ETxtView.st
author Claus Gittinger <cg@exept.de>
Fri, 01 Mar 1996 19:44:55 +0100
changeset 447 ed41e1bbd9a1
parent 440 2beb33cb0146
child 458 14e994e20eb5
permissions -rw-r--r--
also support goto-default (use selection if any)
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
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    19
		tabMeansNextField'
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   320
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   321
    "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
   322
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   323
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   324
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   325
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   326
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   327
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   328
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   329
     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
   330
     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
   331
     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
   332
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   333
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   334
    tabMeansNextField := aBoolean
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   335
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   336
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   337
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   338
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   339
characterUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   340
    "return the character under the cursor - space if behond line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   341
     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
   342
     of the insertion-bar or caret."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   343
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   344
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   345
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   346
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   347
contents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   348
    "return the contents as a String"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   349
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   350
    list isNil ifTrue:[^ ''].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   351
    self removeTrailingBlankLines.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   352
    ^ list asStringWithCRs
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   353
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   354
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   355
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   356
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   357
     This is the absolute col; NOT the visible col"
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
    ^ cursorCol
125
claus
parents: 123
diff changeset
   360
!
claus
parents: 123
diff changeset
   361
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   362
cursorForegroundColor:color1 backgroundColor:color2
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   363
    "set both cursor foreground and cursor background colors"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   364
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   365
    |wasOn|
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
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   368
    cursorFgColor := color1 on:device.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   369
    cursorBgColor := color2 on:device.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   370
    wasOn ifTrue:[self showCursor]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   371
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   372
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   373
cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   374
    "return the cursors line (1..). 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   375
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   376
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   377
    ^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   378
!
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
fixedSize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   381
    "make the texts size fixed (no lines may be added).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   382
     OBSOLETE: use readOnly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   383
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   384
    readOnly ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   385
	readOnly := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   386
	middleButtonMenu notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   387
	    middleButtonMenu disableAll:#(cut paste replace indent)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   388
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   389
    ]
127
claus
parents: 125
diff changeset
   390
!
claus
parents: 125
diff changeset
   391
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   392
fromFile:aFileName
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   393
    "take contents from a named file"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   394
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   395
    self contents:(aFileName asFilename readStream contents)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   396
!
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
list:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   399
    "position cursor home when setting contents"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   400
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   401
    super list:something.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   402
    self cursorHome
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   403
!
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
modified
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   406
    "return true if text was modified"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   407
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   408
    ^ modifiedChannel value
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   409
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   410
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   411
modified:aBoolean
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   412
    "set the modified flag"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   413
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   414
    modifiedChannel value:aBoolean
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   415
!
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   416
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   417
modifiedChannel
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   418
    "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
   419
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   420
    ^ modifiedChannel
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   421
!
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
readOnly
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   424
    "make the text readonly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   425
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   426
    readOnly := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   427
! !
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
!EditTextView methodsFor:'change & update '!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   430
125
claus
parents: 123
diff changeset
   431
accept
claus
parents: 123
diff changeset
   432
    "accept the current contents by executing the accept-action and/or
claus
parents: 123
diff changeset
   433
     changeMessage."
claus
parents: 123
diff changeset
   434
claus
parents: 123
diff changeset
   435
    lockUpdates := true.
claus
parents: 123
diff changeset
   436
     "/
claus
parents: 123
diff changeset
   437
     "/ ST/X way of doing things
claus
parents: 123
diff changeset
   438
     "/ as a historic (and temporary) leftover,
claus
parents: 123
diff changeset
   439
     "/ the block is called with a stringCollection
claus
parents: 123
diff changeset
   440
     "/ - not with the actual string
claus
parents: 123
diff changeset
   441
     "/
claus
parents: 123
diff changeset
   442
     acceptAction notNil ifTrue:[
claus
parents: 123
diff changeset
   443
	 acceptAction value:self list
claus
parents: 123
diff changeset
   444
     ].
claus
parents: 123
diff changeset
   445
claus
parents: 123
diff changeset
   446
     "/
claus
parents: 123
diff changeset
   447
     "/ ST-80 way of doing it
claus
parents: 123
diff changeset
   448
     "/
127
claus
parents: 125
diff changeset
   449
     self sendChangeMessageWith:self argForChangeMessage.
125
claus
parents: 123
diff changeset
   450
claus
parents: 123
diff changeset
   451
    lockUpdates := false.
131
claus
parents: 130
diff changeset
   452
!
claus
parents: 130
diff changeset
   453
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   454
argForChangeMessage
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   455
    ^ self contents
121
claus
parents: 118
diff changeset
   456
!
claus
parents: 118
diff changeset
   457
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   458
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   459
    "get my contents from the model.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   460
     Redefined to ignore updates resulting from my own change."
121
claus
parents: 118
diff changeset
   461
claus
parents: 118
diff changeset
   462
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   463
     ignore updates from my own change
121
claus
parents: 118
diff changeset
   464
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   465
    lockUpdates ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   466
	lockUpdates := false.
125
claus
parents: 123
diff changeset
   467
	^ self
121
claus
parents: 118
diff changeset
   468
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   469
    ^ super getListFromModel
121
claus
parents: 118
diff changeset
   470
! !
claus
parents: 118
diff changeset
   471
claus
parents: 118
diff changeset
   472
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
   473
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   474
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   475
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   476
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   477
    self cursorCol:(self prevTabBefore:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   478
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   479
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   480
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   481
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   482
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   483
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   484
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   485
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   486
    cursorCol := newCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   487
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   488
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   489
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   490
cursorDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   491
    "move cursor down; scroll if at end of visible text"
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
    self cursorDown:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   494
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   495
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   496
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   497
    "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
   498
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   499
    |wasOn nv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   500
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   501
    cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   502
	wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   503
	nv := cursorVisibleLine + n - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   504
	(nv >= nFullLinesShown) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   505
	    self scrollDown:(nv - nFullLinesShown + 1)
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
	cursorLine := cursorLine + n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   508
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   509
	wasOn ifTrue:[self showCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   510
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   511
	cursorLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   512
	    cursorLine := firstLineShown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   513
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   514
	cursorLine := cursorLine + n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   515
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   516
	self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   517
    ].
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   518
    "/ cursor no longer visible ?
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   519
    cursorVisibleLine isNil ifTrue:[
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   520
	cursorLine > list size ifTrue:[
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   521
	    device beep. device sync.
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   522
	]
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   523
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   524
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   525
121
claus
parents: 118
diff changeset
   526
cursorHome
131
claus
parents: 130
diff changeset
   527
    "Otherwise, scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
   528
claus
parents: 118
diff changeset
   529
    |wasOn|
claus
parents: 118
diff changeset
   530
claus
parents: 118
diff changeset
   531
    wasOn := self hideCursor.
claus
parents: 118
diff changeset
   532
    cursorCol := 1.
131
claus
parents: 130
diff changeset
   533
    self scrollToTop.
claus
parents: 130
diff changeset
   534
    cursorLine := cursorVisibleLine := 1.
121
claus
parents: 118
diff changeset
   535
    self makeCursorVisibleAndShowCursor:wasOn.
claus
parents: 118
diff changeset
   536
!
claus
parents: 118
diff changeset
   537
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   538
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   539
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   540
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   541
    (cursorCol ~~ 1) ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   542
	self cursorCol:(cursorCol - 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   543
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   544
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   545
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   546
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   547
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   548
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   549
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   550
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   551
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   552
    cursorLine := line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   553
    cursorVisibleLine := self listLineToVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   554
    cursorCol := col.
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
	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
    self makeCursorVisibleAndShowCursor:wasOn.
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   561
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   562
    "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
   563
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   564
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   565
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   566
    self checkForExistingLine:(cursorLine + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   567
    cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   568
	nFullLinesShown notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   569
	    (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   570
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   571
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   572
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   573
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   574
    cursorCol := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   575
    cursorLine := cursorLine + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   576
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   577
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   578
!
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
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   581
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   582
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   583
    self cursorCol:(cursorCol + 1)
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
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   587
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   588
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   589
    self cursorCol:(self nextTabAfter:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   590
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   591
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   592
cursorToBeginOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   593
    "move cursor to start of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   594
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   595
    self cursorCol:1
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   598
cursorToBottom
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   599
    "move cursor to last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   600
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   601
    |wasOn newTop|
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
    wasOn := self hideCursor.
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
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   606
    (newTop < 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   607
	newTop := 1
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 scrollToLine:newTop.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   610
    cursorCol := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   611
    cursorLine := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   612
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   613
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   614
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   615
!
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
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   618
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   619
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   620
    |wasOn newTop l line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   621
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   622
    l := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   623
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   624
    cursorLine >= l ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   625
	line := self listAt:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   626
	(line isNil or:[line isEmpty]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   627
	    ^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   628
	]
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
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   632
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   633
    l := l + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   634
    newTop :=  l - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   635
    (newTop < 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   636
	newTop := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   637
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   638
    self scrollToLine:newTop.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   639
    cursorCol := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   640
    cursorLine := l.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   641
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
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
    self makeCursorVisibleAndShowCursor:wasOn.
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   646
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   647
    "move cursor to end of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   648
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   649
    |line newCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   650
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   651
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   652
	newCol := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   653
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   654
	line := list at:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   655
	newCol := line size + 1
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 cursorCol:newCol
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
131
claus
parents: 130
diff changeset
   660
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
   661
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
   662
claus
parents: 130
diff changeset
   663
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
   664
!
claus
parents: 130
diff changeset
   665
claus
parents: 130
diff changeset
   666
cursorToLastVisibleLine
claus
parents: 130
diff changeset
   667
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
   668
claus
parents: 130
diff changeset
   669
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
   670
!
claus
parents: 130
diff changeset
   671
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   672
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   673
    "move the cursor to the beginning of the next word"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   674
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   675
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   676
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   677
    (cursorLine > list size) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   678
    self wordAtLine:cursorLine col:cursorCol do:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   679
	:beginLine :beginCol :endLine :endCol :style | 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   680
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   681
	line := endLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   682
	col := endCol + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   683
	searching := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   684
	[searching 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   685
	 and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   686
	    self wordAtLine:line col:col do:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   687
		:beginLine :beginCol :endLine :endCol :style |
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
		(line > list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   690
		    "break out"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   691
		    searching := false
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   692
		] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   693
		    line := endLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   694
		    col := endCol + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   695
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   696
	    ]
121
claus
parents: 118
diff changeset
   697
	].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   698
	self cursorLine:line col:col
121
claus
parents: 118
diff changeset
   699
    ]
claus
parents: 118
diff changeset
   700
!
claus
parents: 118
diff changeset
   701
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   702
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   703
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   704
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   705
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   706
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   707
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   708
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   709
    "move cursor up; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   710
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   711
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   712
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   713
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   714
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   715
    "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
   716
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   717
    |wasOn nv nl|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   718
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   719
    cursorLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   720
	cursorLine := firstLineShown + nFullLinesShown - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   721
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   722
    nl := cursorLine - n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   723
    nl < 1 ifTrue:[nl := 1].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   724
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   725
    (nl ~~ cursorLine) ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   726
	wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   727
	cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   728
	    nv := cursorVisibleLine - n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   729
	    nv < 1 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   730
		self scrollUp:(nv negated + 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   731
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   732
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   733
	cursorLine := nl.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   734
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   735
	wasOn ifTrue:[self showCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   736
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   737
"/ to make cursor visible (even if below visible end):
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   738
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   739
"/      self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   740
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   741
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   742
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   743
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   744
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   745
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   746
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   747
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   748
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   749
    cursorLine := self visibleLineToAbsoluteLine:visibleLineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   750
    cursorVisibleLine := visibleLineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   751
    cursorCol := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   752
    (cursorCol < 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   753
	cursorCol := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   754
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   755
    self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   756
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   757
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   758
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   759
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
   760
claus
parents: 118
diff changeset
   761
    |line col|
claus
parents: 118
diff changeset
   762
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   763
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   764
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   765
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
   766
!
claus
parents: 118
diff changeset
   767
claus
parents: 118
diff changeset
   768
drawCursor
claus
parents: 118
diff changeset
   769
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
   770
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
   771
claus
parents: 118
diff changeset
   772
    shown ifTrue:[
claus
parents: 118
diff changeset
   773
	cursorVisibleLine notNil ifTrue:[
claus
parents: 118
diff changeset
   774
	    self hasSelection ifFalse:[
claus
parents: 118
diff changeset
   775
		self drawCursorCharacter
claus
parents: 118
diff changeset
   776
	    ]
claus
parents: 118
diff changeset
   777
	]
claus
parents: 118
diff changeset
   778
    ]
claus
parents: 118
diff changeset
   779
!
claus
parents: 118
diff changeset
   780
claus
parents: 118
diff changeset
   781
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
   782
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
   783
     of cursor should be drawn.
claus
parents: 123
diff changeset
   784
     Currently, supported are: #block, #frame, #ibeam, #caret and #solidCaret"
121
claus
parents: 118
diff changeset
   785
133
claus
parents: 132
diff changeset
   786
    |x y w char y2 x1 x2 oldPaint|
121
claus
parents: 118
diff changeset
   787
claus
parents: 118
diff changeset
   788
    self hasSelection ifTrue:[
claus
parents: 118
diff changeset
   789
	"
claus
parents: 118
diff changeset
   790
	 hide cursor, if there is a selection
claus
parents: 118
diff changeset
   791
	"
claus
parents: 118
diff changeset
   792
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
claus
parents: 118
diff changeset
   793
    ].
claus
parents: 118
diff changeset
   794
claus
parents: 118
diff changeset
   795
    cursorType == #block ifTrue:[
claus
parents: 118
diff changeset
   796
	super drawVisibleLine:cursorVisibleLine 
claus
parents: 118
diff changeset
   797
			  col:cursorCol 
claus
parents: 118
diff changeset
   798
			 with:fgColor
claus
parents: 118
diff changeset
   799
			  and:bgColor.
claus
parents: 118
diff changeset
   800
	^ self
claus
parents: 118
diff changeset
   801
    ].
claus
parents: 118
diff changeset
   802
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - leftOffset.
claus
parents: 118
diff changeset
   803
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
   804
133
claus
parents: 132
diff changeset
   805
    oldPaint := paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
   806
    cursorType == #frame ifTrue:[
claus
parents: 118
diff changeset
   807
	super redrawVisibleLine:cursorVisibleLine col:cursorCol.
claus
parents: 118
diff changeset
   808
claus
parents: 118
diff changeset
   809
	char := self characterUnderCursor asString.
claus
parents: 118
diff changeset
   810
	self paint:bgColor.
133
claus
parents: 132
diff changeset
   811
	self displayRectangleX:x y:y 
claus
parents: 132
diff changeset
   812
			 width:(font widthOf:char) height:fontHeight.
claus
parents: 132
diff changeset
   813
    ] ifFalse:[
claus
parents: 132
diff changeset
   814
	self paint:bgColor.
claus
parents: 132
diff changeset
   815
	cursorType == #ibeam ifTrue:[
claus
parents: 132
diff changeset
   816
	    x1 := x - 1.
claus
parents: 132
diff changeset
   817
	    y2 := y + fontHeight - 1.
claus
parents: 132
diff changeset
   818
	    self displayLineFromX:x1 y:y toX:x1 y:y2. 
claus
parents: 132
diff changeset
   819
	    self displayLineFromX:x y:y toX:x y:y2. 
claus
parents: 132
diff changeset
   820
	    ^ self
claus
parents: 132
diff changeset
   821
	] ifFalse:[
claus
parents: 132
diff changeset
   822
	    w := fontWidth // 2.
claus
parents: 132
diff changeset
   823
	    y := y + fontHeight - 3.
claus
parents: 132
diff changeset
   824
	    y2 := y + w.
claus
parents: 132
diff changeset
   825
	    x1 := x - w.
claus
parents: 132
diff changeset
   826
	    x2 := x + w.
claus
parents: 132
diff changeset
   827
	    cursorType == #caret ifTrue:[
claus
parents: 132
diff changeset
   828
		self lineWidth:2.
claus
parents: 132
diff changeset
   829
		self displayLineFromX:x1 y:y2 toX:x y:y. 
claus
parents: 132
diff changeset
   830
		self displayLineFromX:x y:y toX:x2 y:y2. 
claus
parents: 132
diff changeset
   831
	    ] ifFalse:[
claus
parents: 132
diff changeset
   832
		"anything else: solidCaret"
claus
parents: 132
diff changeset
   833
claus
parents: 132
diff changeset
   834
		self fillPolygon:(Array with:(x1 @ y2)
claus
parents: 132
diff changeset
   835
					with:(x @ y)
claus
parents: 132
diff changeset
   836
					with:(x2 @ y2))
claus
parents: 132
diff changeset
   837
	    ]
claus
parents: 132
diff changeset
   838
	]
121
claus
parents: 118
diff changeset
   839
    ].
133
claus
parents: 132
diff changeset
   840
    self paint:oldPaint.
121
claus
parents: 118
diff changeset
   841
!
claus
parents: 118
diff changeset
   842
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   843
drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   844
    "draw the cursor. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   845
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   846
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   847
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   848
    hasKeyboardFocus ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   849
	self drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   850
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   851
	self drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   852
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   853
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   854
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   855
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   856
    "draw the cursor when the focus is in the view."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   857
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   858
    self hasSelection ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   859
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   860
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   861
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   862
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   863
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   864
drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   865
    "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
   866
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   867
    self hasSelection ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   868
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
   869
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   870
    cursorType ~~ #block ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   871
	"these dont show unfocussed"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   872
	^ self drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   873
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   874
    self drawCursor:#frame with:cursorFgColor and:cursorBgColor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   875
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   876
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   877
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   878
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   879
     Make certain that this line is visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   880
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   881
    self makeLineVisible:aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   882
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   883
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   884
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   885
hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   886
    "make cursor invisible if currently visible; 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   887
     return true if cursor was visible before."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   888
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   889
    cursorShown ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   890
	shown ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   891
	    self undrawCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   892
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   893
	cursorShown := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   894
	^ true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   895
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   896
    ^ false
121
claus
parents: 118
diff changeset
   897
!
claus
parents: 118
diff changeset
   898
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   899
makeCursorVisible
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   900
    "scroll text to make cursorline visible 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   901
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   902
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   903
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   904
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   905
    cursorLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   906
	line := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   907
	col := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   908
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   909
	 if there is a selection, its better to
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   910
	 have its start being visible, instead of the end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   911
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   912
	(selectionStartLine notNil 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   913
	and:[selectionEndLine notNil]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   914
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   915
"/ that was wrong
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   916
"/      ((line == selectionEndLine)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   917
"/      and:[selectionEndCol notNil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   918
"/      and:[col == (selectionEndCol+1)]]) ifTrue:[
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
	    line := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   921
	    col := selectionStartCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   922
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   923
	self makeLineVisible:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   924
	self makeColVisible:col inLine:line 
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   928
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   929
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   930
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   931
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   932
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   933
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
   934
!
claus
parents: 118
diff changeset
   935
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   936
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   937
    "make cursor visible if currently invisible"
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
    cursorShown ifFalse: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   940
	self drawCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   941
	cursorShown := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   942
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   943
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   944
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   945
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   946
    "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
   947
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   948
    cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   949
	((cursorType == #caret) or:[cursorType == #solidCaret]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   950
	    "caret-cursor touches 4 characters"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   951
	    ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   952
		super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   953
		super redrawVisibleLine:cursorVisibleLine+1 from:cursorCol-1 to:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   954
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   955
		"care for left margin"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   956
		super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   957
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   958
	    ^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   959
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   960
	cursorType == #ibeam ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   961
	    "ibeam-cursor touches 2 characters"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   962
	    cursorCol > 1 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   963
		super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   964
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   965
		"care for left margin"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   966
		super redrawVisibleLine:cursorVisibleLine.
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
	    ^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   969
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   970
	"block is simple - just one character under cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   971
	super redrawVisibleLine:cursorVisibleLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   972
    ]
121
claus
parents: 118
diff changeset
   973
!
claus
parents: 118
diff changeset
   974
claus
parents: 118
diff changeset
   975
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
   976
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
   977
claus
parents: 118
diff changeset
   978
    (shown not or:[cursorShown not]) ifTrue:[
claus
parents: 118
diff changeset
   979
	^ aBlock value
claus
parents: 118
diff changeset
   980
    ].
claus
parents: 118
diff changeset
   981
    self hideCursor.
claus
parents: 118
diff changeset
   982
    aBlock valueNowOrOnUnwindDo:[
claus
parents: 118
diff changeset
   983
	self showCursor
claus
parents: 118
diff changeset
   984
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   985
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   986
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   987
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   988
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   989
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   990
    "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
   991
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   992
    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
   993
	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
   994
	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
   995
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   996
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   997
    "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
   998
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   999
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1000
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1001
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  1002
claus
parents: 118
diff changeset
  1003
    |wasOn|
claus
parents: 118
diff changeset
  1004
claus
parents: 118
diff changeset
  1005
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1006
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1007
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  1008
!
claus
parents: 118
diff changeset
  1009
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1010
deleteCharAtLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1011
    "delete single character at colNr in line lineNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1012
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1013
    |line lineSize newLine drawCharacterOnly wasLargest|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1014
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1015
    self checkModificationsAllowed ifFalse:[ ^ self].
259
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
    line := self listAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1018
    line isNil ifTrue: [^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1019
    lineSize := line size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1020
    (colNr > lineSize) ifTrue: [^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1021
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1022
    wasLargest := (self widthOfLineString:line) == widthOfWidestLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1023
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1024
    drawCharacterOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1025
    (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
  1026
        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
  1027
        fontIsFixedWidth ifTrue:[
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1028
            drawCharacterOnly := true
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1029
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1030
    ] ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1031
        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
  1032
        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
  1033
                       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
  1034
        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
  1035
                       with:line startingAt:(colNr + 1)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1036
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1037
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1038
    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
  1039
        newLine := nil
259
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
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1042
    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
  1043
        widthOfWidestLine := nil. "/ i.e. unknown
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1044
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1045
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1046
    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
  1047
        self redrawLine:lineNr col:colNr
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1048
    ] ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1049
        self redrawLine:lineNr from:colNr
121
claus
parents: 118
diff changeset
  1050
    ]
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1051
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1052
    "Modified: 23.2.1996 / 17:42:23 / cg"
121
claus
parents: 118
diff changeset
  1053
!
claus
parents: 118
diff changeset
  1054
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1055
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1056
    "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
  1057
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1058
    |wasOn oldSize lineNrAboveCursor|
121
claus
parents: 118
diff changeset
  1059
claus
parents: 118
diff changeset
  1060
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1061
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1062
    (cursorCol == 1) ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1063
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1064
	 somewhere in the middle of a line
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1065
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1066
	self cursorLeft.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1067
	self deleteCharAtLine:cursorLine col:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1068
    ] ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1069
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1070
	 at begin of line - merge with previous line;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1071
	 except for the very first line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1072
	"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1073
	(cursorLine == 1) ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1074
	    oldSize := 0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1075
	    lineNrAboveCursor := cursorLine - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1076
	    list notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1077
	       (list size >= lineNrAboveCursor) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1078
		   (list at:lineNrAboveCursor) notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1079
		       oldSize := (list at:lineNrAboveCursor) size
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1080
		   ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1081
	       ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1082
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1083
	    self mergeLine:lineNrAboveCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1084
	    cursorLine := lineNrAboveCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1085
	    cursorCol := oldSize + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1086
	    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1087
	    self makeCursorVisible
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1088
	]
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
    wasOn ifTrue:[self showCursor].
121
claus
parents: 118
diff changeset
  1091
!
claus
parents: 118
diff changeset
  1092
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1093
deleteCharsAtLine:lineNr fromCol:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1094
    "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
  1095
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1096
    |line newLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1097
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1098
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1099
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1100
    line := self listAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1101
    line isNil ifTrue: [^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1102
    (colNr > line size) ifTrue: [^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1103
    newLine := line copyTo:(colNr - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1104
    newLine isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1105
	newLine := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1106
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1107
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1108
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1109
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1110
    self redrawLine:lineNr
131
claus
parents: 130
diff changeset
  1111
!
claus
parents: 130
diff changeset
  1112
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1113
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1114
    "delete characters from startCol to endCol in line lineNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1115
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1116
    |line lineSize newLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1117
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1118
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1119
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1120
    line := self listAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1121
    line isNil ifTrue: [^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1122
    lineSize := line size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1123
    (startCol > lineSize) ifTrue: [^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1124
    (endCol == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1125
    (endCol < startCol) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1126
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1127
    (startCol == endCol) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1128
	self deleteCharAtLine:lineNr col:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1129
	^ self
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
    (endCol >= lineSize) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1132
	self deleteCharsAtLine:lineNr fromCol:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1133
	^ self
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
    (startCol <= 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1136
	self deleteCharsAtLine:lineNr toCol:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1137
	^ self
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
    newLine := (line copyTo:(startCol - 1)) 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1140
	       , (line copyFrom:(endCol + 1) to:lineSize).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1141
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1142
    newLine isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1143
	newLine := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1144
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1145
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1146
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1147
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1148
    self redrawLine:lineNr
121
claus
parents: 118
diff changeset
  1149
!
claus
parents: 118
diff changeset
  1150
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1151
deleteCharsAtLine:lineNr toCol:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1152
    "delete characters from start up to colNr in line lineNr"
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
    |line lineSize newLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1155
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1156
    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
  1157
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1158
    line := self listAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1159
    line isNil ifTrue: [^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1160
    lineSize := line size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1161
    (colNr >= lineSize) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1162
	newLine := nil
121
claus
parents: 118
diff changeset
  1163
    ] ifFalse:[
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1164
	newLine := line copyFrom:(colNr + 1) to:lineSize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1165
	newLine isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1166
	    newLine := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1167
	]
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
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1170
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1171
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1172
    self redrawLine:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1173
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1174
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1175
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1176
    "delete the line where the cursor sits"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1177
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1178
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  1179
!
claus
parents: 118
diff changeset
  1180
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1181
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1182
    "delete all text from startLine/startCol to endLine/endCol -
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1183
     joining lines if nescessary"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1184
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1185
    |line lineSize|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1186
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1187
    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
  1188
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1189
    list isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1190
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1191
    (startLine == endLine) ifTrue:[
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1192
        "delete chars within a line"
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1193
        self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1194
        ^ self
121
claus
parents: 118
diff changeset
  1195
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1196
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1197
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1198
        "delete full lines only"
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1199
        endLine > startLine ifTrue:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1200
            self deleteFromLine:startLine toLine:(endLine - 1)
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1201
        ].
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1202
        ^ self
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1205
    "delete right rest of 1st line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1206
    self deleteCharsAtLine:startLine fromCol:startCol.
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
    "delete the inner lines ..."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1209
    endLine > (startLine + 1) ifTrue:[
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1210
        self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1213
    (endCol ~~ 0) ifTrue:[
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1214
        "delete the left rest of the last line"
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1215
        self deleteCharsAtLine:(startLine + 1) toCol:endCol.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1216
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1217
        "must add blanks, if startCal lies behond end of startLine"
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1218
        line := list at:startLine.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1219
        lineSize := line size.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1220
        (startCol > lineSize) ifTrue:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1221
            line isNil ifTrue:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1222
                line := String new:(startCol - 1)
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1223
            ] ifFalse:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1224
                line := line , (line species new:(startCol - 1 - lineSize))
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1225
            ].
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1226
            list at:startLine put:line.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1227
            widthOfWidestLine := nil. "/ i.e. unknown
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1228
            self textChanged.
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1229
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1230
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1231
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1232
    "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
  1233
    self mergeLine:startLine
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1234
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1235
    "Modified: 23.2.1996 / 19:08:21 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1236
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1237
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1238
deleteFromLine:startLineNr toLine:endLineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1239
    "delete some lines"
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
    |wasOn nLines|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1242
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1243
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1244
    list isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1245
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1246
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1247
    list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1248
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1249
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1250
    self redrawFromLine:startLineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1251
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1252
    nLines := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1253
    (firstLineShown >= nLines) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1254
	self makeLineVisible:nLines
121
claus
parents: 118
diff changeset
  1255
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1256
    wasOn ifTrue:[self showCursor].
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1259
deleteLine:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1260
    "delete line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1261
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1262
    |wasOn visLine w
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1263
     srcY "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1264
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1265
    w := self widthForScrollBetween:lineNr and:(firstLineShown + nLinesShown).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1266
    (self deleteLineWithoutRedraw:lineNr) ifFalse:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1267
    shown ifFalse:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1268
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1269
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1270
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1271
    visLine := self listLineToVisibleLine:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1272
    visLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1273
	srcY :=  margin + topMargin + (visLine * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1274
	self catchExpose.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1275
	self copyFrom:self x:textStartLeft y:srcY
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1276
			 toX:textStartLeft y:(srcY - fontHeight)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1277
		       width:w height:((nLinesShown - visLine) * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1278
	self redrawVisibleLine:nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1279
	(nFullLinesShown ~~ nLinesShown) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1280
	    self redrawVisibleLine:nLinesShown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1281
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1282
	self waitForExpose
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1283
    ].
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
    wasOn ifTrue:[self showCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1286
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1287
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1288
deleteLineWithoutRedraw:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1289
    "delete line - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1290
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1291
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1292
    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
  1293
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1294
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1295
    list removeIndex:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1296
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1297
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1298
    ^ true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1299
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1300
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1301
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1302
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1303
     return true, if something was really deleted"
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
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1306
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1307
    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
  1308
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1309
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1310
    (endLine > list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1311
	lastLine := list size
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1312
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1313
	lastLine := endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1314
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1315
    list removeFromIndex:startLine toIndex:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1316
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1317
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1318
    ^ true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1319
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1320
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1321
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1322
    "delete the selection"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1323
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1324
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1325
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1326
    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
  1327
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1328
    selectionStartLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1329
	wasOn := self hideCursor.
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
	startLine := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1332
	startCol := selectionStartCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1333
	endLine := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1334
	endCol := selectionEndCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1335
	self unselectWithoutRedraw.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1336
	self deleteFromLine:startLine col:startCol 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1337
		     toLine:endLine col:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1338
	cursorCol := startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1339
	cursorLine := startLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1340
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1341
	self makeCursorVisibleAndShowCursor:wasOn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1342
    ]
121
claus
parents: 118
diff changeset
  1343
!
claus
parents: 118
diff changeset
  1344
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1345
insert:aCharacter atLine:lineNr col:colNr
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1346
    "insert a single character at lineNr/colNr"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1347
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1348
    |line lineSize newLine drawCharacterOnly|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1349
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1350
    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
  1351
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1352
    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
  1353
        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
  1354
        ^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1355
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1356
    drawCharacterOnly := false.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1357
    self checkForExistingLine:lineNr.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1358
    line := list at:lineNr.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1359
    lineSize := line size.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1360
    (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
  1361
        (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
  1362
            ^ self
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1363
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1364
    ].
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1365
    (lineSize == 0) ifTrue:[
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1366
        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
  1367
        drawCharacterOnly := true
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1368
    ] ifFalse: [
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1369
        (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
  1370
            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
  1371
            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
  1372
                           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
  1373
            drawCharacterOnly := true
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1374
        ] ifFalse: [
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1375
            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
  1376
            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
  1377
                           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
  1378
            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
  1379
                           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
  1380
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1381
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1382
    newLine at:colNr put:aCharacter.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1383
    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
  1384
        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
  1385
        drawCharacterOnly := false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1386
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1387
    list at:lineNr put:newLine.
118
claus
parents: 105
diff changeset
  1388
    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
  1389
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
118
claus
parents: 105
diff changeset
  1390
    ].
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1391
    self textChanged.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1392
    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
  1393
        drawCharacterOnly ifTrue:[
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1394
            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
  1395
        ] ifFalse:[
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1396
            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
  1397
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1398
    ]
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1399
387
bf7217524026 more 16bit fixes
Claus Gittinger <cg@exept.de>
parents: 385
diff changeset
  1400
    "Modified: 23.2.1996 / 19:09:36 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1401
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1402
121
claus
parents: 118
diff changeset
  1403
insertCharAtCursor:aCharacter
claus
parents: 118
diff changeset
  1404
    "insert a single character at cursor-position - advance cursor"
claus
parents: 118
diff changeset
  1405
claus
parents: 118
diff changeset
  1406
    |wasOn|
claus
parents: 118
diff changeset
  1407
claus
parents: 118
diff changeset
  1408
    wasOn := self hideCursor.
claus
parents: 118
diff changeset
  1409
    self insert:aCharacter atLine:cursorLine col:cursorCol.
claus
parents: 118
diff changeset
  1410
    aCharacter == (Character cr) ifTrue:[
claus
parents: 118
diff changeset
  1411
	self cursorReturn
claus
parents: 118
diff changeset
  1412
    ] ifFalse:[
125
claus
parents: 123
diff changeset
  1413
	self cursorRight.
121
claus
parents: 118
diff changeset
  1414
    ].
claus
parents: 118
diff changeset
  1415
    self makeCursorVisibleAndShowCursor:wasOn.
claus
parents: 118
diff changeset
  1416
!
claus
parents: 118
diff changeset
  1417
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1418
insertLine:aString before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1419
    "insert the line aString before line lineNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1420
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1421
    |wasOn visLine w 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1422
     dstY "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1423
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1424
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1425
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1426
    visLine := self listLineToVisibleLine:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1427
    (shown not or:[visLine isNil]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1428
	self withoutRedrawInsertLine:aString before:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1429
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1430
	w := self widthForScrollBetween:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1431
				    and:(firstLineShown + nLinesShown).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1432
	dstY := topMargin + ((visLine ) * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1433
	self catchExpose.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1434
	self withoutRedrawInsertLine:aString before:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1435
	self copyFrom:self x:textStartLeft y:(dstY - fontHeight)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1436
			 toX:textStartLeft y:dstY
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1437
		       width:w
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1438
		      height:((nLinesShown - visLine "- 1") * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1439
	self redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1440
	self waitForExpose.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1441
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1442
    widthOfWidestLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1443
	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:aString).
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1444
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1445
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1446
    wasOn ifTrue:[self showCursor].
121
claus
parents: 118
diff changeset
  1447
!
claus
parents: 118
diff changeset
  1448
155
claus
parents: 133
diff changeset
  1449
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  1450
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  1451
claus
parents: 133
diff changeset
  1452
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  1453
claus
parents: 133
diff changeset
  1454
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  1455
!
claus
parents: 133
diff changeset
  1456
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1457
insertLines:someText from:start to:end before:lineNr
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1458
    "insert a bunch of lines before line lineNr"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1459
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1460
    |visLine w nLines "{ Class: SmallInteger }"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1461
     srcY "{ Class: SmallInteger }"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1462
     dstY "{ Class: SmallInteger }" |
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1463
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1464
    readOnly ifTrue:[
118
claus
parents: 105
diff changeset
  1465
	^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1466
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1467
    visLine := self listLineToVisibleLine:lineNr.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1468
    (shown not or:[visLine isNil]) ifTrue:[
118
claus
parents: 105
diff changeset
  1469
	self withoutRedrawInsertLines:someText
claus
parents: 105
diff changeset
  1470
				 from:start to:end
claus
parents: 105
diff changeset
  1471
			       before:lineNr.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1472
    ] ifFalse:[
118
claus
parents: 105
diff changeset
  1473
	nLines := end - start + 1.
claus
parents: 105
diff changeset
  1474
	((visLine + nLines) >= nLinesShown) ifTrue:[
claus
parents: 105
diff changeset
  1475
	    self withoutRedrawInsertLines:someText
claus
parents: 105
diff changeset
  1476
				     from:start to:end
claus
parents: 105
diff changeset
  1477
				   before:lineNr.
claus
parents: 105
diff changeset
  1478
	    self redrawFromVisibleLine:visLine to:nLinesShown
claus
parents: 105
diff changeset
  1479
	] ifFalse:[
claus
parents: 105
diff changeset
  1480
	    w := self widthForScrollBetween:(lineNr + nLines)
claus
parents: 105
diff changeset
  1481
					and:(firstLineShown + nLines + nLinesShown).
claus
parents: 105
diff changeset
  1482
	    srcY := topMargin + ((visLine - 1) * fontHeight).
claus
parents: 105
diff changeset
  1483
	    dstY := srcY + (nLines * fontHeight).
claus
parents: 105
diff changeset
  1484
	    "
claus
parents: 105
diff changeset
  1485
	     stupid: must catchExpose before inserting new
claus
parents: 105
diff changeset
  1486
	     stuff - since catchExpose may perform redraws
claus
parents: 105
diff changeset
  1487
	    "
claus
parents: 105
diff changeset
  1488
	    self catchExpose.
claus
parents: 105
diff changeset
  1489
	    self withoutRedrawInsertLines:someText
claus
parents: 105
diff changeset
  1490
				     from:start to:end
claus
parents: 105
diff changeset
  1491
				   before:lineNr.
claus
parents: 105
diff changeset
  1492
	    self copyFrom:self x:textStartLeft y:srcY
claus
parents: 105
diff changeset
  1493
			     toX:textStartLeft y:dstY
claus
parents: 105
diff changeset
  1494
			   width:w
claus
parents: 105
diff changeset
  1495
			  height:(height - dstY).
claus
parents: 105
diff changeset
  1496
	    self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
claus
parents: 105
diff changeset
  1497
	    self waitForExpose
claus
parents: 105
diff changeset
  1498
	].
claus
parents: 105
diff changeset
  1499
    ].
claus
parents: 105
diff changeset
  1500
    widthOfWidestLine notNil ifTrue:[
claus
parents: 105
diff changeset
  1501
	someText do:[:line |
claus
parents: 105
diff changeset
  1502
	    widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
claus
parents: 105
diff changeset
  1503
	]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1504
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1505
    self textChanged.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1506
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1507
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1508
insertLines:lines withCr:withCr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1509
    "insert a bunch of lines at cursor position. Cursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1510
     is moved behind insertion.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1511
     If withCr is true, append cr after last line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1512
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1513
    |start end nLines wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1514
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1515
    lines notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1516
	nLines := lines size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1517
	(nLines == 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1518
	    self insertStringAtCursor:(lines at:1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1519
	    withCr ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1520
		self insertCharAtCursor:(Character cr)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1521
	    ] 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1522
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1523
	    (cursorCol ~~ 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1524
		self insertStringAtCursor:(lines at:1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1525
		self insertCharAtCursor:(Character cr).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1526
		start := 2
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1527
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1528
		start := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1529
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1530
	    withCr ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1531
		end := nLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1532
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1533
		end := nLines - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1534
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1535
	    (start < nLines) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1536
		(end >= start) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1537
		    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1538
		    self insertLines:lines from:start to:end before:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1539
		    cursorLine := cursorLine + (end - start + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1540
		    cursorVisibleLine := self absoluteLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1541
		    wasOn ifTrue:[self showCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1542
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1543
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1544
	    withCr ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1545
		"last line without cr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1546
		self insertStringAtCursor:(lines at:nLines)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1547
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1548
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1549
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1550
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1551
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1552
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1553
    "insert the argument, aString at cursor position and select it"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1554
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1555
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1556
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1557
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1558
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1559
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1560
    self selectFromLine:startLine col:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1561
		 toLine:cursorLine col:(cursorCol - 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1562
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1563
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1564
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1565
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1566
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1567
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1568
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1569
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1570
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1571
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1572
     l               "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1573
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1574
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1575
    aString isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1576
    ((aString occurrencesOf:(Character cr)) == 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1577
	^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  1578
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1579
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1580
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1581
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1582
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1583
    [start <= end] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1584
	stop := aString indexOf:(Character cr) startingAt:start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1585
	stop == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1586
	    stop := end + 1
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
	subString := aString copyFrom:start to:(stop - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1589
	self insertStringWithoutCRs:subString atLine:l col:c.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1590
	(stop < end) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1591
	    c := c + subString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1592
	    self insert:(Character cr) atLine:l col:c.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1593
	    l := l + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1594
	    c := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1595
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1596
	start := stop + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1597
    ]
121
claus
parents: 118
diff changeset
  1598
!
claus
parents: 118
diff changeset
  1599
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1600
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1601
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1602
     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
  1603
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1604
    |start " { Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1605
     stop  " { Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1606
     end   " { Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1607
     subString|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1608
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1609
    aString isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1610
	"new:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1611
	self insertCharAtCursor:(Character cr).
118
claus
parents: 105
diff changeset
  1612
	^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1613
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1614
    ((aString occurrencesOf:(Character cr)) == 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1615
	^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1616
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1617
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1618
    self insertLines:aString asStringCollection withCr:false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1619
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1620
"/    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1621
"/    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1622
"/    "insert the 1st line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1623
"/    (cursorCol ~~ 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1624
"/        stop := aString indexOf:(Character cr) startingAt:start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1625
"/        stop == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1626
"/            stop := end + 1
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
"/        subString := aString copyFrom:start to:(stop - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1629
"/        self insertStringWithoutCRsAtCursor:subString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1630
"/        self insertCharAtCursor:(Character cr).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1631
"/        start := stop + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1632
"/    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1633
"/    "insert the block of full lines"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1634
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1635
"/    [start <= end] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1636
"/        stop := aString indexOf:(Character cr) startingAt:start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1637
"/        stop == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1638
"/            stop := end + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1639
"/        ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1640
"/        subString := aString copyFrom:start to:(stop - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1641
"/        self insertStringWithoutCRsAtCursor:subString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1642
"/        (stop < end) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1643
"/            self insertCharAtCursor:(Character cr)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1644
"/        ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1645
"/        start := stop + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1646
"/    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1647
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1648
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1649
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1650
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1651
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1652
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1653
    shown ifTrue:[self redrawLine:lineNr from:colNr]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1654
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1655
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1656
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1657
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1658
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1659
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1660
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1661
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1662
    aString notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1663
	wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1664
	self insertString:aString atLine:cursorLine col:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1665
	cursorCol := cursorCol + aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1666
	wasOn ifTrue:[self showCursor]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1667
    ]
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1670
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1671
    "insert spaces to next tab"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1672
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1673
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1674
121
claus
parents: 118
diff changeset
  1675
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1676
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1677
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1678
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1679
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1680
121
claus
parents: 118
diff changeset
  1681
mergeLine:lineNr
claus
parents: 118
diff changeset
  1682
    "merge line lineNr with line lineNr+1"
claus
parents: 118
diff changeset
  1683
claus
parents: 118
diff changeset
  1684
    |leftPart rightPart bothParts nextLineNr|
claus
parents: 118
diff changeset
  1685
claus
parents: 118
diff changeset
  1686
    list isNil ifFalse:[
claus
parents: 118
diff changeset
  1687
	nextLineNr := lineNr + 1.
claus
parents: 118
diff changeset
  1688
	(nextLineNr > list size) ifFalse:[
156
claus
parents: 155
diff changeset
  1689
	    (leftPart := self listAt:lineNr) isNil ifTrue:[
121
claus
parents: 118
diff changeset
  1690
		leftPart := ''
claus
parents: 118
diff changeset
  1691
	    ].
156
claus
parents: 155
diff changeset
  1692
	    (rightPart := self listAt:nextLineNr) isNil ifTrue:[
121
claus
parents: 118
diff changeset
  1693
		rightPart := ''
claus
parents: 118
diff changeset
  1694
	    ].
claus
parents: 118
diff changeset
  1695
	    bothParts := leftPart , rightPart.
claus
parents: 118
diff changeset
  1696
	    bothParts isBlank ifTrue:[bothParts := nil].
claus
parents: 118
diff changeset
  1697
	    list at:lineNr put:bothParts.
claus
parents: 118
diff changeset
  1698
	    self redrawLine:lineNr.
claus
parents: 118
diff changeset
  1699
	    self deleteLine:nextLineNr
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1700
	]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1701
    ]
156
claus
parents: 155
diff changeset
  1702
claus
parents: 155
diff changeset
  1703
    "Modified: 7.9.1995 / 15:56:17 / claus"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1704
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1705
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1706
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1707
    "remove all blank lines at end of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1708
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1709
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1710
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1711
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1712
    lastLine := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1713
    finished := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1714
    [finished] whileFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1715
	(lastLine <= 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1716
	    finished := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1717
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1718
	    line := list at:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1719
	    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1720
		line isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1721
		    list at:lastLine put:nil.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1722
		    line := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1723
		]
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
	    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1726
		finished := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1727
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1728
		lastLine := lastLine - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1729
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1730
	]
118
claus
parents: 105
diff changeset
  1731
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1732
    (lastLine ~~ list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1733
	list grow:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1734
"/        self textChanged
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1735
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1736
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1737
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1738
replaceSelectionBy:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1739
    "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
  1740
     leave cursor after insertion"
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
    self replaceSelectionBy:something keepCursor:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1743
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1744
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1745
replaceSelectionBy:something keepCursor:keep
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1746
    "delete the selection (if any) and insert something, a character or string;
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1747
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1748
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1749
    |sel l c|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1750
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1751
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1752
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1753
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1754
    sel := self selection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1755
    sel notNil ifTrue:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1756
	lastString := sel.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1757
	self deleteSelection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1758
	replacing := true.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1759
	lastReplacement := ''
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1760
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1761
    (something isMemberOf:Character) ifTrue:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1762
	lastReplacement notNil ifTrue:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1763
	    (lastReplacement endsWith:Character space) ifTrue:[
131
claus
parents: 130
diff changeset
  1764
		lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)".
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1765
		lastReplacement := lastReplacement copyWith:something.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1766
		lastReplacement := lastReplacement copyWith:Character space
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1767
	    ] ifFalse:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1768
		lastReplacement := lastReplacement copyWith:something.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1769
	    ]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1770
	].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1771
	self insertCharAtCursor:something
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1772
    ] ifFalse:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1773
	lastReplacement := something.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1774
	self insertStringAtCursor:something
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1775
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1776
    keep ifTrue:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1777
	self cursorLine:l col:c
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1778
    ]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1779
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1780
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1781
splitLine:lineNr before:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1782
    "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
  1783
     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
  1784
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1785
    |line lineSize leftRest rightRest visLine w      
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1786
     srcY    "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1787
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1788
    list isNil ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1789
	lineNr > (list size) ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1790
	    (colNr == 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1791
		self insertLine:nil before:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1792
		^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1793
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1794
	    line := list at:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1795
	    line isNil ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1796
		lineSize := line size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1797
		(colNr <= lineSize) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1798
		    rightRest := line copyFrom:colNr to:lineSize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1799
		    (colNr > 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1800
			leftRest := line copyTo:(colNr - 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1801
		    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1802
		] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1803
		    leftRest := line
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1804
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1805
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1806
	    leftRest notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1807
		leftRest isBlank ifTrue:[leftRest := nil]
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
	    list at:lineNr put:leftRest.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1810
	    self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1811
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1812
	    visLine := self listLineToVisibleLine:(lineNr).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1813
	    visLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1814
		w := self widthForScrollBetween:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1815
					    and:(firstLineShown + nLinesShown).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1816
		srcY := topMargin + (visLine * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1817
		self catchExpose.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1818
		self copyFrom:self x:textStartLeft y:srcY
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1819
				 toX:textStartLeft y:(srcY + fontHeight)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1820
			       width:w
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1821
			      height:((nLinesShown - visLine - 1) * fontHeight).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1822
		self redrawLine:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1823
		self redrawLine:(lineNr + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1824
		self waitForExpose
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1825
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1826
	    widthOfWidestLine := nil. "/ unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1827
	    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1828
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1829
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1830
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1831
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1832
withoutRedrawInsertLine:aString before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1833
    "insert the argument, aString before line lineNr; the string
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1834
     becomes line nileNr; everything else is moved down; the view
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1835
     is not redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1836
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1837
    |line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1838
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1839
    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
  1840
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1841
    line := aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1842
    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1843
	line isString ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1844
	    line isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1845
		line := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1846
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1847
		(line occurrencesOf:(Character tab)) == 0 ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1848
		    line := self withTabsExpanded:line
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1849
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1850
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1851
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1852
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1853
    list isNil ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1854
	list := StringCollection new:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1855
    ] ifFalse: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1856
	list grow:((list size + 1) max:lineNr)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1857
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1858
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1859
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1860
     overlapping copy - if it didn't, we had to use:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1861
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1862
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1863
    [index > lineNr] whileTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1864
	pIndex := index - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1865
	list at:index put:(list at:pIndex).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1866
	index := pIndex
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1867
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1868
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1869
    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
  1870
    list at:lineNr put:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1871
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1872
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1873
withoutRedrawInsertLines:lines from:start to:end before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1874
    "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
  1875
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1876
    |newLine newLines nLines|
121
claus
parents: 118
diff changeset
  1877
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1878
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1879
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1880
    nLines := end - start + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1881
    newLines := Array new:(lines size).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1882
    start to:end do:[:index |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1883
	newLine := lines at:index.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1884
	newLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1885
	    newLine isString ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1886
		newLine isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1887
		    newLine := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1888
		] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1889
		    (newLine occurrencesOf:(Character tab)) == 0 ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1890
			newLine := self withTabsExpanded:newLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1891
		    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1892
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1893
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1894
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1895
	newLines at:index put:newLine
121
claus
parents: 118
diff changeset
  1896
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1897
    list isNil ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1898
	list := StringCollection new:(lineNr + nLines + 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1899
    ] ifFalse: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1900
	list grow:((list size + nLines) max:(lineNr + nLines - 1))
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1901
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1902
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1903
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1904
     overlapping copy - if it didn't, we had to use:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1905
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1906
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1907
    [index > lineNr] whileTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1908
	pIndex := index - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1909
	list at:index put:(list at:pIndex).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1910
	index := pIndex
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1911
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1912
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1913
    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
  1914
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
121
claus
parents: 118
diff changeset
  1915
!
claus
parents: 118
diff changeset
  1916
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1917
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1918
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1919
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  1920
    |strLen line lineSize newLine stringType|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1921
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1922
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1923
    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
  1924
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1925
    strLen := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1926
    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
  1927
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  1928
    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
  1929
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1930
    line := list at:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1931
    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
  1932
        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
  1933
        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
  1934
            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
  1935
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1936
    ] ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1937
        lineSize := 0
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1938
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1939
    ((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
  1940
        newLine := aString
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1941
    ] ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1942
        (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
  1943
            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
  1944
        ] ifFalse: [
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1945
            (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
  1946
                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
  1947
                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
  1948
                               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
  1949
            ] ifFalse: [
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  1950
                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
  1951
                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
  1952
                               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
  1953
                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
  1954
                               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
  1955
            ]
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1956
        ].
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  1957
        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
  1958
                       with:aString startingAt:1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1959
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1960
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1961
    (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
  1962
        newLine := self withTabsExpanded:newLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1963
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1964
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1965
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1966
    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
  1967
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1968
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1969
    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
  1970
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  1971
    "Modified: 26.2.1996 / 18:07:34 / cg"
259
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
!EditTextView methodsFor:'event processing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1975
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1976
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1977
    "hide the cursor when button is activated"
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
    hasKeyboardFocus := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1980
    cursorShown ifTrue: [self drawCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1981
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1982
    ((button == 1) or:[button == #select]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1983
	self hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1984
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1985
    (button == #paste) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1986
	self pasteOrReplace.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1987
	^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1988
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1989
    super buttonPress:button x:x y:y
121
claus
parents: 118
diff changeset
  1990
!
claus
parents: 118
diff changeset
  1991
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1992
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1993
    "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
  1994
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1995
    ((button == 1) or:[button == #select]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1996
	typeOfSelection := nil. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1997
	selectionStartLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1998
	    clickCol notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1999
		self cursorLine:clickLine col:clickCol
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
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2002
	    lastString := nil. "new selection invalidates remembered string"
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
	self showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2005
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2006
    super buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2007
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2008
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2009
hasKeyboardFocus:aBoolean
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2010
    "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
  2011
     (otherwise, I would not know about this)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2012
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2013
    hasKeyboardFocus := aBoolean.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2014
    cursorShown ifTrue: [self drawCursor].
121
claus
parents: 118
diff changeset
  2015
!
claus
parents: 118
diff changeset
  2016
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2017
keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2018
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2019
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2020
    <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
  2021
                          #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
  2022
                          #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
  2023
                          #SelectFromBeginning
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2024
                          #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
  2025
                          #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
  2026
                          #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
  2027
                          #InsertLine)>
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2028
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2029
    |sensor n fKeyMacros|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2030
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2031
    sensor := self sensor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2032
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2033
    (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
  2034
        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
  2035
            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
  2036
                "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
  2037
                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
  2038
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2039
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2040
            "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
  2041
             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
  2042
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2043
            (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
  2044
                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
  2045
            ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2046
                (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
  2047
                    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
  2048
                    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
  2049
                ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2050
                    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
  2051
                ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2052
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2053
            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
  2054
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2055
            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
  2056
                "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
  2057
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2058
                "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
  2059
                        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
  2060
                "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2061
"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2062
                (#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2063
"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2064
                (#( $) $] $} ) 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
  2065
                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
  2066
                                   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
  2067
                                                |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
  2068
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2069
                                                savLine := cursorLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2070
                                                savCol := cursorCol.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2071
                                                self cursorLine:line col:col.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2072
                                                device flush.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2073
                                                Processor activeProcess millisecondDelay:200.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2074
                                                self cursorLine:savLine col:savCol
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2075
                                           ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2076
                                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
  2077
                                   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
  2078
                ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2079
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2080
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2081
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2082
    ].                         
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2083
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2084
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2085
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2086
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2087
     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
  2088
             another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2089
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2090
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2091
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2092
    (('[fF][0-9]' match:key)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2093
    or:['[fF][0-9][0-9]' match:key]) ifTrue:[
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2094
        self sensor shiftDown 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
  2095
            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
  2096
            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
  2097
                (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
  2098
                    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
  2099
                    ^ self
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2100
                ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2101
            ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2102
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2103
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2104
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  2105
    (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
  2106
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2107
    ((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2108
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2109
    (key == #Again) ifTrue:[self again. ^self].
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
    (key == #Replace) ifTrue:[self replace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2112
    (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
  2113
        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
  2114
        ^ self selectWordUnderCursor. 
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2117
    (key == #SearchMatchingParent) ifTrue:[^ self searchForMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2118
    (key == #SelectMatchingParents) ifTrue:[^ self searchForAndSelectMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2119
    (key == #SelectToEnd) ifTrue:[^ self selectUpToEnd.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2120
    (key == #SelectFromBeginning) ifTrue:[^ self selectFromBeginning.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2121
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2122
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2123
  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
  2124
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2125
    (key == #Ctrlb) ifTrue:[self unselect. self cursorLeft. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2126
    (key == #Ctrlf) ifTrue:[self unselect. self cursorRight. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2127
    (key == #Ctrln) ifTrue:[self unselect. self cursorDown. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2128
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2129
"
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
    (key == #BeginOfLine) ifTrue:[self cursorToBeginOfLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2132
    (key == #EndOfLine) ifTrue:[self cursorToEndOfLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2133
    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2134
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2135
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2136
    (key == #CursorRight) 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
  2137
        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
  2138
            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
  2139
            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
  2140
            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
  2141
            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
  2142
                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
  2143
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2144
            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
  2145
            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
  2146
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2147
        self cursorRight. ^self
121
claus
parents: 118
diff changeset
  2148
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2149
    (key == #CursorDown) 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
  2150
        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
  2151
            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
  2152
            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
  2153
            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
  2154
            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
  2155
                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
  2156
                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
  2157
                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
  2158
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2159
            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
  2160
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2161
        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
  2162
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2163
        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
  2164
            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
  2165
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2166
            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
  2167
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2168
        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
  2169
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2170
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2171
    (key == #CursorLeft or:[key == #CursorUp]) 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
  2172
        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
  2173
            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
  2174
            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
  2175
            cursorCol := selectionStartCol.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2176
            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
  2177
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2178
        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
  2179
        (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
  2180
            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
  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
        (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
  2183
            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
  2184
                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
  2185
            ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2186
                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
  2187
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2188
            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
  2189
            ^ self
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2190
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2191
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2192
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2193
    (key == #Return)    ifTrue:[
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2194
        self sensor shiftDown 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
  2195
            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
  2196
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2197
        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
  2198
            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
  2199
            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
  2200
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2201
            "/ old version just unselected ...
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2202
            "/ 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
  2203
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2204
            "/ new version deletes ...
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2205
            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
  2206
                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
  2207
            ] ifFalse:[
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 copyAndDeleteSelection.            
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2209
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2210
            self insertCharAtCursor:(Character cr). 
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2211
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2212
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2213
    ].
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
  2214
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2215
    (key == #Tab) ifTrue:[
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2216
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2217
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2218
        self sensor shiftDown 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
  2219
            "
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2220
             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
  2221
             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
  2222
             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
  2223
            "
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2224
            "/ self unselect. self cursorBacktab.
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2225
            self unselect. self cursorTab. 
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2226
            ^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
  2227
        ].
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2228
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2229
        "
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2230
         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
  2231
         (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
  2232
         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
  2233
         complained ....
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2234
        "
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2235
        "/ self unselect. self cursorTab. ^self
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2236
        self unselect. self insertTabAtCursor. 
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2237
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2238
    ].
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
  2239
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2240
    (key == #BackSpace) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2241
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2242
        "/ 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
  2243
        "/ 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
  2244
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2245
        "/ 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
  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
        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
  2248
            ^ 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
  2249
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2250
        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
  2251
        self deleteCharBeforeCursor. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2252
    ].
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
  2253
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2254
    (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
  2255
        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
  2256
            ^ 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
  2257
        ].
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 deleteCharAtCursor. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2260
    ].
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
  2261
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2262
    (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
  2263
        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
  2264
        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
  2265
            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
  2266
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2267
            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
  2268
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2269
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2270
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2271
    (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
  2272
        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
  2273
        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
  2274
            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
  2275
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2276
            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
  2277
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2278
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2279
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2280
    ((key == #Escape)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2281
    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
  2282
        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
  2283
        self unselect. self selectCursorLineFromBeginning. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2284
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2285
    (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
  2286
        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
  2287
        self unselect. self selectCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2288
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2289
    (key == #ExpandSelectionByLine)    ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2290
"/        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
  2291
        self selectExpandCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2292
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2293
    (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
  2294
        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
  2295
        self unselect. self deleteCursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2296
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2297
    (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
  2298
        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
  2299
        self unselect. self insertLine:nil before:cursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2300
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2301
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2302
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2303
    "Modified: 7.2.1996 / 19:26:28 / cg"
121
claus
parents: 118
diff changeset
  2304
!
claus
parents: 118
diff changeset
  2305
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2306
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2307
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2308
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2309
    super mapped.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2310
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2311
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2312
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2313
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2314
pointerEnter:state x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2315
    (windowGroup isNil or:[windowGroup focusView isNil]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2316
	hasKeyboardFocus := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2317
	cursorShown ifTrue: [self drawCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2318
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2319
    super pointerEnter:state x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2320
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2321
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2322
pointerLeave:state
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2323
    (windowGroup isNil or:[windowGroup focusView isNil]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2324
	hasKeyboardFocus := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2325
	cursorShown ifTrue: [self drawCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2326
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2327
    super pointerLeave:state
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2328
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2329
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
  2330
showFocus:explicit
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2331
    hasKeyboardFocus := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2332
    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
  2333
    super showFocus:explicit
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2334
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2335
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
  2336
showNoFocus:explicit
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2337
    hasKeyboardFocus := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2338
    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
  2339
    super showNoFocus:explicit
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2340
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2341
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2342
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2343
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2344
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2345
    |cv|
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
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2348
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2349
    cv notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2350
	self makeLineVisible:cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2351
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2352
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2353
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2354
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2355
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2356
indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2357
    "indent selected line-range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2358
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2359
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2360
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2361
    selectionStartLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2362
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2363
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2364
    (selectionEndCol == 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2365
	end := end - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2366
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2367
    self unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2368
    self indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2369
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2370
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2371
indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2372
    "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
  2373
     last non-empty line before start, and change the indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2374
     of the line based on that indent."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2375
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2376
    |leftStart lnr delta d line spaces|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2377
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2378
    "find a line to base indent on..."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2379
    leftStart := 0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2380
    lnr := start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2381
    [(leftStart == 0) and:[lnr ~~ 1]] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2382
	lnr := lnr - 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2383
	leftStart := self leftIndentOfLine:lnr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2384
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2385
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2386
    (leftStart == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2387
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2388
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2389
    (delta == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2390
    (delta > 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2391
	spaces := String new:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2392
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2393
    start to:end do:[:lineNr |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2394
	line := self listAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2395
	line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2396
	    line isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2397
		list at:lineNr put:nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2398
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2399
		(delta > 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2400
		    line := spaces , line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2401
		    widthOfWidestLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2402
			widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2403
		    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2404
		] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2405
		    "check if deletion is ok"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2406
		    d := delta negated + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2407
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2408
		    line size > d ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2409
			(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2410
			    line := line copyFrom:d
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2411
			]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2412
		    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2413
		    widthOfWidestLine := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2414
		].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2415
		list at:lineNr put:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2416
		self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2417
	    ]
121
claus
parents: 118
diff changeset
  2418
	]
claus
parents: 118
diff changeset
  2419
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2420
    self redrawFromLine:start to:end
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2421
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2422
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2423
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2424
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2425
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2426
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2427
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2428
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2429
    self enableEnterLeaveEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2430
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2431
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2432
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2433
    "initialize style specific stuff"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2434
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2435
    super initStyle.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2436
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2437
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2438
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2439
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2440
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2441
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2442
    cursorType := DefaultCursorType.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2443
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2444
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2445
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2446
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2447
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2448
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2449
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2450
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2451
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2452
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2453
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2454
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2455
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2456
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2457
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2458
    cursorCol := 1.
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2459
    modifiedChannel := false asValue.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2460
    showMatchingParenthesis := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2461
    hasKeyboardFocus := false. "/ true.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  2462
    tabMeansNextField := false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2463
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2464
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2465
realize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2466
    "make the view visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2467
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2468
    super realize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2469
    cursorFgColor := cursorFgColor on:device.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2470
    cursorBgColor := cursorBgColor on:device.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2471
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2472
121
claus
parents: 118
diff changeset
  2473
!EditTextView methodsFor:'menu actions'!
claus
parents: 118
diff changeset
  2474
claus
parents: 118
diff changeset
  2475
cut
claus
parents: 118
diff changeset
  2476
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  2477
claus
parents: 118
diff changeset
  2478
    |line col history sel|
claus
parents: 118
diff changeset
  2479
claus
parents: 118
diff changeset
  2480
    sel := self selection.
claus
parents: 118
diff changeset
  2481
    sel notNil ifTrue:[
claus
parents: 118
diff changeset
  2482
	lastString := sel.
claus
parents: 118
diff changeset
  2483
	line := selectionStartLine.
claus
parents: 118
diff changeset
  2484
	col := selectionStartCol.
claus
parents: 118
diff changeset
  2485
	undoAction := [self insertLines:lastString atLine:line col:col].
claus
parents: 118
diff changeset
  2486
claus
parents: 118
diff changeset
  2487
	"
claus
parents: 118
diff changeset
  2488
	 remember in CopyBuffer
claus
parents: 118
diff changeset
  2489
	"
claus
parents: 118
diff changeset
  2490
	self setTextSelection:lastString.
claus
parents: 118
diff changeset
  2491
claus
parents: 118
diff changeset
  2492
	"
claus
parents: 118
diff changeset
  2493
	 append to DeleteHistory (if there is one)
claus
parents: 118
diff changeset
  2494
	"
claus
parents: 118
diff changeset
  2495
	history := Smalltalk at:#DeleteHistory.
claus
parents: 118
diff changeset
  2496
	history notNil ifTrue:[
claus
parents: 118
diff changeset
  2497
	    history addAll:(lastString asStringCollection).
claus
parents: 118
diff changeset
  2498
	    history size > 1000 ifTrue:[
claus
parents: 118
diff changeset
  2499
		history := history copyFrom:(history size - 1000)
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
  2500
	    ].
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
  2501
	].
121
claus
parents: 118
diff changeset
  2502
claus
parents: 118
diff changeset
  2503
	"
claus
parents: 118
diff changeset
  2504
	 now, delete it
claus
parents: 118
diff changeset
  2505
	"
claus
parents: 118
diff changeset
  2506
	self deleteSelection.
claus
parents: 118
diff changeset
  2507
	lastReplacement := nil
claus
parents: 118
diff changeset
  2508
    ] ifFalse:[
claus
parents: 118
diff changeset
  2509
	"
claus
parents: 118
diff changeset
  2510
	 a cut without selection will search&cut again
claus
parents: 118
diff changeset
  2511
	"
claus
parents: 118
diff changeset
  2512
	self again
claus
parents: 118
diff changeset
  2513
    ]
claus
parents: 118
diff changeset
  2514
!
claus
parents: 118
diff changeset
  2515
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2516
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2517
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2518
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2519
    cursorLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2520
	^ cursorLine
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 defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2523
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2524
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2525
editMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2526
    "return the views middleButtonMenu"
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2527
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2528
    |labels selectors m sub shortKeys|
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2529
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2530
    self sensor ctrlDown ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2531
        labels := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2532
                        'again (for all)'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2533
                   ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2534
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2535
        selectors := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2536
                        multipleAgain
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2537
                       ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2538
    ] ifFalse:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2539
        labels := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2540
"/                      'undo'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2541
                        'again'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2542
                        '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2543
                        'copy'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2544
                        'cut'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2545
                        'paste'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2546
                        '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2547
                        'accept'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2548
                        '='
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2549
                        'others'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2550
                   ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2551
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2552
        selectors := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2553
"/                      undo
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2554
                        again
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2555
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2556
                        copySelection
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2557
                        cut
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2558
                        pasteOrReplace
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2559
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2560
                        accept
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2561
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2562
                        others
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2563
                       ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2564
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2565
        shortKeys := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2566
"/                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2567
                        #Again 
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2568
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2569
                        #Copy
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2570
                        #Cut
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2571
                        #Paste
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2572
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2573
                        #Accept 
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2574
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2575
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2576
                      ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2577
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2578
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2579
    m := PopUpMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2580
            labels:(resources array:labels)
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2581
            selectors:selectors
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2582
            accelerators:shortKeys.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2583
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2584
    labels := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2585
                    'search ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2586
                    'goto ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2587
                    '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2588
                    'font ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2589
                    '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2590
                    'indent'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2591
                    '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2592
                    'save as ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2593
                    'print'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2594
                ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2595
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2596
   selectors := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2597
                     search
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2598
                     gotoLine
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2599
                     nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2600
                     changeFont
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2601
                     nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2602
                     indent
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2603
                     nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2604
                     save
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2605
                     print
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2606
                    ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2607
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2608
    shortKeys := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2609
                      #Find
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2610
                      #GotoLine
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2611
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2612
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2613
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2614
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2615
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2616
                      #SaveAs
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2617
                      #Print).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2618
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2619
    sub := PopUpMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2620
                labels:(resources array:labels)
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2621
                selectors:selectors
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2622
                accelerators:shortKeys
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2623
                receiver:model.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2624
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2625
    m subMenuAt:#others put:sub.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2626
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2627
    readOnly ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2628
        m disable:#paste
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2629
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2630
    self hasSelection not ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2631
        m disable:#copySelection.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2632
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2633
    (self hasSelection not or:[readOnly]) ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2634
        m disable:#cut.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2635
        sub disable:#indent.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2636
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2637
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2638
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2639
    "Modified: 28.2.1996 / 19:00:12 / cg"
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2640
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  2641
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2642
paste
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2643
    "paste copybuffer; if there is a selection, unselect first.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2644
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2645
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2646
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2647
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2648
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2649
    self unselect.  
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2650
    sel notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2651
	self paste:sel.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2652
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2653
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2654
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2655
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2656
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2657
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2658
    |s startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2659
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2660
    someText notNil ifTrue:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2661
        s := someText.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2662
        s isString ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2663
            s := s asStringCollection
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2664
        ] ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2665
            (s isKindOf:StringCollection) ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2666
                self warn:'selection not convertable to Text'.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2667
                ^ self
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2668
            ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2669
        ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2670
        startLine := cursorLine.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2671
        startCol := cursorCol.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2672
        self insertLines:(s withTabsExpanded) withCr:false.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2673
        self selectFromLine:startLine col:startCol
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2674
                     toLine:cursorLine col:(cursorCol - 1).
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2675
        typeOfSelection := #paste.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2676
        undoAction := [self cut].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2677
    ]
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2678
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2679
    "Modified: 14.2.1996 / 11:14:14 / stefan"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2680
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2681
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2682
pasteOrReplace
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2683
    "paste copybuffer; if there is a selection, replace it.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2684
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2685
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2686
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2687
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2688
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2689
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2690
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2691
    self pasteOrReplace:sel.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2692
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2693
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2694
pasteOrReplace:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2695
    "paste copybuffer; if there is a selection, replace it.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2696
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2697
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2698
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2699
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2700
    ((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2701
	^ self replace:someText
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
    self paste:someText.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2704
!
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
replace
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2707
    "replace selection by copybuffer"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2708
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2709
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2710
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2711
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2712
    sel notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2713
	self replace:sel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2714
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2715
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2716
121
claus
parents: 118
diff changeset
  2717
replace:someText
claus
parents: 118
diff changeset
  2718
    "replace selection by someText"
claus
parents: 118
diff changeset
  2719
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2720
    |selected selectedString| 
121
claus
parents: 118
diff changeset
  2721
claus
parents: 118
diff changeset
  2722
    selected := self selection.
claus
parents: 118
diff changeset
  2723
    selected isNil ifTrue:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2724
        ^ self paste:someText
121
claus
parents: 118
diff changeset
  2725
    ].
claus
parents: 118
diff changeset
  2726
    self deleteSelection.
claus
parents: 118
diff changeset
  2727
claus
parents: 118
diff changeset
  2728
    "take care, if we replace a selection without space by a word selected
claus
parents: 118
diff changeset
  2729
     with one - in this case we usually do not want the space.
claus
parents: 118
diff changeset
  2730
     But, if we replace a word-selected selection by something without a
claus
parents: 118
diff changeset
  2731
     space, we DO want the space added."
claus
parents: 118
diff changeset
  2732
claus
parents: 118
diff changeset
  2733
    selected size == 1 ifTrue:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2734
        selectedString := selected at:1.
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  2735
    ].
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  2736
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2737
    someText size == 1 ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2738
        |cutOffSpace addSpace replacement replacementString|
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2739
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2740
        cutOffSpace := false.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2741
        addSpace := false.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2742
        replacement := someText copy.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2743
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2744
        selectedString notNil ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2745
            ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2746
               "selection has no space"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2747
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2748
                ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2749
                    cutOffSpace := true
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2750
                ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2751
            ] ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2752
                addSpace := true
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2753
            ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2754
        ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2755
        replacementString := replacement at:1.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2756
        cutOffSpace ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2757
            (replacementString startsWith:' ') ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2758
                replacementString := replacementString withoutSpaces
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2759
            ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2760
        ] ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2761
            selectStyle == #wordLeft ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2762
                "want a space at left"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2763
                (replacementString startsWith:' ') ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2764
                    replacementString := replacementString withoutSpaces.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2765
                    replacementString := ' ' , replacementString
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2766
                ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2767
            ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2768
            selectStyle == #wordRight ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2769
                "want a space at right"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2770
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2771
                (replacementString endsWith:' ') ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2772
                    replacementString := replacementString withoutSpaces.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2773
                    replacementString := replacementString , ' '
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2774
                ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2775
            ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2776
        ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2777
        replacement at:1 put: replacementString.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2778
        self paste:replacement.
121
claus
parents: 118
diff changeset
  2779
    ] ifFalse:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2780
        self paste:someText
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  2781
    ].
121
claus
parents: 118
diff changeset
  2782
    lastString := selectedString.
claus
parents: 118
diff changeset
  2783
    lastReplacement := someText
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2784
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  2785
    "Modified: 14.2.1996 / 10:37:02 / stefan"
121
claus
parents: 118
diff changeset
  2786
!
claus
parents: 118
diff changeset
  2787
claus
parents: 118
diff changeset
  2788
showDeleted
claus
parents: 118
diff changeset
  2789
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  2790
claus
parents: 118
diff changeset
  2791
    |v|
claus
parents: 118
diff changeset
  2792
claus
parents: 118
diff changeset
  2793
    v := EditTextView openWith:(Smalltalk at:#DeleteHistory).
claus
parents: 118
diff changeset
  2794
    v readOnly.
claus
parents: 118
diff changeset
  2795
    v topView label:'deleted text'.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2796
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2797
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2798
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2799
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2800
checkModificationsAllowed
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2801
    readOnly ifTrue: [
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2802
	exceptionBlock isNil ifTrue:[
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2803
	    ^ false
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2804
	].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2805
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2806
	(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
  2807
	    ^ false
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2808
	]
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2809
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2810
    ^ true
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2811
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2812
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2813
textChanged
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2814
    "triggered whenever text has been edited (not to confuse with
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2815
     contentsChanged, which is triggered when the size has changed, and
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2816
     is used to notify scrollers, other views etc.)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2817
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2818
    super contentsChanged.
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2819
    modifiedChannel value:true.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2820
    contentsWasSaved := false
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2821
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2822
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2823
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2824
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2825
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  2826
    "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
  2827
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2828
    "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
  2829
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  2830
    ^ readOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2831
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2832
    "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
  2833
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2834
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2835
widthOfContents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2836
    "return the width of the contents in pixels
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2837
     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
  2838
     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
  2839
     line (and possibly see the cursor behind the line)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2840
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2841
    |w|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2842
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2843
    w := super widthOfContents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2844
    ^ w + (font widthOf:' ')
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2845
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2846
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2847
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2848
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2849
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2850
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2851
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2852
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2853
	cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2854
	    (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2855
		self drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2856
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2857
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2858
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2859
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2860
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2861
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2862
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2863
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2864
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2865
	(visLine == cursorVisibleLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2866
	    self drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2867
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2868
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2869
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2870
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2871
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2872
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2873
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2874
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2875
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2876
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2877
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2878
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2879
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2880
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2881
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2882
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2883
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2884
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2885
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2886
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2887
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2888
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2889
	(visLine == cursorVisibleLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2890
	    (colNr == cursorCol) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2891
		self drawCursorCharacter.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2892
		^ self
118
claus
parents: 105
diff changeset
  2893
	    ]
claus
parents: 105
diff changeset
  2894
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2895
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2896
    super redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2897
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2898
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2899
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2900
    "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
  2901
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2902
    super redrawVisibleLine:visLine from:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2903
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2904
!
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
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2907
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2908
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2909
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2910
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2911
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2912
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2913
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2914
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2915
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2916
    "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
  2917
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2918
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2919
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2920
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2921
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2922
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2923
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2924
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2925
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2926
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2927
    "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
  2928
     within the real text  "
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
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2931
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2932
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2933
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2934
    self cursorVisibleLine:prevCursorLine col:cursorCol
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2937
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2938
    "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
  2939
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2940
    super originChanged:delta.
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
     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
  2943
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2944
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2945
    prevCursorState ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2946
	self showCursor
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
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2949
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2950
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2951
    "sent before scrolling - have to hide the cursor"
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
    prevCursorState := cursorShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2954
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2955
	self hideCursor
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
!
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
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2960
    "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
  2961
     within the real text  "
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
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2964
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2965
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2966
    super pageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2967
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2968
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2969
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2970
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2971
    "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
  2972
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2973
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2974
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2975
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2976
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2977
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2978
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2979
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2980
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2981
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2982
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2983
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2984
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2985
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2986
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2987
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2988
    cursorLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2989
    selectionStartLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2990
	startLine := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2991
	startCol := selectionStartCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2992
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2993
	startLine := cursorLine min:list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2994
	startCol := cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2995
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2996
    self searchBackwardFor:pattern startingAtLine:startLine col:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2997
    ifFound:[:line :col |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2998
	self cursorLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2999
	self showMatch:pattern atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3000
"/        self makeLineVisible:cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3001
    ] ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3002
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3003
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3004
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3005
    "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
  3006
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3007
    self searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3008
			      ifFound:[:line :col | 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3009
					  self selectFromLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3010
						       toLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3011
				      ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3012
			   ifNotFound:[self showNotFound]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3013
			      onError:[device beep]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3014
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3015
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3016
searchForMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3017
    "search for a matching parenthesis starting at cursor position. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3018
     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
  3019
     backwards if its a closing parenthesis.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3020
     Positions the cursor if found, peeps if not"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3021
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3022
     self searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3023
			       ifFound:[:line :col | self cursorLine:line col:col]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3024
			    ifNotFound:[self showNotFound]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3025
			       onError:[device beep]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3026
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3027
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3028
searchFwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3029
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3030
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3031
    |startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3032
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3033
    "/ 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
  3034
    "/ 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
  3035
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3036
    self hasSelection ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3037
	(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3038
	    startCol := 0
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3039
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3040
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3041
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3042
    self searchFwd:pattern startingAtLine:cursorLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3043
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3044
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3045
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3046
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3047
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3048
    cursorLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3049
    self searchForwardFor:pattern startingAtLine:startLine col:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3050
    ifFound:[:line :col |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3051
	self cursorLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3052
	self showMatch:pattern atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3053
"/        self makeLineVisible:cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3054
    ] ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3055
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3056
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3057
setSearchPattern
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3058
    "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
  3059
     cursor to start of pattern"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3060
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3061
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3062
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3063
    "if last operation was a replcae, set pattern to last
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3064
     original string (for search after again)"
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
    (lastString notNil and:[lastReplacement notNil]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3067
	searchPattern := lastString asString withoutSeparators.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3068
	^ self
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
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3072
    sel notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3073
	self cursorLine:selectionStartLine col:selectionStartCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3074
	searchPattern := sel asString withoutSeparators
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3075
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3076
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3077
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3078
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3079
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3080
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3081
    "select the whole text.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3082
     redefined to send super selectFrom... since we dont want the
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3083
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3084
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3085
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3086
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3087
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3088
	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
  3089
	typeOfSelection := nil
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
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3092
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3093
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3094
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3095
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3096
    self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3097
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3098
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3099
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3100
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3101
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3102
    self selectFromLine:cursorLine col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3103
		 toLine:cursorLine col:cursorCol
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
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3107
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3108
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3109
    selectionStartLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3110
	self selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3111
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3112
	self selectFromLine:selectionStartLine col:selectionStartCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3113
		     toLine:cursorLine+1 col:0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3114
	self makeLineVisible:selectionEndLine
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
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3119
    "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
  3120
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3121
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3122
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3123
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3124
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3125
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3126
	cursorCol == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3127
	    col := 0
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3128
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3129
	    col := cursorCol - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3130
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3131
	super selectFromLine:1 col:1 toLine:cursorLine col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3132
	typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3133
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3134
!
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
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3137
    "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
  3138
     for easier editing. Also typeOfSelection is nilled here."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3139
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3140
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3141
    self cursorLine:selectionEndLine col:(selectionEndCol + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3142
    typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3143
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3144
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3145
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3146
    "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
  3147
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3148
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3149
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3150
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3151
	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
  3152
	typeOfSelection := nil
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
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3155
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3156
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3157
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3158
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3159
    self selectWordAtLine:cursorLine col:cursorCol
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3162
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3163
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3164
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3165
    |wasOn|
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
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3168
    super unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3169
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3170
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3171
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3172
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3173
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3174
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3175
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3176
     If current selection is not last string, search forward to
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3177
     next occurence of it before repeating the last operation."
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3178
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3179
    |s l c sel|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3180
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3181
    lastString notNil ifTrue:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3182
	s := lastString asString.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3183
	"remove final cr"
131
claus
parents: 130
diff changeset
  3184
	s := s copyWithoutLast:1 "copyTo:(s size - 1)".
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3185
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3186
	sel := self selection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3187
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3188
	"if we are already there (after a find), ommit search"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3189
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3190
	(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3191
	    undoAction := [self insertLines:lastString atLine:cursorLine col:cursorCol].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3192
	    l := selectionStartLine "cursorLine". 
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3193
	    c := selectionStartCol "cursorCol".
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3194
	    self deleteSelection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3195
	    lastReplacement notNil ifTrue:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3196
		self insertLines:lastReplacement asStringCollection withCr:false.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3197
		self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3198
	    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3199
	    ^ true
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3200
	].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3201
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3202
	self searchForwardFor:s startingAtLine:cursorLine col:cursorCol 
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3203
	    ifFound:
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3204
		[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3205
		    :line :col |
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3206
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3207
		    self selectFromLine:line col:col
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3208
				 toLine:line col:(col + s size - 1).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3209
		    self makeLineVisible:line.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3210
		    undoAction := [self insertLines:lastString atLine:line col:col].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3211
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3212
		    self deleteSelection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3213
		    lastReplacement notNil ifTrue:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3214
			self insertLines:lastReplacement asStringCollection withCr:false.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3215
			self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3216
		    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3217
		    ^ true
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3218
		] 
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3219
	   ifAbsent:
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3220
		[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3221
		    self showNotFound.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3222
		    ^ false
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3223
		]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3224
    ]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3225
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3226
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3227
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3228
    "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
  3229
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3230
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3231
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3232
121
claus
parents: 118
diff changeset
  3233
undo
claus
parents: 118
diff changeset
  3234
    "currently not implemented"
claus
parents: 118
diff changeset
  3235
claus
parents: 118
diff changeset
  3236
    undoAction notNil ifTrue:[
claus
parents: 118
diff changeset
  3237
	undoAction value
claus
parents: 118
diff changeset
  3238
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3239
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3240
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3241
!EditTextView class methodsFor:'documentation'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3242
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3243
version
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
  3244
    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ETxtView.st,v 1.51 1996-03-01 12:56:59 cg Exp $'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3245
! !