EditTextView.st
author Claus Gittinger <cg@exept.de>
Sat, 23 Mar 1996 17:21:25 +0100
changeset 516 656a8f993435
parent 503 468d4a36ed67
child 522 aa9458e4643e
permissions -rw-r--r--
dont crash without items
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
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
    16
		cursorFgColor cursorBgColor cursorType undoAction typeOfSelection
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
    17
		lastString lastReplacement lastAction replacing
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    18
		showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    19
		tabMeansNextField autoIndent insertMode'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    20
	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
118
claus
parents: 105
diff changeset
    21
		DefaultCursorType'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    22
	poolDictionaries:''
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    23
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    24
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    25
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    26
!EditTextView class methodsFor:'documentation'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    27
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    28
copyright
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    29
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    30
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
    31
	      All Rights Reserved
33
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
 This software is furnished under a license and may be used
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    34
 only in accordance with the terms of that license and with the
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    35
 inclusion of the above copyright notice.   This software may not
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    36
 be provided or otherwise made available to, or used by, any
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    37
 other person.  No title to or ownership of the software is
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    38
 hereby transferred.
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    39
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    40
!
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    41
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    42
documentation
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    43
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    44
    a view for editable text - adds editing functionality to TextView
125
claus
parents: 123
diff changeset
    45
    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
    46
    acceptAction to be performed for accept
125
claus
parents: 123
diff changeset
    47
claus
parents: 123
diff changeset
    48
    If used with a model, this is informed by sending it a changeMsg with
claus
parents: 123
diff changeset
    49
    the current contents as argument.
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    50
    (however, it is possible to define both changeMsg and acceptAction)
125
claus
parents: 123
diff changeset
    51
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
    52
    Please read the historic notice in the ListView class.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    53
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    54
    Instance variables:
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    55
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    56
        cursorLine              <Number>        line where cursor sits (1..)
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    57
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    58
        cursorVisibleLine       <Number>        visible line where cursor sits (1..nLinesShown)
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    59
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    60
        cursorCol               <Number>        col where cursor sits (1..)
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    61
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    62
        cursorShown             <Boolean>       true, if cursor is currently shown
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    63
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    64
        readOnly                <Boolean>       true, if text may not be edited
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    65
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    66
        modifiedCHannel         <ValueHolder>   holding true, if text has been modified
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    67
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    68
        fixedSize               <Boolean>       true, if no lines may be added/removed
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    69
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    70
        exceptionBlock          <Block>         block to be evaluated when readonly text is about to be modified
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    71
						if it returns true, the modification will be done anyway.
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    72
						if it returns anything else, the modification is not done.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    73
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    74
        cursorFgColor           <Color>         color used for cursor drawing
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    75
        cursorBgColor           <Color>         color used for cursor drawing
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    76
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    77
        cursorType              <Symbol>        how the cursor is drawn; currently implemented
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    78
					        are #block (solid-block cursor), #ibeam
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    79
					        (vertical bar at insertion point) 
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    80
					        and #caret (caret below insertion-point)
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    81
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    82
        undoAction              <Block>         block which undoes last cut, paste or replace
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    83
						(not yet fully implemented)
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    84
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    85
        typeOfSelection         <Symbol>        #paste, if selection created by paste, nil otherwise
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    86
						this affects the next keyPress: if #paste it does not
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    87
						replace; otherwise it replaces the selection.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    88
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    89
        lastCut                 <String>        last cut or replaced string
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    90
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    91
        lastReplacement         <String>        last replacement
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    92
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    93
        replacing               <Boolean>       true if entered characters replace last selection
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    94
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    95
        showMatchingParenthesis <Boolean>       if true, shows matching parenthesis
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    96
					        when entering one; this is the default.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    97
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    98
	hasKeyboardFocus	<Boolean>	true if this view has the focus
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    99
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   100
	acceptAction 		<Block>		accept action - evaluated passing the contents as 
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   101
						argument 
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   102
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   103
        tabMeansNextField	<Boolean>	if true, Tab is ignored as input and shifts keyboard
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   104
						focus to the next field. For editTextViews, this is false
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   105
						by default (i.e. tabs can be entered into the text).
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   106
						For some subclasses (inputFields), this may be true.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   107
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   108
	lockUpdates		<Boolean>	internal, private
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   109
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   110
        prevCursorState         <Boolean>       temporary, private
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   111
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   112
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   113
    used globals:
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   114
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   115
        DeleteHistory           <Text>          last 1000 lines of deleted text
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   116
					        (but only if this variable exists already)
121
claus
parents: 118
diff changeset
   117
claus
parents: 118
diff changeset
   118
    styleSheet parameters:
claus
parents: 118
diff changeset
   119
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   120
        textCursorForegroundColor <Color>       cursor fg color; default: text background
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   121
        textCursorBackgroundColor <Color>       cursor bg color; default: text foreground
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   122
        textCursorType            <Symbol>      cursor type; default:  #block
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   123
"
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   124
!
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   125
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   126
examples
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   127
"
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   128
  non MVC operation:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   129
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   130
    basic setup:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   131
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   132
	|top textView|
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   133
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   134
	top := StandardSystemView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   135
	top extent:300@200.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   136
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   137
	textView := EditTextView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   138
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   139
	top addSubView:textView.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   140
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   141
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   142
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   143
	top open.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   144
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   145
    with vertical scrollbar:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   146
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   147
	|top scrollView textView|
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   148
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   149
	top := StandardSystemView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   150
	top extent:300@200.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   151
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   152
	scrollView := ScrollableView for:EditTextView.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   153
	textView := scrollView scrolledView.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   154
	scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   155
	top addSubView:scrollView.
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
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
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
	top open.
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
    with horizontal & vertical scrollbars:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   162
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   163
	|top scrollView textView|
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   164
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   165
	top := StandardSystemView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   166
	top extent:300@200.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   167
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   168
	scrollView := HVScrollableView for:EditTextView.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   169
	textView := scrollView scrolledView.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   170
	scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   171
	top addSubView:scrollView.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   172
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   173
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   174
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   175
	top open.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   176
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
    set the action for accept:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   179
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   180
	|top textView|
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   181
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   182
	top := StandardSystemView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   183
	top extent:300@200.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   184
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   185
	textView := EditTextView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   186
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   187
	top addSubView:textView.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   188
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   189
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   190
	textView acceptAction:[:contents |
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   191
				Transcript showCr:'will not overwrite the file with:'.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   192
				Transcript showCr:contents asString
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   193
			      ].
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   194
	top open.
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
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   197
  MVC operation:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   198
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   199
	(the examples model here is a plug simulating a real model;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   200
	 real world applications would not use a plug ..)
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   201
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   202
	|top textView model|
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   203
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   204
	model := Plug new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   205
	model respondTo:#accepted:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   206
		   with:[:newContents | 
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   207
				Transcript showCr:'will not overwrite the file with:'.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   208
				Transcript showCr:newContents asString
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   209
			].
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   210
	model respondTo:#getList
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   211
		   with:['/etc/hosts' asFilename contentsOfEntireFile].
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
	top := StandardSystemView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   215
	top extent:300@200.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   216
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   217
	textView := EditTextView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   218
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   219
	top addSubView:textView.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   220
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   221
	textView model:model;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   222
		 changeMessage:#accepted:;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   223
		 listMessage:#getList;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   224
		 aspect:#list.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   225
	top open.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   226
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   227
    two textViews on the same model:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   228
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   229
	|top1 textView1 top2 textView2 model currentContents|
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   230
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   231
	model := Plug new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   232
	model respondTo:#accepted:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   233
		   with:[:newContents |
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   234
				Transcript showCr:'accepted'.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   235
				currentContents := newContents.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   236
				self changed:#contents
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   237
			].
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   238
	model respondTo:#getList
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   239
		   with:[self halt. currentContents].
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   240
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   241
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   242
	top1 := StandardSystemView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   243
	top1 extent:300@200.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   244
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   245
	textView1 := EditTextView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   246
	textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   247
	top1 addSubView:textView1.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   248
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   249
	textView1 model:model;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   250
		  aspect:#contents;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   251
		  changeMessage:#accepted:;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   252
		  listMessage:#getList.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   253
	top1 open.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   254
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   255
	top2 := StandardSystemView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   256
	top2 extent:300@200.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   257
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   258
	textView2 := EditTextView new.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   259
	textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   260
	top2 addSubView:textView2.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   261
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   262
	textView2 model:model;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   263
		  aspect:#contents;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   264
		  changeMessage:#accepted:;
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   265
		  listMessage:#getList.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   266
	top2 open.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   267
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   268
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   269
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   270
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   271
!EditTextView class methodsFor:'defaults'!
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   272
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   273
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   274
    "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
   275
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   276
    <resource: #style (#textCursorForegroundColor #textCursorBackgroundColor
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   277
                       #textCursorType )>
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   278
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   279
    DefaultCursorForegroundColor := StyleSheet colorAt:'textCursorForegroundColor'.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   280
    DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursorBackgroundColor'.
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   281
    DefaultCursorType := StyleSheet at:'textCursorType' default:#block.
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   282
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   283
    "Modified: 1.3.1996 / 13:45:41 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   284
! !
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   285
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   286
!EditTextView methodsFor:'ST-80 compatibility editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   287
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   288
insertAndSelect:aString at:aCharacterPosition
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   289
    "insert a selected string at aCharacterPosition."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   290
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   291
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   292
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   293
    line := self lineOfCharacterPosition:aCharacterPosition.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   294
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   295
    self insertString:aString atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   296
    self selectFromLine:line col:col toLine:line col:col + aString size - 1
125
claus
parents: 123
diff changeset
   297
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   298
     |v|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   299
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   300
     v := EditTextView new openAndWait.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   301
     v contents:'1234567890\1234567890\1234567890\' withCRs.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   302
     v insertAndSelect:'<- hello there' at:5.
125
claus
parents: 123
diff changeset
   303
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   304
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   305
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   306
!EditTextView methodsFor:'accessing-behavior'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   307
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   308
acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   309
    "return the action to be performed on accept (or nil)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   310
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   311
    ^ acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   312
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   313
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   314
acceptAction:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   315
    "set the action to be performed on accept"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   316
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   317
    acceptAction := aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   318
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   319
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   320
autoIndent:aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   321
    autoIndent := aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   322
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   323
    "Created: 5.3.1996 / 14:37:50 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   324
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   325
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   326
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   327
    "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
   328
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   329
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   330
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   331
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   332
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   333
insertMode:aBoolean
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   334
    insertMode := aBoolean
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   335
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   336
    "Created: 6.3.1996 / 12:24:05 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   337
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   338
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   339
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   340
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   341
     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
   342
     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
   343
     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
   344
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   345
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   346
    tabMeansNextField := aBoolean
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   347
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   348
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   349
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   350
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   351
characterUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   352
    "return the character under the cursor - space if behond line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   353
     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
   354
     of the insertion-bar or caret."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   355
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   356
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   357
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   358
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   359
contents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   360
    "return the contents as a String"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   361
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   362
    list isNil ifTrue:[^ ''].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   363
    self removeTrailingBlankLines.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   364
    ^ list asStringWithCRs
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   365
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   366
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   367
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   368
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   369
     This is the absolute col; NOT the visible col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   370
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   371
    ^ cursorCol
125
claus
parents: 123
diff changeset
   372
!
claus
parents: 123
diff changeset
   373
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   374
cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   375
    "return the cursors line (1..). 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   376
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   377
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   378
    ^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   379
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   380
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   381
fixedSize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   382
    "make the texts size fixed (no lines may be added).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   383
     OBSOLETE: use readOnly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   384
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   385
    readOnly ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   386
	readOnly := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   387
	middleButtonMenu notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   388
	    middleButtonMenu disableAll:#(cut paste replace indent)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   389
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   390
    ]
127
claus
parents: 125
diff changeset
   391
!
claus
parents: 125
diff changeset
   392
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   393
fromFile:aFileName
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   394
    "take contents from a named file"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   395
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   396
    self contents:(aFileName asFilename readStream contents)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   397
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   398
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   399
list:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   400
    "position cursor home when setting contents"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   401
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   402
    super list:something.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   403
    self cursorHome
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   404
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   405
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   406
modified
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   407
    "return true if text was modified"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   408
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   409
    ^ modifiedChannel value
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   410
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   411
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   412
modified:aBoolean
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   413
    "set the modified flag"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   414
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   415
    modifiedChannel value:aBoolean
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   416
!
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   417
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   418
modifiedChannel
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   419
    "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
   420
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   421
    ^ modifiedChannel
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   422
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   423
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   424
readOnly
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   425
    "make the text readonly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   426
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   427
    readOnly := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   428
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   429
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   430
!EditTextView methodsFor:'accessing-look'!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   431
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   432
cursorForegroundColor:color1 backgroundColor:color2
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   433
    "set both cursor foreground and cursor background colors"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   434
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   435
    |wasOn|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   436
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   437
    wasOn := self hideCursor.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   438
    cursorFgColor := color1 on:device.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   439
    cursorBgColor := color2 on:device.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   440
    wasOn ifTrue:[self showCursor]
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   441
! !
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   442
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   443
!EditTextView methodsFor:'change & update '!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   444
125
claus
parents: 123
diff changeset
   445
accept
claus
parents: 123
diff changeset
   446
    "accept the current contents by executing the accept-action and/or
claus
parents: 123
diff changeset
   447
     changeMessage."
claus
parents: 123
diff changeset
   448
claus
parents: 123
diff changeset
   449
    lockUpdates := true.
claus
parents: 123
diff changeset
   450
     "/
claus
parents: 123
diff changeset
   451
     "/ ST/X way of doing things
claus
parents: 123
diff changeset
   452
     "/ as a historic (and temporary) leftover,
claus
parents: 123
diff changeset
   453
     "/ the block is called with a stringCollection
claus
parents: 123
diff changeset
   454
     "/ - not with the actual string
claus
parents: 123
diff changeset
   455
     "/
claus
parents: 123
diff changeset
   456
     acceptAction notNil ifTrue:[
claus
parents: 123
diff changeset
   457
	 acceptAction value:self list
claus
parents: 123
diff changeset
   458
     ].
claus
parents: 123
diff changeset
   459
claus
parents: 123
diff changeset
   460
     "/
claus
parents: 123
diff changeset
   461
     "/ ST-80 way of doing it
claus
parents: 123
diff changeset
   462
     "/
127
claus
parents: 125
diff changeset
   463
     self sendChangeMessageWith:self argForChangeMessage.
125
claus
parents: 123
diff changeset
   464
claus
parents: 123
diff changeset
   465
    lockUpdates := false.
131
claus
parents: 130
diff changeset
   466
!
claus
parents: 130
diff changeset
   467
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   468
argForChangeMessage
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   469
    ^ self contents
121
claus
parents: 118
diff changeset
   470
!
claus
parents: 118
diff changeset
   471
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   472
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   473
    "get my contents from the model.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   474
     Redefined to ignore updates resulting from my own change."
121
claus
parents: 118
diff changeset
   475
claus
parents: 118
diff changeset
   476
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   477
     ignore updates from my own change
121
claus
parents: 118
diff changeset
   478
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   479
    lockUpdates ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   480
	lockUpdates := false.
125
claus
parents: 123
diff changeset
   481
	^ self
121
claus
parents: 118
diff changeset
   482
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   483
    ^ super getListFromModel
121
claus
parents: 118
diff changeset
   484
! !
claus
parents: 118
diff changeset
   485
claus
parents: 118
diff changeset
   486
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
   487
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   488
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   489
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   490
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   491
    self cursorCol:(self prevTabBefore:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   492
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   493
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   494
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   495
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   496
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   497
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   498
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   499
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   500
    cursorCol := newCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   501
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   502
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   503
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   504
cursorDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   505
    "move cursor down; scroll if at end of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   506
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   507
    self cursorDown:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   508
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   509
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   510
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   511
    "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
   512
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   513
    |wasOn nv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   514
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   515
    cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   516
	wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   517
	nv := cursorVisibleLine + n - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   518
	(nv >= nFullLinesShown) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   519
	    self scrollDown:(nv - nFullLinesShown + 1)
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
	cursorLine := cursorLine + n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   522
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   523
	wasOn ifTrue:[self showCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   524
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   525
	cursorLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   526
	    cursorLine := firstLineShown
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
	cursorLine := cursorLine + n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   529
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   530
	self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   531
    ].
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   532
    "/ cursor no longer visible ?
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   533
    cursorVisibleLine isNil ifTrue:[
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   534
	cursorLine > list size ifTrue:[
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   535
	    device beep. device sync.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   536
	]
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   537
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   538
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   539
121
claus
parents: 118
diff changeset
   540
cursorHome
131
claus
parents: 130
diff changeset
   541
    "Otherwise, scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
   542
claus
parents: 118
diff changeset
   543
    |wasOn|
claus
parents: 118
diff changeset
   544
claus
parents: 118
diff changeset
   545
    wasOn := self hideCursor.
claus
parents: 118
diff changeset
   546
    cursorCol := 1.
131
claus
parents: 130
diff changeset
   547
    self scrollToTop.
claus
parents: 130
diff changeset
   548
    cursorLine := cursorVisibleLine := 1.
121
claus
parents: 118
diff changeset
   549
    self makeCursorVisibleAndShowCursor:wasOn.
claus
parents: 118
diff changeset
   550
!
claus
parents: 118
diff changeset
   551
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   552
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   553
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   554
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   555
    (cursorCol ~~ 1) ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   556
	self cursorCol:(cursorCol - 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   557
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   558
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   559
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   560
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   561
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   562
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   563
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   564
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   565
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   566
    cursorLine := line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   567
    cursorVisibleLine := self listLineToVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   568
    cursorCol := col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   569
    (cursorCol < 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   570
	cursorCol := 1
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
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   573
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   574
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   575
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   576
    "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
   577
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   578
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   579
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   580
    self checkForExistingLine:(cursorLine + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   581
    cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   582
	nFullLinesShown notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   583
	    (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   584
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   585
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   586
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   587
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   588
    cursorCol := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   589
    cursorLine := cursorLine + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   590
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   591
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   592
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   593
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   594
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   595
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   596
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   597
    self cursorCol:(cursorCol + 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   598
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   599
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   600
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   601
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   602
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   603
    self cursorCol:(self nextTabAfter:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   604
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   605
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   606
cursorToBeginOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   607
    "move cursor to start of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   608
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   609
    self cursorCol:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   610
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   611
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   612
cursorToBottom
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   613
    "move cursor to last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   614
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   615
    |wasOn newTop|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   616
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   617
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   618
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   619
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   620
    (newTop < 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   621
	newTop := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   622
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   623
    self scrollToLine:newTop.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   624
    cursorCol := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   625
    cursorLine := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   626
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   627
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   628
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   629
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   630
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   631
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   632
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   633
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   634
    |wasOn newTop l line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   635
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   636
    l := list size.
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
    cursorLine >= l ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   639
	line := self listAt:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   640
	(line isNil or:[line isEmpty]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   641
	    ^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   642
	]
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   645
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   646
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   647
    l := l + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   648
    newTop :=  l - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   649
    (newTop < 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   650
	newTop := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   651
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   652
    self scrollToLine:newTop.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   653
    cursorCol := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   654
    cursorLine := l.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   655
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   656
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   657
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   658
!
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
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   661
    "move cursor to end of current line"
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
    |line newCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   664
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   665
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   666
	newCol := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   667
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   668
	line := list at:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   669
	newCol := line size + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   670
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   671
    self cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   672
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   673
131
claus
parents: 130
diff changeset
   674
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
   675
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
   676
claus
parents: 130
diff changeset
   677
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
   678
!
claus
parents: 130
diff changeset
   679
claus
parents: 130
diff changeset
   680
cursorToLastVisibleLine
claus
parents: 130
diff changeset
   681
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
   682
claus
parents: 130
diff changeset
   683
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
   684
!
claus
parents: 130
diff changeset
   685
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   686
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   687
    "move the cursor to the beginning of the next word"
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
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   690
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   691
    (cursorLine > list size) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   692
    self wordAtLine:cursorLine col:cursorCol do:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   693
	:beginLine :beginCol :endLine :endCol :style | 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   694
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   695
	line := endLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   696
	col := endCol + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   697
	searching := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   698
	[searching 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   699
	 and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   700
	    self wordAtLine:line col:col do:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   701
		:beginLine :beginCol :endLine :endCol :style |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   702
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   703
		(line > list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   704
		    "break out"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   705
		    searching := false
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   706
		] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   707
		    line := endLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   708
		    col := endCol + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   709
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   710
	    ]
121
claus
parents: 118
diff changeset
   711
	].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   712
	self cursorLine:line col:col
121
claus
parents: 118
diff changeset
   713
    ]
claus
parents: 118
diff changeset
   714
!
claus
parents: 118
diff changeset
   715
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   716
cursorToPreviousWord
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   717
    "move the cursor to the beginning of this or the previous word"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   718
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   719
    |col line searching l|
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   720
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   721
    (cursorLine > list size) ifTrue:[^ self].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   722
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   723
    self wordAtLine:cursorLine col:cursorCol do:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   724
        :beginLine :beginCol :endLine :endCol :style | 
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   725
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   726
        line := beginLine.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   727
        col := beginCol.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   728
        style == #wordLeft ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   729
            col := col + 1
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   730
        ].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   731
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   732
        (cursorLine == line
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   733
        and:[cursorCol == col]) ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   734
            searching := true.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   735
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   736
            col > 1 ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   737
                col := col - 1.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   738
            ].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   739
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   740
            [searching] whileTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   741
                (col == 1) ifTrue:[    
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   742
                    line == 1 ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   743
                        searching := false
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   744
                    ] ifFalse:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   745
                        line := line - 1.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   746
                        l := list at:line.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   747
                        col := l size + 1.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   748
                    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   749
                ] ifFalse:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   750
                    (self characterAtLine:line col:col) isSeparator ifFalse:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   751
                        self wordAtLine:line col:col do:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   752
                            :beginLine :beginCol :endLine :endCol :style |
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   753
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   754
                            line := beginLine.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   755
                            col := beginCol.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   756
                            style == #wordLeft ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   757
                                col := col + 1
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   758
                            ].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   759
                            searching := false.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   760
                        ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   761
                    ] ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   762
                        col := col - 1
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   763
                    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   764
                ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   765
            ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   766
        ].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   767
        self cursorLine:line col:col
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   768
    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   769
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   770
    "Created: 8.3.1996 / 21:52:48 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   771
    "Modified: 8.3.1996 / 22:12:45 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   772
!
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   773
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   774
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   775
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   776
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   777
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   778
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   779
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   780
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   781
    "move cursor up; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   782
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   783
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   784
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   785
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   786
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   787
    "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
   788
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   789
    |wasOn nv nl|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   790
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   791
    cursorLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   792
	cursorLine := firstLineShown + nFullLinesShown - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   793
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   794
    nl := cursorLine - n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   795
    nl < 1 ifTrue:[nl := 1].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   796
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   797
    (nl ~~ cursorLine) ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   798
	wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   799
	cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   800
	    nv := cursorVisibleLine - n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   801
	    nv < 1 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   802
		self scrollUp:(nv negated + 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   803
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   804
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   805
	cursorLine := nl.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   806
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   807
	wasOn ifTrue:[self showCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   808
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   809
"/ to make cursor visible (even if below visible end):
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   810
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   811
"/      self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   812
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   813
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   814
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   815
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   816
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   817
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   818
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   819
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   820
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   821
    cursorLine := self visibleLineToAbsoluteLine:visibleLineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   822
    cursorVisibleLine := visibleLineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   823
    cursorCol := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   824
    (cursorCol < 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   825
	cursorCol := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   826
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   827
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   828
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   829
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   830
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   831
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
   832
claus
parents: 118
diff changeset
   833
    |line col|
claus
parents: 118
diff changeset
   834
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   835
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   836
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   837
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
   838
!
claus
parents: 118
diff changeset
   839
claus
parents: 118
diff changeset
   840
drawCursor
claus
parents: 118
diff changeset
   841
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
   842
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
   843
claus
parents: 118
diff changeset
   844
    shown ifTrue:[
claus
parents: 118
diff changeset
   845
	cursorVisibleLine notNil ifTrue:[
claus
parents: 118
diff changeset
   846
	    self hasSelection ifFalse:[
claus
parents: 118
diff changeset
   847
		self drawCursorCharacter
claus
parents: 118
diff changeset
   848
	    ]
claus
parents: 118
diff changeset
   849
	]
claus
parents: 118
diff changeset
   850
    ]
claus
parents: 118
diff changeset
   851
!
claus
parents: 118
diff changeset
   852
claus
parents: 118
diff changeset
   853
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
   854
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
   855
     of cursor should be drawn.
claus
parents: 123
diff changeset
   856
     Currently, supported are: #block, #frame, #ibeam, #caret and #solidCaret"
121
claus
parents: 118
diff changeset
   857
133
claus
parents: 132
diff changeset
   858
    |x y w char y2 x1 x2 oldPaint|
121
claus
parents: 118
diff changeset
   859
claus
parents: 118
diff changeset
   860
    self hasSelection ifTrue:[
claus
parents: 118
diff changeset
   861
	"
claus
parents: 118
diff changeset
   862
	 hide cursor, if there is a selection
claus
parents: 118
diff changeset
   863
	"
claus
parents: 118
diff changeset
   864
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
claus
parents: 118
diff changeset
   865
    ].
claus
parents: 118
diff changeset
   866
claus
parents: 118
diff changeset
   867
    cursorType == #block ifTrue:[
claus
parents: 118
diff changeset
   868
	super drawVisibleLine:cursorVisibleLine 
claus
parents: 118
diff changeset
   869
			  col:cursorCol 
claus
parents: 118
diff changeset
   870
			 with:fgColor
claus
parents: 118
diff changeset
   871
			  and:bgColor.
claus
parents: 118
diff changeset
   872
	^ self
claus
parents: 118
diff changeset
   873
    ].
claus
parents: 118
diff changeset
   874
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - leftOffset.
claus
parents: 118
diff changeset
   875
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
   876
133
claus
parents: 132
diff changeset
   877
    oldPaint := paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
   878
    cursorType == #frame ifTrue:[
claus
parents: 118
diff changeset
   879
	super redrawVisibleLine:cursorVisibleLine col:cursorCol.
claus
parents: 118
diff changeset
   880
claus
parents: 118
diff changeset
   881
	char := self characterUnderCursor asString.
claus
parents: 118
diff changeset
   882
	self paint:bgColor.
133
claus
parents: 132
diff changeset
   883
	self displayRectangleX:x y:y 
claus
parents: 132
diff changeset
   884
			 width:(font widthOf:char) height:fontHeight.
claus
parents: 132
diff changeset
   885
    ] ifFalse:[
claus
parents: 132
diff changeset
   886
	self paint:bgColor.
claus
parents: 132
diff changeset
   887
	cursorType == #ibeam ifTrue:[
claus
parents: 132
diff changeset
   888
	    x1 := x - 1.
claus
parents: 132
diff changeset
   889
	    y2 := y + fontHeight - 1.
claus
parents: 132
diff changeset
   890
	    self displayLineFromX:x1 y:y toX:x1 y:y2. 
claus
parents: 132
diff changeset
   891
	    self displayLineFromX:x y:y toX:x y:y2. 
claus
parents: 132
diff changeset
   892
	    ^ self
claus
parents: 132
diff changeset
   893
	] ifFalse:[
claus
parents: 132
diff changeset
   894
	    w := fontWidth // 2.
claus
parents: 132
diff changeset
   895
	    y := y + fontHeight - 3.
claus
parents: 132
diff changeset
   896
	    y2 := y + w.
claus
parents: 132
diff changeset
   897
	    x1 := x - w.
claus
parents: 132
diff changeset
   898
	    x2 := x + w.
claus
parents: 132
diff changeset
   899
	    cursorType == #caret ifTrue:[
claus
parents: 132
diff changeset
   900
		self lineWidth:2.
claus
parents: 132
diff changeset
   901
		self displayLineFromX:x1 y:y2 toX:x y:y. 
claus
parents: 132
diff changeset
   902
		self displayLineFromX:x y:y toX:x2 y:y2. 
claus
parents: 132
diff changeset
   903
	    ] ifFalse:[
claus
parents: 132
diff changeset
   904
		"anything else: solidCaret"
claus
parents: 132
diff changeset
   905
claus
parents: 132
diff changeset
   906
		self fillPolygon:(Array with:(x1 @ y2)
claus
parents: 132
diff changeset
   907
					with:(x @ y)
claus
parents: 132
diff changeset
   908
					with:(x2 @ y2))
claus
parents: 132
diff changeset
   909
	    ]
claus
parents: 132
diff changeset
   910
	]
121
claus
parents: 118
diff changeset
   911
    ].
133
claus
parents: 132
diff changeset
   912
    self paint:oldPaint.
121
claus
parents: 118
diff changeset
   913
!
claus
parents: 118
diff changeset
   914
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   915
drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   916
    "draw the cursor. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   917
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   918
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   919
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   920
    hasKeyboardFocus ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   921
	self drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   922
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   923
	self drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   924
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   925
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   926
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   927
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   928
    "draw the cursor when the focus is in the view."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   929
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   930
    self hasSelection ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   931
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
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
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   934
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   935
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   936
drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   937
    "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
   938
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   939
    self hasSelection ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   940
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
   941
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   942
    cursorType ~~ #block ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   943
	"these dont show unfocussed"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   944
	^ self drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   945
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   946
    self drawCursor:#frame with:cursorFgColor and:cursorBgColor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   947
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   948
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   949
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   950
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   951
     Make certain that this line is visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   952
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   953
    self makeLineVisible:aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   954
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   955
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   956
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   957
hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   958
    "make cursor invisible if currently visible; 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   959
     return true if cursor was visible before."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   960
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   961
    cursorShown ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   962
	shown ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   963
	    self undrawCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   964
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   965
	cursorShown := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   966
	^ true
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
    ^ false
121
claus
parents: 118
diff changeset
   969
!
claus
parents: 118
diff changeset
   970
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   971
makeCursorVisible
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   972
    "scroll text to make cursorline visible 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   973
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   974
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   975
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   976
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   977
    cursorLine notNil ifTrue:[
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   978
        line := cursorLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   979
        col := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   980
        "
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   981
         if there is a selection, its better to
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   982
         have its start being visible, instead of the end
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   983
        "
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   984
        (selectionStartLine notNil 
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   985
        and:[selectionEndLine notNil]) ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   986
            expandingTop ~~ false ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   987
                line := selectionStartLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   988
                col := selectionStartCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   989
            ] ifFalse:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   990
                line := selectionEndLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   991
                col := selectionEndCol
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   992
            ]
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   993
        ].
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   994
        self makeLineVisible:line.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   995
        self makeColVisible:col inLine:line 
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   996
    ]
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   997
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
   998
    "Modified: 6.3.1996 / 13:46:46 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   999
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1000
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1001
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1002
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1003
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1004
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1005
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1006
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
  1007
!
claus
parents: 118
diff changeset
  1008
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1009
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1010
    "make cursor visible if currently invisible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1011
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1012
    cursorShown ifFalse: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1013
	self drawCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1014
	cursorShown := true
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1018
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1019
    "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
  1020
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1021
    cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1022
	((cursorType == #caret) or:[cursorType == #solidCaret]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1023
	    "caret-cursor touches 4 characters"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1024
	    ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1025
		super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1026
		super redrawVisibleLine:cursorVisibleLine+1 from:cursorCol-1 to:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1027
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1028
		"care for left margin"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1029
		super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1030
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1031
	    ^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1032
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1033
	cursorType == #ibeam ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1034
	    "ibeam-cursor touches 2 characters"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1035
	    cursorCol > 1 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1036
		super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1037
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1038
		"care for left margin"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1039
		super redrawVisibleLine:cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1040
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1041
	    ^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1042
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1043
	"block is simple - just one character under cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1044
	super redrawVisibleLine:cursorVisibleLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1045
    ]
121
claus
parents: 118
diff changeset
  1046
!
claus
parents: 118
diff changeset
  1047
claus
parents: 118
diff changeset
  1048
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
  1049
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
  1050
claus
parents: 118
diff changeset
  1051
    (shown not or:[cursorShown not]) ifTrue:[
claus
parents: 118
diff changeset
  1052
	^ aBlock value
claus
parents: 118
diff changeset
  1053
    ].
claus
parents: 118
diff changeset
  1054
    self hideCursor.
claus
parents: 118
diff changeset
  1055
    aBlock valueNowOrOnUnwindDo:[
claus
parents: 118
diff changeset
  1056
	self showCursor
claus
parents: 118
diff changeset
  1057
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1058
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1059
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1060
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1061
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1062
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1063
    "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
  1064
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1065
    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
  1066
	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
  1067
	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
  1068
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1069
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1070
    "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
  1071
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1072
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1073
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1074
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  1075
claus
parents: 118
diff changeset
  1076
    |wasOn|
claus
parents: 118
diff changeset
  1077
claus
parents: 118
diff changeset
  1078
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1079
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1080
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  1081
!
claus
parents: 118
diff changeset
  1082
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1083
deleteCharAtLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1084
    "delete single character at colNr in line lineNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1085
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1086
    |line lineSize newLine drawCharacterOnly wasLargest|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1087
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1088
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1089
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1090
    line := self listAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1091
    line isNil ifTrue: [^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1092
    lineSize := line size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1093
    (colNr > lineSize) ifTrue: [^ self].
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
    wasLargest := (self widthOfLineString:line) == widthOfWidestLine.
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
    drawCharacterOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1098
    (colNr == lineSize) ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1099
        newLine := line copyTo:(lineSize - 1).
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1100
        fontIsFixedWidth ifTrue:[
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1101
            drawCharacterOnly := true
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1102
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1103
    ] ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1104
        newLine := line species new:(lineSize - 1).
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1105
        newLine replaceFrom:1 to:(colNr - 1)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1106
                       with:line startingAt:1.
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1107
        newLine replaceFrom:colNr to:(lineSize - 1)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1108
                       with:line startingAt:(colNr + 1)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1109
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1110
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1111
    newLine isBlank ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1112
        newLine := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1113
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1114
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1115
    wasLargest ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1116
        widthOfWidestLine := nil. "/ i.e. unknown
259
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 textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1119
    drawCharacterOnly ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1120
        self redrawLine:lineNr col:colNr
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1121
    ] ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1122
        self redrawLine:lineNr from:colNr
121
claus
parents: 118
diff changeset
  1123
    ]
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1124
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1125
    "Modified: 23.2.1996 / 17:42:23 / cg"
121
claus
parents: 118
diff changeset
  1126
!
claus
parents: 118
diff changeset
  1127
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1128
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1129
    "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
  1130
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1131
    |wasOn oldSize lineNrAboveCursor|
121
claus
parents: 118
diff changeset
  1132
claus
parents: 118
diff changeset
  1133
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1134
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1135
    (cursorCol == 1) ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1136
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1137
	 somewhere in the middle of a line
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1138
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1139
	self cursorLeft.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1140
	self deleteCharAtLine:cursorLine col:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1141
    ] ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1142
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1143
	 at begin of line - merge with previous line;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1144
	 except for the very first line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1145
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1146
	(cursorLine == 1) ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1147
	    oldSize := 0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1148
	    lineNrAboveCursor := cursorLine - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1149
	    list notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1150
	       (list size >= lineNrAboveCursor) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1151
		   (list at:lineNrAboveCursor) notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1152
		       oldSize := (list at:lineNrAboveCursor) size
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1153
		   ]
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
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1156
	    self mergeLine:lineNrAboveCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1157
	    cursorLine := lineNrAboveCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1158
	    cursorCol := oldSize + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1159
	    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1160
	    self makeCursorVisible
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1161
	]
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
    wasOn ifTrue:[self showCursor].
121
claus
parents: 118
diff changeset
  1164
!
claus
parents: 118
diff changeset
  1165
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1166
deleteCharsAtLine:lineNr fromCol:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1167
    "delete characters from colNr up to the end in line lineNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1168
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1169
    |line newLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1170
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1171
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1172
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1173
    line := self listAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1174
    line isNil ifTrue: [^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1175
    (colNr > line size) ifTrue: [^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1176
    newLine := line copyTo:(colNr - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1177
    newLine isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1178
	newLine := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1179
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1180
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1181
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1182
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1183
    self redrawLine:lineNr
131
claus
parents: 130
diff changeset
  1184
!
claus
parents: 130
diff changeset
  1185
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1186
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1187
    "delete characters from startCol to endCol in line lineNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1188
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1189
    |line lineSize newLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1190
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1191
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1192
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1193
    line := self listAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1194
    line isNil ifTrue: [^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1195
    lineSize := line size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1196
    (startCol > lineSize) ifTrue: [^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1197
    (endCol == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1198
    (endCol < startCol) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1199
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1200
    (startCol == endCol) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1201
	self deleteCharAtLine:lineNr col:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1202
	^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1203
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1204
    (endCol >= lineSize) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1205
	self deleteCharsAtLine:lineNr fromCol:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1206
	^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1207
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1208
    (startCol <= 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1209
	self deleteCharsAtLine:lineNr toCol:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1210
	^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1211
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1212
    newLine := (line copyTo:(startCol - 1)) 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1213
	       , (line copyFrom:(endCol + 1) to:lineSize).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1214
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1215
    newLine isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1216
	newLine := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1217
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1218
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1219
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1220
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1221
    self redrawLine:lineNr
121
claus
parents: 118
diff changeset
  1222
!
claus
parents: 118
diff changeset
  1223
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1224
deleteCharsAtLine:lineNr toCol:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1225
    "delete characters from start up to colNr in line lineNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1226
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1227
    |line lineSize newLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1228
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1229
    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
  1230
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1231
    line := self listAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1232
    line isNil ifTrue: [^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1233
    lineSize := line size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1234
    (colNr >= lineSize) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1235
	newLine := nil
121
claus
parents: 118
diff changeset
  1236
    ] ifFalse:[
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1237
	newLine := line copyFrom:(colNr + 1) to:lineSize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1238
	newLine isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1239
	    newLine := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1240
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1241
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1242
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1243
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1244
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1245
    self redrawLine:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1246
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1247
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1248
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1249
    "delete the line where the cursor sits"
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
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  1252
!
claus
parents: 118
diff changeset
  1253
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1254
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1255
    "delete all text from startLine/startCol to endLine/endCol -
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1256
     joining lines if nescessary"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1257
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1258
    |line lineSize|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1259
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1260
    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
  1261
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1262
    list isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1263
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1264
    (startLine == endLine) ifTrue:[
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1265
        "delete chars within a line"
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1266
        self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1267
        ^ self
121
claus
parents: 118
diff changeset
  1268
    ].
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
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1271
        "delete full lines only"
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1272
        endLine > startLine ifTrue:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1273
            self deleteFromLine:startLine toLine:(endLine - 1)
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1274
        ].
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1275
        ^ self
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
    "delete right rest of 1st line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1279
    self deleteCharsAtLine:startLine fromCol:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1280
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1281
    "delete the inner lines ..."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1282
    endLine > (startLine + 1) ifTrue:[
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1283
        self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1284
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1285
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1286
    (endCol ~~ 0) ifTrue:[
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1287
        "delete the left rest of the last line"
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1288
        self deleteCharsAtLine:(startLine + 1) toCol:endCol.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1289
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1290
        "must add blanks, if startCal lies behond end of startLine"
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1291
        line := list at:startLine.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1292
        lineSize := line size.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1293
        (startCol > lineSize) ifTrue:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1294
            line isNil ifTrue:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1295
                line := String new:(startCol - 1)
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1296
            ] ifFalse:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1297
                line := line , (line species new:(startCol - 1 - lineSize))
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1298
            ].
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1299
            list at:startLine put:line.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1300
            widthOfWidestLine := nil. "/ i.e. unknown
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1301
            self textChanged.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1302
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1303
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1304
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1305
    "merge the left rest of 1st line with right rest of last line into one"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1306
    self mergeLine:startLine
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1307
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1308
    "Modified: 23.2.1996 / 19:08:21 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1309
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1310
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1311
deleteFromLine:startLineNr toLine:endLineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1312
    "delete some lines"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1313
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1314
    |wasOn nLines|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1315
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1316
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1317
    list isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1318
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1319
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1320
    list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1321
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1322
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1323
    self redrawFromLine:startLineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1324
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1325
    nLines := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1326
    (firstLineShown >= nLines) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1327
	self makeLineVisible:nLines
121
claus
parents: 118
diff changeset
  1328
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1329
    wasOn ifTrue:[self showCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1330
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1331
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1332
deleteLine:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1333
    "delete line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1334
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1335
    |wasOn visLine w
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1336
     srcY "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1337
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1338
    w := self widthForScrollBetween:lineNr and:(firstLineShown + nLinesShown).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1339
    (self deleteLineWithoutRedraw:lineNr) ifFalse:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1340
    shown ifFalse:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1341
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1342
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1343
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1344
    visLine := self listLineToVisibleLine:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1345
    visLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1346
	srcY :=  margin + topMargin + (visLine * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1347
	self catchExpose.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1348
	self copyFrom:self x:textStartLeft y:srcY
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1349
			 toX:textStartLeft y:(srcY - fontHeight)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1350
		       width:w height:((nLinesShown - visLine) * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1351
	self redrawVisibleLine:nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1352
	(nFullLinesShown ~~ nLinesShown) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1353
	    self redrawVisibleLine:nLinesShown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1354
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1355
	self waitForExpose
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1356
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1357
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1358
    wasOn ifTrue:[self showCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1359
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1360
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1361
deleteLineWithoutRedraw:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1362
    "delete line - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1363
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1364
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1365
    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
  1366
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1367
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1368
    list removeIndex:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1369
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1370
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1371
    ^ true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1372
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1373
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1374
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1375
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1376
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1377
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1378
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1379
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1380
    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
  1381
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1382
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1383
    (endLine > list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1384
	lastLine := list size
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1385
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1386
	lastLine := endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1387
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1388
    list removeFromIndex:startLine toIndex:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1389
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1390
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1391
    ^ true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1392
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1393
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1394
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1395
    "delete the selection"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1396
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1397
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1398
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1399
    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
  1400
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1401
    selectionStartLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1402
	wasOn := self hideCursor.
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
	startLine := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1405
	startCol := selectionStartCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1406
	endLine := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1407
	endCol := selectionEndCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1408
	self unselectWithoutRedraw.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1409
	self deleteFromLine:startLine col:startCol 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1410
		     toLine:endLine col:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1411
	cursorCol := startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1412
	cursorLine := startLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1413
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1414
	self makeCursorVisibleAndShowCursor:wasOn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1415
    ]
121
claus
parents: 118
diff changeset
  1416
!
claus
parents: 118
diff changeset
  1417
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1418
insert:aCharacter atLine:lineNr col:colNr
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1419
    "insert a single character at lineNr/colNr"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1420
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1421
    |line lineSize newLine drawCharacterOnly|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1422
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1423
    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
  1424
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1425
    aCharacter == (Character cr) ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1426
        self splitLine:lineNr before:colNr.
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1427
        ^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1428
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1429
    drawCharacterOnly := false.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1430
    self checkForExistingLine:lineNr.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1431
    line := list at:lineNr.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1432
    lineSize := line size.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1433
    (aCharacter == Character space) ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1434
        (colNr > lineSize)  ifTrue:[
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1435
            ^ self
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1436
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1437
    ].
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1438
    (lineSize == 0) ifTrue:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1439
        newLine := aCharacter asString species new:colNr.
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1440
        drawCharacterOnly := true
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1441
    ] ifFalse: [
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1442
        (colNr > lineSize) ifTrue: [
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1443
            newLine := line species new:colNr.
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1444
            newLine replaceFrom:1 to:lineSize
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1445
                           with:line startingAt:1.
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1446
            drawCharacterOnly := true
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1447
        ] ifFalse: [
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1448
            newLine := line species new:(lineSize + 1).
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1449
            newLine replaceFrom:1 to:(colNr - 1)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1450
                           with:line startingAt:1.
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1451
            newLine replaceFrom:(colNr + 1) to:(lineSize + 1)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1452
                           with:line startingAt:colNr
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1453
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1454
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1455
    newLine at:colNr put:aCharacter.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1456
    aCharacter == (Character tab) ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1457
        newLine := self withTabsExpanded:newLine.
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1458
        drawCharacterOnly := false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1459
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1460
    list at:lineNr put:newLine.
118
claus
parents: 105
diff changeset
  1461
    widthOfWidestLine notNil ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1462
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
118
claus
parents: 105
diff changeset
  1463
    ].
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1464
    self textChanged.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1465
    shown ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1466
        drawCharacterOnly ifTrue:[
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1467
            self redrawLine:lineNr col:colNr
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1468
        ] ifFalse:[
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1469
            self redrawLine:lineNr from:colNr
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1470
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1471
    ]
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1472
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1473
    "Modified: 23.2.1996 / 19:09:36 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1474
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1475
121
claus
parents: 118
diff changeset
  1476
insertCharAtCursor:aCharacter
claus
parents: 118
diff changeset
  1477
    "insert a single character at cursor-position - advance cursor"
claus
parents: 118
diff changeset
  1478
claus
parents: 118
diff changeset
  1479
    |wasOn|
claus
parents: 118
diff changeset
  1480
claus
parents: 118
diff changeset
  1481
    wasOn := self hideCursor.
claus
parents: 118
diff changeset
  1482
    self insert:aCharacter atLine:cursorLine col:cursorCol.
claus
parents: 118
diff changeset
  1483
    aCharacter == (Character cr) ifTrue:[
claus
parents: 118
diff changeset
  1484
	self cursorReturn
claus
parents: 118
diff changeset
  1485
    ] ifFalse:[
125
claus
parents: 123
diff changeset
  1486
	self cursorRight.
121
claus
parents: 118
diff changeset
  1487
    ].
claus
parents: 118
diff changeset
  1488
    self makeCursorVisibleAndShowCursor:wasOn.
claus
parents: 118
diff changeset
  1489
!
claus
parents: 118
diff changeset
  1490
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1491
insertLine:aString before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1492
    "insert the line aString before line lineNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1493
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1494
    |wasOn visLine w 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1495
     dstY "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1496
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1497
    wasOn := self hideCursor.
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
    visLine := self listLineToVisibleLine:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1500
    (shown not or:[visLine isNil]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1501
	self withoutRedrawInsertLine:aString before:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1502
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1503
	w := self widthForScrollBetween:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1504
				    and:(firstLineShown + nLinesShown).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1505
	dstY := topMargin + ((visLine ) * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1506
	self catchExpose.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1507
	self withoutRedrawInsertLine:aString before:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1508
	self copyFrom:self x:textStartLeft y:(dstY - fontHeight)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1509
			 toX:textStartLeft y:dstY
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1510
		       width:w
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1511
		      height:((nLinesShown - visLine "- 1") * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1512
	self redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1513
	self waitForExpose.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1514
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1515
    widthOfWidestLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1516
	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:aString).
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1517
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1518
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1519
    wasOn ifTrue:[self showCursor].
121
claus
parents: 118
diff changeset
  1520
!
claus
parents: 118
diff changeset
  1521
155
claus
parents: 133
diff changeset
  1522
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  1523
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  1524
claus
parents: 133
diff changeset
  1525
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  1526
claus
parents: 133
diff changeset
  1527
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  1528
!
claus
parents: 133
diff changeset
  1529
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1530
insertLines:someText from:start to:end before:lineNr
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1531
    "insert a bunch of lines before line lineNr"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1532
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1533
    |visLine w nLines "{ Class: SmallInteger }"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1534
     srcY "{ Class: SmallInteger }"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1535
     dstY "{ Class: SmallInteger }" |
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1536
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1537
    readOnly ifTrue:[
118
claus
parents: 105
diff changeset
  1538
	^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1539
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1540
    visLine := self listLineToVisibleLine:lineNr.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1541
    (shown not or:[visLine isNil]) ifTrue:[
118
claus
parents: 105
diff changeset
  1542
	self withoutRedrawInsertLines:someText
claus
parents: 105
diff changeset
  1543
				 from:start to:end
claus
parents: 105
diff changeset
  1544
			       before:lineNr.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1545
    ] ifFalse:[
118
claus
parents: 105
diff changeset
  1546
	nLines := end - start + 1.
claus
parents: 105
diff changeset
  1547
	((visLine + nLines) >= nLinesShown) ifTrue:[
claus
parents: 105
diff changeset
  1548
	    self withoutRedrawInsertLines:someText
claus
parents: 105
diff changeset
  1549
				     from:start to:end
claus
parents: 105
diff changeset
  1550
				   before:lineNr.
claus
parents: 105
diff changeset
  1551
	    self redrawFromVisibleLine:visLine to:nLinesShown
claus
parents: 105
diff changeset
  1552
	] ifFalse:[
claus
parents: 105
diff changeset
  1553
	    w := self widthForScrollBetween:(lineNr + nLines)
claus
parents: 105
diff changeset
  1554
					and:(firstLineShown + nLines + nLinesShown).
claus
parents: 105
diff changeset
  1555
	    srcY := topMargin + ((visLine - 1) * fontHeight).
claus
parents: 105
diff changeset
  1556
	    dstY := srcY + (nLines * fontHeight).
claus
parents: 105
diff changeset
  1557
	    "
claus
parents: 105
diff changeset
  1558
	     stupid: must catchExpose before inserting new
claus
parents: 105
diff changeset
  1559
	     stuff - since catchExpose may perform redraws
claus
parents: 105
diff changeset
  1560
	    "
claus
parents: 105
diff changeset
  1561
	    self catchExpose.
claus
parents: 105
diff changeset
  1562
	    self withoutRedrawInsertLines:someText
claus
parents: 105
diff changeset
  1563
				     from:start to:end
claus
parents: 105
diff changeset
  1564
				   before:lineNr.
claus
parents: 105
diff changeset
  1565
	    self copyFrom:self x:textStartLeft y:srcY
claus
parents: 105
diff changeset
  1566
			     toX:textStartLeft y:dstY
claus
parents: 105
diff changeset
  1567
			   width:w
claus
parents: 105
diff changeset
  1568
			  height:(height - dstY).
claus
parents: 105
diff changeset
  1569
	    self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
claus
parents: 105
diff changeset
  1570
	    self waitForExpose
claus
parents: 105
diff changeset
  1571
	].
claus
parents: 105
diff changeset
  1572
    ].
claus
parents: 105
diff changeset
  1573
    widthOfWidestLine notNil ifTrue:[
claus
parents: 105
diff changeset
  1574
	someText do:[:line |
claus
parents: 105
diff changeset
  1575
	    widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
claus
parents: 105
diff changeset
  1576
	]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1577
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1578
    self textChanged.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1579
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1580
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1581
insertLines:lines withCr:withCr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1582
    "insert a bunch of lines at cursor position. Cursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1583
     is moved behind insertion.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1584
     If withCr is true, append cr after last line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1585
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1586
    |start end nLines wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1587
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1588
    lines notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1589
	nLines := lines size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1590
	(nLines == 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1591
	    self insertStringAtCursor:(lines at:1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1592
	    withCr ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1593
		self insertCharAtCursor:(Character cr)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1594
	    ] 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1595
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1596
	    (cursorCol ~~ 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1597
		self insertStringAtCursor:(lines at:1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1598
		self insertCharAtCursor:(Character cr).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1599
		start := 2
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1600
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1601
		start := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1602
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1603
	    withCr ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1604
		end := nLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1605
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1606
		end := nLines - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1607
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1608
	    (start < nLines) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1609
		(end >= start) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1610
		    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1611
		    self insertLines:lines from:start to:end before:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1612
		    cursorLine := cursorLine + (end - start + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1613
		    cursorVisibleLine := self absoluteLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1614
		    wasOn ifTrue:[self showCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1615
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1616
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1617
	    withCr ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1618
		"last line without cr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1619
		self insertStringAtCursor:(lines at:nLines)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1620
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1621
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1622
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1623
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1624
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1625
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1626
    "insert the argument, aString at cursor position and select it"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1627
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1628
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1629
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1630
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1631
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1632
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1633
    self selectFromLine:startLine col:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1634
		 toLine:cursorLine col:(cursorCol - 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1635
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1636
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1637
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1638
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1639
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1640
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1641
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1642
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1643
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1644
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1645
     l               "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1646
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1647
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1648
    aString isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1649
    ((aString occurrencesOf:(Character cr)) == 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1650
	^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  1651
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1652
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1653
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1654
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1655
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1656
    [start <= end] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1657
	stop := aString indexOf:(Character cr) startingAt:start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1658
	stop == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1659
	    stop := end + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1660
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1661
	subString := aString copyFrom:start to:(stop - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1662
	self insertStringWithoutCRs:subString atLine:l col:c.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1663
	(stop < end) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1664
	    c := c + subString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1665
	    self insert:(Character cr) atLine:l col:c.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1666
	    l := l + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1667
	    c := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1668
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1669
	start := stop + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1670
    ]
121
claus
parents: 118
diff changeset
  1671
!
claus
parents: 118
diff changeset
  1672
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1673
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1674
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1675
     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
  1676
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1677
    |start " { Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1678
     stop  " { Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1679
     end   " { Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1680
     subString|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1681
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1682
    aString isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1683
	"new:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1684
	self insertCharAtCursor:(Character cr).
118
claus
parents: 105
diff changeset
  1685
	^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1686
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1687
    ((aString occurrencesOf:(Character cr)) == 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1688
	^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1689
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1690
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1691
    self insertLines:aString asStringCollection withCr:false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1692
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1693
"/    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1694
"/    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1695
"/    "insert the 1st line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1696
"/    (cursorCol ~~ 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1697
"/        stop := aString indexOf:(Character cr) startingAt:start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1698
"/        stop == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1699
"/            stop := end + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1700
"/        ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1701
"/        subString := aString copyFrom:start to:(stop - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1702
"/        self insertStringWithoutCRsAtCursor:subString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1703
"/        self insertCharAtCursor:(Character cr).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1704
"/        start := stop + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1705
"/    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1706
"/    "insert the block of full lines"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1707
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1708
"/    [start <= end] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1709
"/        stop := aString indexOf:(Character cr) startingAt:start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1710
"/        stop == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1711
"/            stop := end + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1712
"/        ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1713
"/        subString := aString copyFrom:start to:(stop - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1714
"/        self insertStringWithoutCRsAtCursor:subString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1715
"/        (stop < end) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1716
"/            self insertCharAtCursor:(Character cr)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1717
"/        ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1718
"/        start := stop + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1719
"/    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1720
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1721
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1722
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1723
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1724
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1725
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1726
    shown ifTrue:[self redrawLine:lineNr from:colNr]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1727
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1728
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1729
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1730
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1731
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1732
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1733
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1734
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1735
    aString notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1736
	wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1737
	self insertString:aString atLine:cursorLine col:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1738
	cursorCol := cursorCol + aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1739
	wasOn ifTrue:[self showCursor]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1740
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1741
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1742
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1743
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1744
    "insert spaces to next tab"
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
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1747
121
claus
parents: 118
diff changeset
  1748
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1749
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1750
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1751
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1752
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1753
121
claus
parents: 118
diff changeset
  1754
mergeLine:lineNr
claus
parents: 118
diff changeset
  1755
    "merge line lineNr with line lineNr+1"
claus
parents: 118
diff changeset
  1756
claus
parents: 118
diff changeset
  1757
    |leftPart rightPart bothParts nextLineNr|
claus
parents: 118
diff changeset
  1758
claus
parents: 118
diff changeset
  1759
    list isNil ifFalse:[
claus
parents: 118
diff changeset
  1760
	nextLineNr := lineNr + 1.
claus
parents: 118
diff changeset
  1761
	(nextLineNr > list size) ifFalse:[
156
claus
parents: 155
diff changeset
  1762
	    (leftPart := self listAt:lineNr) isNil ifTrue:[
121
claus
parents: 118
diff changeset
  1763
		leftPart := ''
claus
parents: 118
diff changeset
  1764
	    ].
156
claus
parents: 155
diff changeset
  1765
	    (rightPart := self listAt:nextLineNr) isNil ifTrue:[
121
claus
parents: 118
diff changeset
  1766
		rightPart := ''
claus
parents: 118
diff changeset
  1767
	    ].
claus
parents: 118
diff changeset
  1768
	    bothParts := leftPart , rightPart.
claus
parents: 118
diff changeset
  1769
	    bothParts isBlank ifTrue:[bothParts := nil].
claus
parents: 118
diff changeset
  1770
	    list at:lineNr put:bothParts.
claus
parents: 118
diff changeset
  1771
	    self redrawLine:lineNr.
claus
parents: 118
diff changeset
  1772
	    self deleteLine:nextLineNr
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1773
	]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1774
    ]
156
claus
parents: 155
diff changeset
  1775
claus
parents: 155
diff changeset
  1776
    "Modified: 7.9.1995 / 15:56:17 / claus"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1777
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1778
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1779
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1780
    "remove all blank lines at end of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1781
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1782
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1783
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1784
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1785
    lastLine := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1786
    finished := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1787
    [finished] whileFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1788
	(lastLine <= 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1789
	    finished := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1790
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1791
	    line := list at:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1792
	    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1793
		line isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1794
		    list at:lastLine put:nil.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1795
		    line := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1796
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1797
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1798
	    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1799
		finished := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1800
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1801
		lastLine := lastLine - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1802
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1803
	]
118
claus
parents: 105
diff changeset
  1804
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1805
    (lastLine ~~ list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1806
	list grow:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1807
"/        self textChanged
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1808
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1809
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1810
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1811
replace:aCharacter atLine:lineNr col:colNr
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1812
    "replace a single character at lineNr/colNr"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1813
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1814
    |line lineSize newLine drawCharacterOnly|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1815
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1816
    self checkModificationsAllowed ifFalse:[ ^ self].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1817
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1818
    aCharacter == (Character cr) ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1819
        ^ self
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1820
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1821
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1822
    self checkForExistingLine:lineNr.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1823
    line := list at:lineNr.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1824
    lineSize := line size.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1825
    (aCharacter == Character space) ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1826
        (colNr > lineSize)  ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1827
            ^ self
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1828
        ]
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1829
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1830
    (lineSize == 0) ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1831
        newLine := aCharacter asString species new:colNr.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1832
    ] ifFalse: [
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1833
        (colNr > lineSize) ifTrue: [
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1834
            newLine := line species new:colNr.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1835
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1836
        ] ifFalse: [
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1837
            newLine := line copy.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1838
        ]
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1839
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1840
    newLine at:colNr put:aCharacter.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1841
    list at:lineNr put:newLine.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1842
    widthOfWidestLine notNil ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1843
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1844
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1845
    self textChanged.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1846
    shown ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1847
        self redrawLine:lineNr col:colNr
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1848
    ]
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1849
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1850
    "Created: 6.3.1996 / 12:29:20 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1851
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1852
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1853
replaceCharAtCursor:aCharacter
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1854
    "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
  1855
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1856
    |wasOn|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1857
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1858
    wasOn := self hideCursor.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1859
    aCharacter == (Character cr) ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1860
        self cursorReturn
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1861
    ] ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1862
        self replace:aCharacter atLine:cursorLine col:cursorCol.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1863
        self cursorRight.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1864
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1865
    self makeCursorVisibleAndShowCursor:wasOn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1866
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1867
    "Created: 6.3.1996 / 12:27:42 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1868
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1869
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1870
replaceSelectionBy:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1871
    "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
  1872
     leave cursor after insertion"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1873
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1874
    self replaceSelectionBy:something keepCursor:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1875
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1876
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1877
replaceSelectionBy:something keepCursor:keep
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1878
    "delete the selection (if any) and insert something, a character or string;
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1879
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1880
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1881
    |sel l c|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1882
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1883
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1884
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1885
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1886
    sel := self selection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1887
    sel notNil ifTrue:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1888
        lastString := sel.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1889
        self deleteSelection.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1890
        replacing := true.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1891
        lastReplacement := ''
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1892
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1893
    (something isMemberOf:Character) ifTrue:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1894
        lastReplacement notNil ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1895
            (lastReplacement endsWith:Character space) ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1896
                lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)".
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1897
                lastReplacement := lastReplacement copyWith:something.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1898
                lastReplacement := lastReplacement copyWith:Character space
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1899
            ] ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1900
                lastReplacement := lastReplacement copyWith:something.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1901
            ]
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1902
        ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1903
        insertMode ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1904
            self insertCharAtCursor:something
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1905
        ] ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1906
            self replaceCharAtCursor:something
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1907
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1908
    ] ifFalse:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1909
        lastReplacement := something.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1910
        insertMode ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1911
            self insertStringAtCursor:something
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1912
        ] ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1913
            self replaceStringAtCursor
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1914
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1915
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1916
    keep ifTrue:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1917
        self cursorLine:l col:c
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1918
    ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1919
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1920
    "Modified: 6.3.1996 / 12:26:31 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1921
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1922
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1923
splitLine:lineNr before:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1924
    "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
  1925
     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
  1926
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1927
    |line lineSize leftRest rightRest visLine w      
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1928
     srcY    "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1929
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1930
    list isNil ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1931
	lineNr > (list size) ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1932
	    (colNr == 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1933
		self insertLine:nil before:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1934
		^ self
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
	    line := list at:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1937
	    line isNil ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1938
		lineSize := line size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1939
		(colNr <= lineSize) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1940
		    rightRest := line copyFrom:colNr to:lineSize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1941
		    (colNr > 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1942
			leftRest := line copyTo:(colNr - 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1943
		    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1944
		] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1945
		    leftRest := line
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1946
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1947
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1948
	    leftRest notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1949
		leftRest isBlank ifTrue:[leftRest := nil]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1950
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1951
	    list at:lineNr put:leftRest.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1952
	    self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1953
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1954
	    visLine := self listLineToVisibleLine:(lineNr).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1955
	    visLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1956
		w := self widthForScrollBetween:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1957
					    and:(firstLineShown + nLinesShown).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1958
		srcY := topMargin + (visLine * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1959
		self catchExpose.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1960
		self copyFrom:self x:textStartLeft y:srcY
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1961
				 toX:textStartLeft y:(srcY + fontHeight)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1962
			       width:w
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1963
			      height:((nLinesShown - visLine - 1) * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1964
		self redrawLine:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1965
		self redrawLine:(lineNr + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1966
		self waitForExpose
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1967
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1968
	    widthOfWidestLine := nil. "/ unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1969
	    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1970
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1971
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1972
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1973
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1974
withoutRedrawInsertLine:aString before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1975
    "insert the argument, aString before line lineNr; the string
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1976
     becomes line nileNr; everything else is moved down; the view
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1977
     is not redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1978
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1979
    |line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1980
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1981
    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
  1982
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1983
    line := aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1984
    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1985
	line isString ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1986
	    line isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1987
		line := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1988
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1989
		(line occurrencesOf:(Character tab)) == 0 ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1990
		    line := self withTabsExpanded:line
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1991
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1992
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1993
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1994
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1995
    list isNil ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1996
	list := StringCollection new:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1997
    ] ifFalse: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1998
	list grow:((list size + 1) max:lineNr)
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2001
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2002
     overlapping copy - if it didn't, we had to use:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2003
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2004
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2005
    [index > lineNr] whileTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2006
	pIndex := index - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2007
	list at:index put:(list at:pIndex).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2008
	index := pIndex
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2009
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2010
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2011
    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
  2012
    list at:lineNr put:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2013
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2014
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2015
withoutRedrawInsertLines:lines from:start to:end before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2016
    "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
  2017
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2018
    |newLine newLines nLines|
121
claus
parents: 118
diff changeset
  2019
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2020
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2021
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2022
    nLines := end - start + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2023
    newLines := Array new:(lines size).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2024
    start to:end do:[:index |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2025
	newLine := lines at:index.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2026
	newLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2027
	    newLine isString ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2028
		newLine isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2029
		    newLine := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2030
		] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2031
		    (newLine occurrencesOf:(Character tab)) == 0 ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2032
			newLine := self withTabsExpanded:newLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2033
		    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2034
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2035
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2036
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2037
	newLines at:index put:newLine
121
claus
parents: 118
diff changeset
  2038
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2039
    list isNil ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2040
	list := StringCollection new:(lineNr + nLines + 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2041
    ] ifFalse: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2042
	list grow:((list size + nLines) max:(lineNr + nLines - 1))
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2043
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2044
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2045
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2046
     overlapping copy - if it didn't, we had to use:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2047
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2048
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2049
    [index > lineNr] whileTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2050
	pIndex := index - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2051
	list at:index put:(list at:pIndex).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2052
	index := pIndex
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2053
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2054
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2055
    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
  2056
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
121
claus
parents: 118
diff changeset
  2057
!
claus
parents: 118
diff changeset
  2058
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2059
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2060
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2061
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2062
    |strLen line lineSize newLine stringType|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2063
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2064
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2065
    aString isNil ifTrue:[^ self].
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2066
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2067
    strLen := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2068
    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
  2069
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2070
    stringType := aString species.
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2071
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2072
    line := list at:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2073
    line notNil ifTrue:[
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2074
        lineSize := line size.
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2075
        line bitsPerCharacter > aString bitsPerCharacter ifTrue:[
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2076
            stringType := line species
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2077
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2078
    ] ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2079
        lineSize := 0
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2080
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2081
    ((colNr == 1) and:[lineSize == 0]) ifTrue: [
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2082
        newLine := aString
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2083
    ] ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2084
        (lineSize == 0) ifTrue: [
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2085
            newLine := stringType new:(colNr + strLen - 1)
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2086
        ] ifFalse: [
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2087
            (colNr > lineSize) ifTrue: [
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2088
                newLine := stringType new:(colNr + strLen - 1).
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2089
                newLine replaceFrom:1 to:lineSize
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2090
                               with:line startingAt:1
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2091
            ] ifFalse: [
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2092
                newLine := stringType new:(lineSize + strLen).
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2093
                newLine replaceFrom:1 to:(colNr - 1)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2094
                               with:line startingAt:1.
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2095
                newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2096
                               with:line startingAt:colNr
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2097
            ]
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2098
        ].
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2099
        newLine replaceFrom:colNr to:(colNr + strLen - 1)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2100
                       with:aString startingAt:1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2101
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2102
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2103
    (aString occurrencesOf:(Character tab)) == 0 ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2104
        newLine := self withTabsExpanded:newLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2105
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2106
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2107
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2108
    widthOfWidestLine notNil ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2109
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2110
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2111
    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
  2112
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2113
    "Modified: 26.2.1996 / 18:07:34 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2114
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2115
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2116
!EditTextView methodsFor:'event processing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2117
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2118
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2119
    "hide the cursor when button is activated"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2120
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2121
    hasKeyboardFocus := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2122
    cursorShown ifTrue: [self drawCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2123
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2124
    ((button == 1) or:[button == #select]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2125
	self hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2126
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2127
    (button == #paste) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2128
	self pasteOrReplace.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2129
	^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2130
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2131
    super buttonPress:button x:x y:y
121
claus
parents: 118
diff changeset
  2132
!
claus
parents: 118
diff changeset
  2133
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2134
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2135
    "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
  2136
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2137
    ((button == 1) or:[button == #select]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2138
	typeOfSelection := nil. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2139
	selectionStartLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2140
	    clickCol notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2141
		self cursorLine:clickLine col:clickCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2142
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2143
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2144
	    lastString := nil. "new selection invalidates remembered string"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2145
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2146
	self showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2147
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2148
    super buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2149
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2150
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2151
hasKeyboardFocus:aBoolean
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2152
    "sent by a delegate to make me show a block cursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2153
     (otherwise, I would not know about this)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2154
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2155
    hasKeyboardFocus := aBoolean.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2156
    cursorShown ifTrue: [self drawCursor].
121
claus
parents: 118
diff changeset
  2157
!
claus
parents: 118
diff changeset
  2158
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2159
keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2160
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2161
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2162
    <resource: #keyboard (#Paste #Insert #Cut #Again #Replace 
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2163
                          #SelectWord #SearchMatchingParent
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2164
                          #SelectMatchingParents #SelectToEnd
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2165
                          #SelectFromBeginning
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2166
                          #BeginOfLine #EndOfLine #NextWord
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2167
                          #GotoLine #Delete #BeginOfText #EndOfText
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2168
                          #SelectLine #ExpandSelectionByLine #DeleteLine
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2169
                          #InsertLine)>
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2170
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2171
    |sensor n fKeyMacros shifted i|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2172
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2173
    sensor := self sensor.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2174
    shifted := sensor shiftDown.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2175
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2176
    (key isMemberOf:Character) ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2177
        readOnly ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2178
            typeOfSelection == #paste ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2179
                "pasted selection will NOT be replaced by keystroke"
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2180
                self unselect
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2181
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2182
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2183
            "replace selection by what is typed in -
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2184
             if word was selected with a space, keep it"
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2185
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2186
            (selectStyle == #wordLeft) ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2187
                self replaceSelectionBy:(' ' copyWith:key)
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2188
            ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2189
                (selectStyle == #wordRight) ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2190
                    self replaceSelectionBy:(key asString , ' ').
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2191
                    self cursorLeft
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2192
                ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2193
                    self replaceSelectionBy:key
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2194
                ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2195
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2196
            selectStyle := nil.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2197
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2198
            showMatchingParenthesis ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2199
                "emacs style parenthesis shower"
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2200
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2201
                "claus: only do it for closing parenthesis -
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2202
                        otherwise its too anoying.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2203
                "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2204
"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2205
                (#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2206
"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2207
                (#( $) $] $} ) includes:key) ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2208
                self searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1)
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2209
                                   ifFound:[:line :col |
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2210
                                                |savLine savCol|
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2211
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2212
                                                self withCursor:Cursor eye do:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2213
                                                    savLine := cursorLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2214
                                                    savCol := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2215
                                                    self cursorLine:line col:col.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2216
                                                    device flush.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2217
                                                    Processor activeProcess millisecondDelay:200.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2218
                                                    self cursorLine:savLine col:savCol
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2219
                                                ]
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2220
                                           ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2221
                                ifNotFound:[self showNotFound]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2222
                                   onError:[device beep]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2223
                ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2224
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2225
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2226
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2227
    ].                         
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2228
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2229
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2230
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2231
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2232
     Fn      pastes a key-sequence (but only if not overlayed with
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2233
             another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2234
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2235
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2236
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2237
    (('[fF][0-9]' match:key)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2238
    or:['[fF][0-9][0-9]' match:key]) ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2239
        shifted ifFalse:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2240
            fKeyMacros := Smalltalk at:#FunctionKeySequences.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2241
            fKeyMacros 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
  2242
                (fKeyMacros includesKey:key) ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2243
                    self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2244
                    ^ self
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2245
                ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2246
            ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2247
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2248
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2249
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  2250
    (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
  2251
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2252
    ((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2253
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2254
    (key == #Again) ifTrue:[self again. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2255
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2256
    (key == #Replace) ifTrue:[self replace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2257
    (key == #SelectWord) ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2258
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2259
        ^ self selectWordUnderCursor. 
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2260
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2261
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2262
    (key == #SearchMatchingParent) ifTrue:[^ self searchForMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2263
    (key == #SelectMatchingParents) ifTrue:[^ self searchForAndSelectMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2264
    (key == #SelectToEnd) ifTrue:[^ self selectUpToEnd.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2265
    (key == #SelectFromBeginning) ifTrue:[^ self selectFromBeginning.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2266
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2267
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2268
  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
  2269
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2270
    (key == #Ctrlb) ifTrue:[self unselect. self cursorLeft. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2271
    (key == #Ctrlf) ifTrue:[self unselect. self cursorRight. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2272
    (key == #Ctrln) ifTrue:[self unselect. self cursorDown. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2273
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2274
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2275
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2276
    (key == #BeginOfLine) ifTrue:[self cursorToBeginOfLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2277
    (key == #EndOfLine) ifTrue:[self cursorToEndOfLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2278
    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2279
    (key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2280
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2281
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2282
    (key == #CursorRight) ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2283
        (shifted and:[selectionStartLine isNil]) ifTrue:[
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2284
            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2285
            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2286
            expandingTop := false.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2287
            ^ self redrawLine:selectionStartLine. 
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2288
        ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2289
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2290
        selectionStartLine notNil ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2291
            "/
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2292
            "/ treat the whole selection as cursor
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2293
            "/
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2294
            cursorLine := selectionEndLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2295
            cursorVisibleLine := self listLineToVisibleLine:cursorLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2296
            cursorCol := selectionEndCol.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2297
            cursorCol == 0 ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2298
                cursorCol := 1.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2299
            ].
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2300
            shifted ifTrue:[
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2301
                self expandSelectionRight.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2302
                ^ self
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2303
            ].
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2304
            self unselect; makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2305
            cursorCol == 1 ifTrue:[^ self].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2306
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2307
        self cursorRight. ^self
121
claus
parents: 118
diff changeset
  2308
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2309
    (key == #CursorDown) ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2310
        (shifted and:[selectionStartLine isNil]) ifTrue:[
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2311
            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2312
            selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2313
            self redrawLine:selectionStartLine. 
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2314
            expandingTop := false.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2315
            ^ self redrawLine:selectionEndLine. 
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2316
        ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2317
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2318
        selectionStartLine notNil ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2319
            "/
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2320
            "/ treat the whole selection as cursor
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2321
            "/
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2322
            cursorLine := selectionEndLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2323
            cursorVisibleLine := self listLineToVisibleLine:cursorLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2324
            cursorCol := selectionEndCol.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2325
            cursorCol == 0 ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2326
                cursorCol := 1.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2327
                cursorLine := cursorLine - 1.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2328
                cursorVisibleLine := self listLineToVisibleLine:cursorLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2329
            ].
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2330
            self makeCursorVisible.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2331
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2332
            shifted ifTrue:[
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2333
                self expandSelectionDown.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2334
                ^ self
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2335
            ].
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  2336
            self unselect. 
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2337
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2338
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2339
        sensor isNil ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2340
            n := 1
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2341
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2342
            n := 1 + (sensor compressKeyPressEventsWithKey:#CursorDown).
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2343
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2344
        self cursorDown:n. 
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2345
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2346
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2347
    (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2348
        (shifted and:[selectionStartLine isNil]) ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2349
            expandingTop := true.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2350
            key == #CursorLeft ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2351
                cursorCol > 1 ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2352
                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2353
                    selectionEndCol := clickStartCol := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2354
                    selectionStartCol := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2355
                    ^ self redrawLine:selectionStartLine. 
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2356
                ]
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2357
            ] ifFalse:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2358
                cursorLine > 1 ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2359
                    selectionEndLine := clickStartLine := cursorLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2360
                    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2361
                    selectionStartLine := cursorLine - 1.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2362
                    ^ self redrawFromLine:selectionStartLine to:cursorLine. 
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2363
                ]
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2364
            ]
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2365
        ].
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2366
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2367
        selectionStartLine notNil ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2368
            "/
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2369
            "/ treat the whole selection as cursor
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2370
            "/
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2371
            cursorLine := selectionStartLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2372
            cursorVisibleLine := self listLineToVisibleLine:cursorLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2373
            cursorCol := selectionStartCol.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2374
            self makeCursorVisible.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2375
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2376
            shifted ifTrue:[
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2377
                (key == #CursorUp) ifTrue:[
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2378
                    ^ self expandSelectionUp.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2379
                ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2380
                ^ self expandSelectionLeft.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2381
            ].
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  2382
            self unselect. 
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2383
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2384
        (key == #CursorLeft) ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2385
            self cursorLeft. ^self
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2386
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2387
        (key == #CursorUp)        ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2388
            sensor isNil ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2389
                n := 1
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2390
            ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2391
                n := 1 + (sensor compressKeyPressEventsWithKey:#CursorUp).
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2392
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2393
            self cursorUp:n. 
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2394
            ^ self
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2395
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2396
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2397
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2398
    (key == #Return)    ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2399
        shifted ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2400
            self unselect. self cursorReturn. ^self
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2401
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2402
        readOnly ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2403
            self unselect; makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2404
            self cursorReturn
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2405
        ] ifFalse:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2406
            insertMode ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2407
                self cursorReturn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2408
                autoIndent == true ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2409
                    i := self leftIndentOfLine:cursorLine.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2410
                    i == 0 ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2411
                        i := self leftIndentForLine:cursorLine.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2412
                    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2413
                    self cursorCol:(i+1 max:1)
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2414
                ]
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2415
            ] ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2416
                "/ old version just unselected ...
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2417
                "/ self unselect; makeCursorVisible.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2418
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2419
                "/ new version deletes ...
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2420
                typeOfSelection == #paste ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2421
                    self unselect; makeCursorVisible.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2422
                ] ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2423
                    self copyAndDeleteSelection.            
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2424
                ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2425
                self insertCharAtCursor:(Character cr). 
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2426
                autoIndent == true ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2427
                    i := self leftIndentForLine:cursorLine.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2428
                    self indentFromLine:cursorLine toLine:cursorLine.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2429
                    self cursorCol:(i+1 max:1)
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2430
                ].
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2431
            ].
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2432
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2433
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2434
    ].
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
  2435
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2436
    (key == #Tab) ifTrue:[
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2437
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2438
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2439
        shifted ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2440
            "
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2441
             the old version used shift-tab as backtab,
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2442
             however, backtab was seldom used.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2443
             An alternative is to make it a non-inserting tab ...
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2444
            "
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2445
            "/ self unselect. self cursorBacktab.
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2446
            self unselect. self cursorTab. 
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2447
            ^self
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2448
        ].
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2449
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2450
        "
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2451
         uncomment line below, if you like RAND/INed/MAXed editor behavior
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2452
         (where tab-key is only cursor positioning)
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2453
         this was the original behavior of the TAB key, but many people
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2454
         complained ....
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2455
        "
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2456
        "/ self unselect. self cursorTab. ^self
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2457
        self unselect. self insertTabAtCursor. 
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2458
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2459
    ].
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
  2460
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2461
    (key == #BackSpace) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2462
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2463
        "/ old version just unselected here 
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2464
        "/ self unselect. 
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2465
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2466
        "/ new version deletes selection if any 
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2467
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2468
        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
  2469
            ^ self copyAndDeleteSelection.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2470
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2471
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2472
        self deleteCharBeforeCursor. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2473
    ].
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
  2474
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2475
    (key == #Delete)    ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2476
        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
  2477
            ^ self copyAndDeleteSelection.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2478
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2479
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2480
        self deleteCharAtCursor. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2481
    ].
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
  2482
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2483
    (key == #BeginOfText) ifTrue:[     "i.e. HOME"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2484
        self unselect. 
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2485
        cursorVisibleLine == 1 ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2486
            self cursorHome.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2487
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2488
            self cursorToFirstVisibleLine
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2489
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2490
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2491
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2492
    (key == #EndOfText) ifTrue:[       "i.e. END"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2493
        self unselect.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2494
        cursorVisibleLine == nFullLinesShown ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2495
            self cursorToBottom.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2496
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2497
            self cursorToLastVisibleLine
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2498
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2499
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2500
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2501
    ((key == #Escape)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2502
    or:[key == #SelectLineFromBeginning])    ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2503
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2504
        self unselect. self selectCursorLineFromBeginning. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2505
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2506
    (key == #SelectLine)    ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2507
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2508
        self unselect. self selectCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2509
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2510
    (key == #ExpandSelectionByLine)    ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2511
"/        self makeCursorVisible.
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2512
        self selectExpandCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2513
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2514
    (key == #DeleteLine)    ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2515
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2516
        self unselect. self deleteCursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2517
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2518
    (key == #InsertLine)    ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2519
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2520
        self unselect. self insertLine:nil before:cursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2521
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2522
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2523
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  2524
    "Modified: 18.3.1996 / 17:07:30 / cg"
121
claus
parents: 118
diff changeset
  2525
!
claus
parents: 118
diff changeset
  2526
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2527
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2528
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2529
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2530
    super mapped.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2531
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2532
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2533
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2534
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2535
pointerEnter:state x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2536
    (windowGroup isNil or:[windowGroup focusView isNil]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2537
	hasKeyboardFocus := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2538
	cursorShown ifTrue: [self drawCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2539
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2540
    super pointerEnter:state x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2541
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2542
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2543
pointerLeave:state
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2544
    (windowGroup isNil or:[windowGroup focusView isNil]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2545
	hasKeyboardFocus := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2546
	cursorShown ifTrue: [self drawCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2547
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2548
    super pointerLeave:state
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2549
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2550
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
  2551
showFocus:explicit
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2552
    hasKeyboardFocus := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2553
    cursorShown ifTrue: [self drawCursor].
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
  2554
    super showFocus:explicit
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2555
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2556
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
  2557
showNoFocus:explicit
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2558
    hasKeyboardFocus := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2559
    cursorShown ifTrue: [self drawCursor].
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
  2560
    super showNoFocus:explicit
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2561
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2562
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2563
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2564
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2565
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2566
    |cv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2567
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2568
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2569
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2570
    cv notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2571
	self makeLineVisible:cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2572
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2573
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2574
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2575
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2576
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2577
indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2578
    "indent selected line-range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2579
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2580
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2581
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2582
    selectionStartLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2583
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2584
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2585
    (selectionEndCol == 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2586
	end := end - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2587
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2588
    self unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2589
    self indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2590
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2591
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2592
indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2593
    "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
  2594
     last non-empty line before start, and change the indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2595
     of the line based on that indent."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2596
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2597
    |leftStart delta d line spaces|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2598
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2599
    leftStart := self leftIndentForLine:start.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2600
    (leftStart == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2601
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2602
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2603
    (delta == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2604
    (delta > 0) ifTrue:[
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2605
        spaces := String new:delta
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2606
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2607
    start to:end do:[:lineNr |
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2608
        line := self listAt:lineNr.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2609
        line notNil ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2610
            line isBlank ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2611
                list at:lineNr put:nil
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2612
            ] ifFalse:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2613
                (delta > 0) ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2614
                    line := spaces , line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2615
                    widthOfWidestLine notNil ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2616
                        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2617
                    ]
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2618
                ] ifFalse:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2619
                    "check if deletion is ok"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2620
                    d := delta negated + 1.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2621
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2622
                    line size > d ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2623
                        (line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2624
                            line := line copyFrom:d
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2625
                        ]
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2626
                    ].
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2627
                    widthOfWidestLine := nil
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2628
                ].
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2629
                list at:lineNr put:line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2630
                self textChanged.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2631
            ]
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2632
        ]
121
claus
parents: 118
diff changeset
  2633
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2634
    self redrawFromLine:start to:end
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2635
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2636
    "Modified: 5.3.1996 / 14:59:18 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2637
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2638
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2639
leftIndentForLine:lineNr
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2640
    "find an appropriate indent for a line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2641
     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
  2642
     and returning its indent."
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2643
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2644
    |leftStart lnr|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2645
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2646
    leftStart := 0.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2647
    lnr := lineNr.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2648
    [(leftStart == 0) and:[lnr ~~ 1]] whileTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2649
        lnr := lnr - 1.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2650
        leftStart := self leftIndentOfLine:lnr
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2651
    ].
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2652
    ^ leftStart
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2653
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2654
    "Created: 5.3.1996 / 14:58:53 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2655
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2656
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2657
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2658
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2659
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2660
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2661
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2662
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2663
    self enableEnterLeaveEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2664
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2665
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2666
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2667
    "initialize style specific stuff"
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
    super initStyle.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2670
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2671
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2672
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2673
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2674
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2675
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2676
    cursorType := DefaultCursorType.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2677
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2678
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2679
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2680
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2681
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2682
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2683
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2684
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2685
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2686
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2687
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2688
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2689
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2690
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2691
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2692
    cursorCol := 1.
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2693
    modifiedChannel := false asValue.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2694
    showMatchingParenthesis := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2695
    hasKeyboardFocus := false. "/ true.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  2696
    tabMeansNextField := false.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2697
    autoIndent := false.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2698
    insertMode := true.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2699
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2700
    "Modified: 6.3.1996 / 12:23:50 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2701
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2702
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2703
realize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2704
    "make the view visible"
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
    super realize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2707
    cursorFgColor := cursorFgColor on:device.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2708
    cursorBgColor := cursorBgColor on:device.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2709
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2710
121
claus
parents: 118
diff changeset
  2711
!EditTextView methodsFor:'menu actions'!
claus
parents: 118
diff changeset
  2712
claus
parents: 118
diff changeset
  2713
cut
claus
parents: 118
diff changeset
  2714
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  2715
claus
parents: 118
diff changeset
  2716
    |line col history sel|
claus
parents: 118
diff changeset
  2717
claus
parents: 118
diff changeset
  2718
    sel := self selection.
claus
parents: 118
diff changeset
  2719
    sel notNil ifTrue:[
claus
parents: 118
diff changeset
  2720
	lastString := sel.
claus
parents: 118
diff changeset
  2721
	line := selectionStartLine.
claus
parents: 118
diff changeset
  2722
	col := selectionStartCol.
claus
parents: 118
diff changeset
  2723
	undoAction := [self insertLines:lastString atLine:line col:col].
claus
parents: 118
diff changeset
  2724
claus
parents: 118
diff changeset
  2725
	"
claus
parents: 118
diff changeset
  2726
	 remember in CopyBuffer
claus
parents: 118
diff changeset
  2727
	"
claus
parents: 118
diff changeset
  2728
	self setTextSelection:lastString.
claus
parents: 118
diff changeset
  2729
claus
parents: 118
diff changeset
  2730
	"
claus
parents: 118
diff changeset
  2731
	 append to DeleteHistory (if there is one)
claus
parents: 118
diff changeset
  2732
	"
claus
parents: 118
diff changeset
  2733
	history := Smalltalk at:#DeleteHistory.
claus
parents: 118
diff changeset
  2734
	history notNil ifTrue:[
claus
parents: 118
diff changeset
  2735
	    history addAll:(lastString asStringCollection).
claus
parents: 118
diff changeset
  2736
	    history size > 1000 ifTrue:[
claus
parents: 118
diff changeset
  2737
		history := history copyFrom:(history size - 1000)
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
  2738
	    ].
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
  2739
	].
121
claus
parents: 118
diff changeset
  2740
claus
parents: 118
diff changeset
  2741
	"
claus
parents: 118
diff changeset
  2742
	 now, delete it
claus
parents: 118
diff changeset
  2743
	"
claus
parents: 118
diff changeset
  2744
	self deleteSelection.
claus
parents: 118
diff changeset
  2745
	lastReplacement := nil
claus
parents: 118
diff changeset
  2746
    ] ifFalse:[
claus
parents: 118
diff changeset
  2747
	"
claus
parents: 118
diff changeset
  2748
	 a cut without selection will search&cut again
claus
parents: 118
diff changeset
  2749
	"
claus
parents: 118
diff changeset
  2750
	self again
claus
parents: 118
diff changeset
  2751
    ]
claus
parents: 118
diff changeset
  2752
!
claus
parents: 118
diff changeset
  2753
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2754
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2755
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2756
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2757
    cursorLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2758
	^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2759
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2760
    ^ super defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2761
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2762
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2763
editMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2764
    "return the views middleButtonMenu"
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2765
488
d10fe3a5f0cf resources
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
  2766
    <resource: #keyboard (#Again #Copy #Cut #Paste #Accept #Find #GotoLine #SaveAs #Print)>
d10fe3a5f0cf resources
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
  2767
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2768
    |labels selectors m sub shortKeys|
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2769
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2770
    self sensor ctrlDown ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2771
        labels := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2772
                        'again (for all)'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2773
                   ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2774
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2775
        selectors := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2776
                        multipleAgain
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2777
                       ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2778
    ] ifFalse:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2779
        labels := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2780
"/                      'undo'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2781
                        'again'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2782
                        '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2783
                        'copy'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2784
                        'cut'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2785
                        'paste'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2786
                        '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2787
                        'accept'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2788
                        '='
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2789
                        'others'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2790
                   ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2791
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2792
        selectors := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2793
"/                      undo
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2794
                        again
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2795
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2796
                        copySelection
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2797
                        cut
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2798
                        pasteOrReplace
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2799
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2800
                        accept
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2801
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2802
                        others
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2803
                       ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2804
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2805
        shortKeys := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2806
"/                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2807
                        #Again 
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2808
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2809
                        #Copy
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2810
                        #Cut
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2811
                        #Paste
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2812
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2813
                        #Accept 
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2814
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2815
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2816
                      ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2817
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2818
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2819
    m := PopUpMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2820
            labels:(resources array:labels)
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2821
            selectors:selectors
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2822
            accelerators:shortKeys.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2823
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2824
    labels := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2825
                    'search ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2826
                    'goto ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2827
                    '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2828
                    'font ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2829
                    '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2830
                    'indent'
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2831
                    'autoIndent \c'
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2832
                    'insertMode \c'
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2833
                    '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2834
                    'save as ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2835
                    'print'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2836
                ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2837
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2838
   selectors := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2839
                     search
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2840
                     gotoLine
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2841
                     nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2842
                     changeFont
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2843
                     nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2844
                     indent
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2845
                     autoIndent:
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2846
                     insertMode:
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2847
                     nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2848
                     save
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2849
                     print
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2850
                    ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2851
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2852
    shortKeys := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2853
                      #Find
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2854
                      #GotoLine
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2855
                      nil
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2856
                      nil         "/ changeFont
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2857
                      nil
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2858
                      nil         "/ indent
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2859
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2860
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2861
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2862
                      #SaveAs
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2863
                      #Print).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2864
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2865
    sub := PopUpMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2866
                labels:(resources array:labels)
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2867
                selectors:selectors
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2868
                accelerators:shortKeys
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2869
                receiver:model.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2870
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2871
    m subMenuAt:#others put:sub.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2872
    sub checkToggleAt:#autoIndent: put:autoIndent.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2873
    sub checkToggleAt:#insertMode: put:insertMode.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2874
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2875
    readOnly ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2876
        m disable:#paste
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2877
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2878
    self hasSelection not ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2879
        m disable:#copySelection.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2880
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2881
    (self hasSelection not or:[readOnly]) ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2882
        m disable:#cut.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2883
        sub disable:#indent.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2884
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2885
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2886
488
d10fe3a5f0cf resources
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
  2887
    "Modified: 7.3.1996 / 13:13:03 / cg"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2888
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2889
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2890
paste
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2891
    "paste copybuffer; if there is a selection, unselect first.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2892
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2893
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2894
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2895
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2896
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2897
    self unselect.  
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2898
    sel notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2899
	self paste:sel.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2900
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2901
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2902
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2903
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2904
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2905
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2906
    |s startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2907
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2908
    someText notNil ifTrue:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2909
        s := someText.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2910
        s isString ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2911
            s := s asStringCollection
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2912
        ] ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2913
            (s isKindOf:StringCollection) ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2914
                self warn:'selection not convertable to Text'.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2915
                ^ self
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2916
            ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2917
        ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2918
        startLine := cursorLine.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2919
        startCol := cursorCol.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2920
        self insertLines:(s withTabsExpanded) withCr:false.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2921
        self selectFromLine:startLine col:startCol
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2922
                     toLine:cursorLine col:(cursorCol - 1).
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2923
        typeOfSelection := #paste.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2924
        undoAction := [self cut].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2925
    ]
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2926
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2927
    "Modified: 14.2.1996 / 11:14:14 / stefan"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2928
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2929
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2930
pasteOrReplace
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2931
    "paste copybuffer; if there is a selection, replace it.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2932
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2933
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2934
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2935
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2936
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2937
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2938
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2939
    self pasteOrReplace:sel.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2940
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2941
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2942
pasteOrReplace:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2943
    "paste copybuffer; if there is a selection, replace it.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2944
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2945
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2946
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2947
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2948
    ((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2949
	^ self replace:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2950
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2951
    self paste:someText.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2952
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2953
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2954
replace
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2955
    "replace selection by copybuffer"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2956
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2957
    |sel|
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
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2960
    sel notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2961
	self replace:sel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2962
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2963
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2964
121
claus
parents: 118
diff changeset
  2965
replace:someText
claus
parents: 118
diff changeset
  2966
    "replace selection by someText"
claus
parents: 118
diff changeset
  2967
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2968
    |selected selectedString| 
121
claus
parents: 118
diff changeset
  2969
claus
parents: 118
diff changeset
  2970
    selected := self selection.
claus
parents: 118
diff changeset
  2971
    selected isNil ifTrue:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2972
        ^ self paste:someText
121
claus
parents: 118
diff changeset
  2973
    ].
claus
parents: 118
diff changeset
  2974
    self deleteSelection.
claus
parents: 118
diff changeset
  2975
claus
parents: 118
diff changeset
  2976
    "take care, if we replace a selection without space by a word selected
claus
parents: 118
diff changeset
  2977
     with one - in this case we usually do not want the space.
claus
parents: 118
diff changeset
  2978
     But, if we replace a word-selected selection by something without a
claus
parents: 118
diff changeset
  2979
     space, we DO want the space added."
claus
parents: 118
diff changeset
  2980
claus
parents: 118
diff changeset
  2981
    selected size == 1 ifTrue:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2982
        selectedString := selected at:1.
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  2983
    ].
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  2984
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2985
    someText size == 1 ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2986
        |cutOffSpace addSpace replacement replacementString|
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2987
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2988
        cutOffSpace := false.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2989
        addSpace := false.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2990
        replacement := someText copy.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2991
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2992
        selectedString notNil ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2993
            ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2994
               "selection has no space"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2995
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2996
                ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2997
                    cutOffSpace := true
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2998
                ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2999
            ] ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3000
                addSpace := true
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3001
            ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3002
        ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3003
        replacementString := replacement at:1.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3004
        cutOffSpace ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3005
            (replacementString startsWith:' ') ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3006
                replacementString := replacementString withoutSpaces
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3007
            ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3008
        ] ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3009
            selectStyle == #wordLeft ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3010
                "want a space at left"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3011
                (replacementString startsWith:' ') ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3012
                    replacementString := replacementString withoutSpaces.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3013
                    replacementString := ' ' , replacementString
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3014
                ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3015
            ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3016
            selectStyle == #wordRight ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3017
                "want a space at right"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3018
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3019
                (replacementString endsWith:' ') ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3020
                    replacementString := replacementString withoutSpaces.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3021
                    replacementString := replacementString , ' '
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3022
                ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3023
            ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3024
        ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3025
        replacement at:1 put: replacementString.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3026
        self paste:replacement.
121
claus
parents: 118
diff changeset
  3027
    ] ifFalse:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3028
        self paste:someText
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  3029
    ].
121
claus
parents: 118
diff changeset
  3030
    lastString := selectedString.
claus
parents: 118
diff changeset
  3031
    lastReplacement := someText
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3032
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3033
    "Modified: 14.2.1996 / 10:37:02 / stefan"
121
claus
parents: 118
diff changeset
  3034
!
claus
parents: 118
diff changeset
  3035
claus
parents: 118
diff changeset
  3036
showDeleted
claus
parents: 118
diff changeset
  3037
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  3038
claus
parents: 118
diff changeset
  3039
    |v|
claus
parents: 118
diff changeset
  3040
claus
parents: 118
diff changeset
  3041
    v := EditTextView openWith:(Smalltalk at:#DeleteHistory).
claus
parents: 118
diff changeset
  3042
    v readOnly.
claus
parents: 118
diff changeset
  3043
    v topView label:'deleted text'.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3044
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3045
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3046
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3047
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3048
checkModificationsAllowed
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3049
    readOnly ifTrue: [
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3050
	exceptionBlock isNil ifTrue:[
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3051
	    ^ false
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3052
	].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3053
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3054
	(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3055
	    ^ false
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3056
	]
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3057
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3058
    ^ true
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3059
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3060
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3061
textChanged
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3062
    "triggered whenever text has been edited (not to confuse with
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3063
     contentsChanged, which is triggered when the size has changed, and
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3064
     is used to notify scrollers, other views etc.)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3065
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3066
    super contentsChanged.
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3067
    modifiedChannel value:true.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3068
    contentsWasSaved := false
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3069
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3070
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3071
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3072
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  3073
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3074
    "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
  3075
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3076
    "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
  3077
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3078
    ^ readOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  3079
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  3080
    "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
  3081
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3082
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3083
widthOfContents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3084
    "return the width of the contents in pixels
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3085
     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
  3086
     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
  3087
     line (and possibly see the cursor behind the line)"
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
    |w|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3090
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3091
    w := super widthOfContents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3092
    ^ w + (font widthOf:' ')
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3093
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3094
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3095
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3096
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3097
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3098
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3099
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3100
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3101
	cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3102
	    (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3103
		self drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3104
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3105
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3106
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3107
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3108
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3109
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3110
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3111
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3112
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3113
	(visLine == cursorVisibleLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3114
	    self drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3115
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3116
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3117
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3118
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3119
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3120
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3121
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3122
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3123
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3124
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3125
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3126
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3127
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3128
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3129
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3130
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3131
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3132
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3133
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3134
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3135
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3136
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3137
	(visLine == cursorVisibleLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3138
	    (colNr == cursorCol) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3139
		self drawCursorCharacter.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3140
		^ self
118
claus
parents: 105
diff changeset
  3141
	    ]
claus
parents: 105
diff changeset
  3142
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3143
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3144
    super redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3145
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3146
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3147
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3148
    "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
  3149
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3150
    super redrawVisibleLine:visLine from:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3151
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3152
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3153
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3154
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3155
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3156
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3157
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3158
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3159
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3160
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3161
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3162
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3163
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3164
    "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
  3165
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3166
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3167
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3168
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3169
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3170
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3171
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3172
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3173
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3174
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3175
    "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
  3176
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3177
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3178
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3179
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3180
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3181
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3182
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3183
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3184
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3185
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3186
    "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
  3187
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3188
    super originChanged:delta.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3189
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3190
     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
  3191
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3192
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3193
    prevCursorState ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3194
	self showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3195
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3196
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3197
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3198
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3199
    "sent before scrolling - have to hide the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3200
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3201
    prevCursorState := cursorShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3202
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3203
	self hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3204
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3205
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3206
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3207
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3208
    "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
  3209
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3210
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3211
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3212
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3213
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3214
    super pageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3215
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3216
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3217
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3218
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3219
    "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
  3220
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3221
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3222
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3223
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3224
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3225
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3226
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3227
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3228
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3229
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3230
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3231
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3232
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3233
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3234
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3235
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3236
    cursorLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3237
    selectionStartLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3238
	startLine := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3239
	startCol := selectionStartCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3240
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3241
	startLine := cursorLine min:list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3242
	startCol := cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3243
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3244
    self searchBackwardFor:pattern startingAtLine:startLine col:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3245
    ifFound:[:line :col |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3246
	self cursorLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3247
	self showMatch:pattern atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3248
"/        self makeLineVisible:cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3249
    ] ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3250
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3251
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3252
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3253
    "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
  3254
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3255
    self searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3256
			      ifFound:[:line :col | 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3257
					  self selectFromLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3258
						       toLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3259
				      ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3260
			   ifNotFound:[self showNotFound]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3261
			      onError:[device beep]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3262
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3263
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3264
searchForMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3265
    "search for a matching parenthesis starting at cursor position. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3266
     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
  3267
     backwards if its a closing parenthesis.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3268
     Positions the cursor if found, peeps if not"
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
     self searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3271
			       ifFound:[:line :col | self cursorLine:line col:col]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3272
			    ifNotFound:[self showNotFound]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3273
			       onError:[device beep]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3274
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3275
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3276
searchFwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3277
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3278
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3279
    |startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3280
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3281
    "/ 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
  3282
    "/ 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
  3283
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3284
    self hasSelection ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3285
	(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3286
	    startCol := 0
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3287
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3288
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3289
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3290
    self searchFwd:pattern startingAtLine:cursorLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3291
!
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
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3294
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3295
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3296
    cursorLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3297
    self searchForwardFor:pattern startingAtLine:startLine col:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3298
    ifFound:[:line :col |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3299
	self cursorLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3300
	self showMatch:pattern atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3301
"/        self makeLineVisible:cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3302
    ] ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3303
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3304
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3305
setSearchPattern
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3306
    "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
  3307
     cursor to start of pattern"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3308
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3309
    |sel|
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
    "if last operation was a replcae, set pattern to last
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3312
     original string (for search after again)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3313
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3314
    (lastString notNil and:[lastReplacement notNil]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3315
	searchPattern := lastString asString withoutSeparators.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3316
	^ self
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3319
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3320
    sel notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3321
	self cursorLine:selectionStartLine col:selectionStartCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3322
	searchPattern := sel asString withoutSeparators
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3323
    ]
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
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3327
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3328
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3329
    "select the whole text.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3330
     redefined to send super selectFrom... since we dont want the
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3331
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3332
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3333
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3334
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3335
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3336
	super selectFromLine:1 col:1 toLine:(list size + 1) col:0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3337
	typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3338
    ]
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3341
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3342
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3343
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3344
    self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3345
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3346
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3347
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3348
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3349
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3350
    self selectFromLine:cursorLine col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3351
		 toLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3352
!
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
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3355
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3356
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3357
    selectionStartLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3358
	self selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3359
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3360
	self selectFromLine:selectionStartLine col:selectionStartCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3361
		     toLine:cursorLine+1 col:0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3362
	self makeLineVisible:selectionEndLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3363
    ]
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3366
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3367
    "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
  3368
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3369
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3370
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3371
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3372
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3373
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3374
	cursorCol == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3375
	    col := 0
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3376
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3377
	    col := cursorCol - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3378
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3379
	super selectFromLine:1 col:1 toLine:cursorLine col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3380
	typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3381
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3382
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3383
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3384
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3385
    "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
  3386
     for easier editing. Also typeOfSelection is nilled here."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3387
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3388
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3389
    self cursorLine:selectionEndLine col:(selectionEndCol + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3390
    typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3391
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3392
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3393
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3394
    "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
  3395
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3396
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3397
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3398
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3399
	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
  3400
	typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3401
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3402
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3403
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3404
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3405
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3406
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3407
    self selectWordAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3408
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3409
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3410
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3411
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3412
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3413
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3414
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3415
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3416
    super unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3417
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3418
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3419
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3420
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3421
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3422
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3423
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3424
     If current selection is not last string, search forward to
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3425
     next occurence of it before repeating the last operation."
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3426
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3427
    |s l c sel savedSelectStyle|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3428
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3429
    lastString notNil ifTrue:[
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3430
        s := lastString asString.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3431
        "remove final cr"
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3432
        s := s copyWithoutLast:1 "copyTo:(s size - 1)".
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3433
        s := s withoutSpaces.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3434
        savedSelectStyle := selectStyle.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3435
        selectStyle := nil.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3436
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3437
        sel := self selection.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3438
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3439
        "if we are already there (after a find), ommit search"
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3440
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3441
        (sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3442
            undoAction := [self insertLines:lastString atLine:cursorLine col:cursorCol].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3443
            l := selectionStartLine "cursorLine". 
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3444
            c := selectionStartCol "cursorCol".
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3445
            self deleteSelection.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3446
            lastReplacement notNil ifTrue:[
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3447
                self insertLines:lastReplacement asStringCollection withCr:false.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3448
                self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3449
            ].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3450
            selectStyle := savedSelectStyle.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3451
            ^ true
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3452
        ].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3453
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3454
        self searchForwardFor:s startingAtLine:cursorLine col:cursorCol 
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3455
            ifFound:
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3456
                [
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3457
                    :line :col |
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3458
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3459
                    |repl|
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3460
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3461
                    self selectFromLine:line col:col
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3462
                                 toLine:line col:(col + s size - 1).
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3463
                    self makeLineVisible:line.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3464
                    undoAction := [self insertLines:lastString atLine:line col:col].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3465
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3466
                    self deleteSelection.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3467
                    lastReplacement notNil ifTrue:[
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3468
                        repl := lastReplacement withoutSpaces.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3469
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3470
                        self insertLines:repl asStringCollection withCr:false.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3471
                        self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3472
                    ].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3473
                    selectStyle := savedSelectStyle.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3474
                    ^ true
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3475
                ] 
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3476
           ifAbsent:
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3477
                [
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3478
                    self showNotFound.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3479
                    selectStyle := savedSelectStyle.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3480
                    ^ false
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3481
                ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3482
    ]
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3483
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  3484
    "Modified: 18.3.1996 / 14:48:27 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3485
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3486
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3487
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3488
    "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
  3489
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3490
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3491
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3492
121
claus
parents: 118
diff changeset
  3493
undo
claus
parents: 118
diff changeset
  3494
    "currently not implemented"
claus
parents: 118
diff changeset
  3495
claus
parents: 118
diff changeset
  3496
    undoAction notNil ifTrue:[
claus
parents: 118
diff changeset
  3497
	undoAction value
claus
parents: 118
diff changeset
  3498
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3499
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3500
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3501
!EditTextView class methodsFor:'documentation'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3502
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3503
version
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  3504
    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.60 1996-03-18 16:20:41 cg Exp $'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3505
! !