EditTextView.st
author Claus Gittinger <cg@exept.de>
Mon, 24 Sep 2001 10:04:22 +0200
changeset 2406 aeabb4ccf07c
parent 2404 9dedc6b66762
child 2416 56acdd9e31b5
permissions -rw-r--r--
*** empty log message ***
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
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
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
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
    13
"{ Package: 'stx:libwidg' }"
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
    14
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    15
TextView subclass:#EditTextView
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    16
	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    17
		prevCursorState readOnly modifiedChannel fixedSize exceptionBlock
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    18
		cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    19
		cursorTypeNoFocus undoAction typeOfSelection lastString
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    20
		lastReplacement lastAction replacing showMatchingParenthesis
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    21
		hasKeyboardFocus acceptAction lockUpdates tabMeansNextField
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    22
		autoIndent insertMode trimBlankLines wordWrap
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    23
		replacementWordSelectStyle acceptChannel acceptEnabled st80Mode
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    24
		disableIfInvisible cursorMovementWhenUpdating learnMode
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    25
		learnedMacro'
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    26
	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    27
		DefaultCursorType DefaultCursorNoFocusForegroundColor ST80Mode
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    28
		DefaultCursorTypeNoFocus'
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    29
	poolDictionaries:''
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
    30
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    31
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    32
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
    33
!EditTextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    34
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    35
copyright
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    36
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    37
 COPYRIGHT (c) 1989 by Claus Gittinger
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
    38
              All Rights Reserved
33
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
 This software is furnished under a license and may be used
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    41
 only in accordance with the terms of that license and with the
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    42
 inclusion of the above copyright notice.   This software may not
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    43
 be provided or otherwise made available to, or used by, any
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    44
 other person.  No title to or ownership of the software is
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    45
 hereby transferred.
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    46
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    47
!
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    48
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    49
documentation
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    50
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    51
    a view for editable text - adds editing functionality to TextView
125
claus
parents: 123
diff changeset
    52
    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
    53
    acceptAction to be performed for accept
125
claus
parents: 123
diff changeset
    54
claus
parents: 123
diff changeset
    55
    If used with a model, this is informed by sending it a changeMsg with
claus
parents: 123
diff changeset
    56
    the current contents as argument.
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    57
    (however, it is possible to define both changeMsg and acceptAction)
125
claus
parents: 123
diff changeset
    58
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
    59
    Please read the historic notice in the ListView class.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    60
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    61
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    62
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    63
        cursorLine              <Number>        line where cursor sits (1..)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    64
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    65
        cursorVisibleLine       <Number>        visible line where cursor sits (1..nLinesShown)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    66
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    67
        cursorCol               <Number>        col where cursor sits (1..)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    68
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    69
        cursorShown             <Boolean>       true, if cursor is currently shown
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    70
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    71
        readOnly                <Boolean>       true, if text may not be edited
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    72
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    73
        modifiedChannel         <ValueHolder>   holding true, if text has been modified.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    74
                                                cleared on accept.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    75
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    76
        acceptChannel           <ValueHolder>   holding true, if text has been accepted.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    77
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    78
        fixedSize               <Boolean>       true, if no lines may be added/removed
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    79
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    80
        exceptionBlock          <Block>         block to be evaluated when readonly text is about to be modified
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    81
                                                if it returns true, the modification will be done anyway.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    82
                                                if it returns anything else, the modification is not done.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    83
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    84
        cursorFgColor           <Color>         color used for cursor drawing
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    85
        cursorBgColor           <Color>         color used for cursor drawing
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    86
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    87
        cursorType              <Symbol>        how the cursor is drawn; currently implemented
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    88
                                                are #block (solid-block cursor), #ibeam
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    89
                                                (vertical bar at insertion point) 
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    90
                                                and #caret (caret below insertion-point)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    91
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    92
        cursorTypeNoFocus       <Symbol>        like above, if view has no focus
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    93
                                                nil means: hide the cursor.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    94
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    95
        undoAction              <Block>         block which undoes last cut, paste or replace
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    96
                                                (not yet fully implemented)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    97
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    98
        typeOfSelection         <Symbol>        #paste, if selection created by paste, nil otherwise
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    99
                                                this affects the next keyPress: if #paste it does not
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   100
                                                replace; otherwise it replaces the selection.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   101
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   102
        lastCut                 <String>        last cut or replaced string
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   103
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   104
        lastReplacement         <String>        last replacement
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   105
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   106
        replacing               <Boolean>       true if entered characters replace last selection
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   107
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   108
        showMatchingParenthesis <Boolean>       if true, shows matching parenthesis
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   109
                                                when entering one; this is the default.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   110
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   111
        hasKeyboardFocus        <Boolean>       true if this view has the focus
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   112
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   113
        acceptAction            <Block>         accept action - evaluated passing the contents as 
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   114
                                                argument 
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   115
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   116
        tabMeansNextField       <Boolean>       if true, Tab is ignored as input and shifts keyboard
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   117
                                                focus to the next field. For editTextViews, this is false
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   118
                                                by default (i.e. tabs can be entered into the text).
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   119
                                                For some subclasses (inputFields), this may be true.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   120
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   121
        trimBlankLines          <Boolean>       if true, trailing blanks are
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   122
                                                removed when editing.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   123
                                                Default is true.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   124
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   125
        wordWrap                <Boolean>       Currently not used.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   126
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   127
        lockUpdates             <Boolean>       internal, private
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   128
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   129
        prevCursorState         <Boolean>       temporary, private
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   130
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   131
        cursorMovementWhenUpdating
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   132
                                <Symbol>        defines where the cursor is to be positioned if the
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   133
                                                model changes its value by some outside activity
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   134
                                                (i.e. not by user input into the field).
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   135
                                                Can be one of:
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   136
                                                    #keep / nil     -> stay where it was
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   137
                                                    #endOfText      -> cursor to the end
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   138
                                                    #endOfLine      -> stay in the line, but move to end
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   139
                                                    #beginOfText    -> cursor to the beginning
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   140
                                                    #beginOfLine    -> stay in the line, but move to begin
2131
858209ba8509 cursor movement default
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   141
                                                The default is #beginOfText
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   142
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   143
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   144
    class variables:
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   145
        ST80Mode                <Boolean>       if true, cursor positioning is
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   146
                                                done as in vi or ST80; i.e.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   147
                                                wysiwyg mode is somewhat relaxed,
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   148
                                                in that the cursor cannot be
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   149
                                                positioned behind a lines end.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   150
                                                This is not yet completely implemented.
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   151
    used globals:
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   152
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   153
        DeleteHistory           <Text>          last 1000 lines of deleted text
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   154
                                                (but only if this variable exists already)
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   155
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   156
    [styleSheet parameters:]
121
claus
parents: 118
diff changeset
   157
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   158
        textCursorForegroundColor <Color>       cursor fg color; default: text background
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   159
        textCursorBackgroundColor <Color>       cursor bg color; default: text foreground
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   160
        textCursorNoFocusForegroundColor 
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   161
                                  <Color>       cursor fg color if no focus; default: cursor fg color
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   162
        textCursorType            <Symbol>      cursor type; default:  #block
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   163
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   164
    [author:]
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   165
        Claus Gittinger
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   166
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   167
    [see also:]
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   168
        CodeView Workspace TextView ListView
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   169
        EditField
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   170
"
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   171
!
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
examples
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
  non MVC operation:
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
    basic setup:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   178
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   179
        |top textView|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   180
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   181
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   182
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   183
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   184
        textView := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   185
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   186
        top addSubView:textView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   187
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   188
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   189
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   190
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   191
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   192
297
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
    with vertical scrollbar:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   195
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   196
        |top scrollView textView|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   197
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   198
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   199
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   200
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   201
        scrollView := ScrollableView for:EditTextView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   202
        textView := scrollView scrolledView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   203
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   204
        top addSubView:scrollView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   205
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   206
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   207
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   208
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   209
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   210
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   211
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   212
    with horizontal & vertical scrollbars:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   213
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   214
        |top scrollView textView|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   215
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   216
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   217
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   218
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   219
        scrollView := HVScrollableView for:EditTextView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   220
        textView := scrollView scrolledView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   221
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   222
        top addSubView:scrollView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   223
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   224
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   225
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   226
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   227
                                                                        [exEnd]
297
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
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   230
    set the action for accept:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   231
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   232
        |top textView|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   233
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   234
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   235
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   236
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   237
        textView := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   238
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   239
        top addSubView:textView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   240
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   241
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   242
        textView acceptAction:[:contents |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   243
                                Transcript showCR:'will not overwrite the file with:'.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   244
                                Transcript showCR:contents asString
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   245
                              ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   246
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   247
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   248
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   249
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   250
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   251
    non-string (text) items:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   252
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   253
        |top textView list|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   254
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   255
        list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   256
        1 to:list size by:2 do:[:nr |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   257
            list at:nr put:(Text string:(list at:nr)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   258
                                 emphasis:(Array with:#bold with:(#color->Color red)))
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   259
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   260
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   261
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   262
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   263
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   264
        textView := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   265
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   266
        top addSubView:textView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   267
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   268
        textView contents:list.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   269
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   270
                                                                        [exEnd]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   271
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   272
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   273
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   274
  MVC operation:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   275
    (the examples model here is a plug simulating a real model;
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   276
     real world applications would not use a plug ..)
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   277
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   278
        |top textView model|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   279
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   280
        model := Plug new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   281
        model respondTo:#accepted:
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   282
                   with:[:newContents | 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   283
                                Transcript showCR:'will not overwrite the file with:'.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   284
                                Transcript showCR:newContents asString
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   285
                        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   286
        model respondTo:#getList
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   287
                   with:['/etc/hosts' asFilename contentsOfEntireFile].
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   288
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   289
        
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   290
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   291
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   292
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   293
        textView := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   294
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   295
        top addSubView:textView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   296
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   297
        textView listMessage:#getList;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   298
                 model:model;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   299
                 changeMessage:#accepted:;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   300
                 aspect:#list.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   301
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   302
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   303
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   304
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   305
    two textViews on the same model:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   306
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   307
        |top1 textView1 top2 textView2 model currentContents|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   308
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   309
        model := Plug new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   310
        model respondTo:#accepted:
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   311
                   with:[:newContents |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   312
                                Transcript showCR:'accepted:'.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   313
                                Transcript showCR:newContents asString.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   314
                                currentContents := newContents.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   315
                                model changed:#contents
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   316
                        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   317
        model respondTo:#getList
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   318
                   with:[Transcript showCR:'query'.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   319
                         currentContents].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   320
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   321
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   322
        top1 := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   323
        top1 extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   324
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   325
        textView1 := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   326
        textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   327
        top1 addSubView:textView1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   328
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   329
        textView1 listMessage:#getList;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   330
                  model:model;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   331
                  aspect:#contents;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   332
                  changeMessage:#accepted:.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   333
        top1 open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   334
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   335
        top2 := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   336
        top2 extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   337
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   338
        textView2 := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   339
        textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   340
        top2 addSubView:textView2.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   341
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   342
        textView2 listMessage:#getList;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   343
                  model:model;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   344
                  aspect:#contents;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   345
                  changeMessage:#accepted:.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   346
        top2 open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   347
                                                                        [exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   348
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   349
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   350
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   351
!EditTextView class methodsFor:'defaults'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   352
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   353
st80Mode
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   354
    "return true, if the st80 editing mode is turned on.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   355
     This setting affects the behavior of the cursor, when positioned
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   356
     behond the end of a line or the end of the text.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   357
     The default is initialized from the viewStyle."
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   358
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   359
    ^ ST80Mode
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   360
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   361
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   362
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   363
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   364
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   365
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   366
    "Modified: / 16.1.1998 / 22:54:57 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   367
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   368
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   369
st80Mode:aBoolean
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   370
    "turns on/off st80 behavior, where the cursor cannot be positioned
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   371
     behond the end of a line or the last line"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   372
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   373
    ST80Mode := aBoolean.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   374
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   375
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   376
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   377
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   378
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   379
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   380
    "Modified: / 16.1.1998 / 22:55:19 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   381
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   382
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   383
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   384
    "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
   385
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   386
    <resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor'
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   387
                       #'textCursor.noFocusForegroundColor' 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   388
                       #'textCursor.type' #'textCursor.typeNoFocus'
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   389
                       #'editText.st80Mode')>
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   390
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   391
    DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   392
    DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   393
    DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   394
    DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   395
    DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'.
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   396
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   397
    ST80Mode := StyleSheet at:'editText.st80Mode' default:false.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   398
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   399
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   400
     self updateStyleCache
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   401
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   402
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   403
    "Modified: / 20.5.1998 / 04:27:41 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   404
! !
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   405
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   406
!EditTextView methodsFor:'Compatibility - ST80'!
1552
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   407
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   408
autoAccept:aBoolean
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   409
    "ignored for now"
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   410
2019
b6b078ea3bbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
   411
    "Created: / 5.6.1998 / 15:30:32 / cg "
1585
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   412
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   413
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   414
continuousAccept:aBoolean
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   415
    "ignored for now"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   416
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   417
    "Created: / 19.6.1998 / 00:03:49 / cg"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   418
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   419
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   420
cutSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   421
    self cut
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   422
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   423
    "Created: / 31.10.1997 / 03:29:50 / cg"
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   424
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   425
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   426
deselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   427
    "remove the selection"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   428
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   429
    ^ self unselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   430
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   431
    "Created: / 19.6.1998 / 02:41:54 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   432
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   433
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   434
enabled:aBoolean
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   435
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   436
    self readOnly:aBoolean not
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   437
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   438
    "Created: / 30.3.1999 / 15:10:23 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   439
    "Modified: / 30.3.1999 / 15:10:53 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   440
!
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   441
1732
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   442
find:pattern
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   443
    self searchFwd:pattern ifAbsent:nil
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   444
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   445
    "Created: / 29.1.1999 / 19:09:42 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   446
    "Modified: / 29.1.1999 / 19:10:12 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   447
!
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   448
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   449
insert:aString at:aCharacterPosition
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   450
    "insert a string at aCharacterPosition."
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   451
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   452
    |line col|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   453
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   454
    line := self lineOfCharacterPosition:aCharacterPosition.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   455
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   456
    col < 1 ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   457
        col := 1
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   458
    ].
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   459
    self insertString:aString atLine:line col:col.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   460
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   461
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   462
     |top v|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   463
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   464
     top := StandardSystemView new.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   465
     top extent:300@300.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   466
     v := EditTextView origin:0.0@0.0 corner:1.0@1.0 in:top.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   467
     top openAndWait.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   468
     v contents:'1234567890\1234567890\1234567890\' withCRs.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   469
     v insert:'<- hello there' at:5.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   470
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   471
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   472
    "Modified: / 5.4.1998 / 17:20:08 / cg"
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   473
!
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   474
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   475
insertAndSelect:aString at:aCharacterPosition
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   476
    "insert a selected string at aCharacterPosition."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   477
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   478
    |line col|
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
    line := self lineOfCharacterPosition:aCharacterPosition.
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   481
    col := (aCharacterPosition - (self characterPositionOfLine:line col:1) + 1) max:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   482
    self insertString:aString atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   483
    self selectFromLine:line col:col toLine:line col:col + aString size - 1
125
claus
parents: 123
diff changeset
   484
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   485
     |v|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   486
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   487
     v := EditTextView new openAndWait.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   488
     v contents:'1234567890\1234567890\1234567890\' withCRs.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   489
     v insertAndSelect:'<- hello there' at:5.
125
claus
parents: 123
diff changeset
   490
    "
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   491
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   492
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   493
pasteSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   494
    self paste
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   495
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   496
    "Created: / 31.10.1997 / 03:28:53 / cg"
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   497
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   498
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   499
replaceSelectionWith:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   500
    ^ self replaceSelectionBy:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   501
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   502
    "Created: / 19.6.1998 / 02:42:32 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   503
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   504
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   505
selectAt:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   506
    "move the cursor before cursorPosition."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   507
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   508
    self cursorToCharacterPosition:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   509
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   510
    "Modified: / 19.6.1998 / 02:41:28 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   511
    "Created: / 19.6.1998 / 02:43:39 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   512
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   513
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   514
selectFrom:startPos to:endPos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   515
    "change the selection given two aCharacterPositions."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   516
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   517
    |line1 col1 line2 col2|
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   518
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   519
    startPos > endPos ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   520
        ^ self unselect
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   521
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   522
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   523
    line1 := self lineOfCharacterPosition:startPos.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   524
    col1 := startPos - (self characterPositionOfLine:line1 col:1) + 1.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   525
    col1 < 1 ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   526
        col1 := 1
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   527
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   528
    line2 := self lineOfCharacterPosition:endPos.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   529
    col2 := startPos - (self characterPositionOfLine:line2 col:1) + 1.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   530
    col2 < 1 ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   531
        col2 := 1
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   532
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   533
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   534
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   535
    "Modified: / 19.6.1998 / 02:41:28 / cg"
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   536
!
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   537
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   538
textHasChanged
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   539
    ^ self modified
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   540
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   541
    "Created: / 19.6.1998 / 00:09:43 / cg"
2117
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   542
!
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   543
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   544
textHasChanged:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   545
    "ST-80 compatibility: set/clear the modified flag."
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   546
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   547
    self modified:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   548
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   549
    "Created: / 5.2.2000 / 17:07:59 / cg"
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   552
!EditTextView methodsFor:'accessing-behavior'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   553
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   554
acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   555
    "return the action to be performed on accept (or nil)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   556
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   557
    ^ acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   558
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   559
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   560
acceptAction:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   561
    "set the action to be performed on accept"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   562
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   563
    acceptAction := aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   564
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   565
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   566
acceptEnabled:aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   567
    "enable/disable accept. This greys the corresponding item in the menu"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   568
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   569
    acceptEnabled := aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   570
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   571
    "Created: 7.3.1997 / 11:04:34 / cg"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   572
!
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   573
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   574
autoIndent:aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   575
    autoIndent := aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   576
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   577
    "Created: 5.3.1996 / 14:37:50 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   578
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   579
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   580
cursorMovementWhenUpdating:aSymbolOrNil
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   581
    "define what should be done with the cursor, 
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   582
     when I get a new text (via the model or the #contents/#list)
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   583
     Allowed arguments are:
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   584
        #keep / nil     -> stay where it was
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   585
        #endOfText      -> position cursor to the end
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   586
        #beginOfText    -> position cursor to the beginning
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   587
        #endOfLine      -> position cursor to the current lines end
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   588
        #beginOfLine    -> position cursor to the current lines start
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   589
     The default is #beginOfText.
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   590
     This may be useful for fields which get new values assigned from
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   591
     the program (i.e. not from the user)"
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   592
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   593
    cursorMovementWhenUpdating := aSymbolOrNil
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   594
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   595
    "Modified: 16.12.1995 / 16:27:55 / cg"
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   596
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   597
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   598
disableIfInvisible:aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   599
    disableIfInvisible := aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   600
!
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   601
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   602
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   603
    "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
   604
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   605
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   606
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   607
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   608
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   609
insertMode:aBoolean
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   610
    insertMode := aBoolean
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   611
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   612
    "Created: 6.3.1996 / 12:24:05 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   613
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   614
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   615
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   616
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   617
     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
   618
     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
   619
     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
   620
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   621
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   622
    tabMeansNextField := aBoolean
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   625
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   626
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   627
acceptChannel
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   628
    "return the valueHolder holding true if text was accepted.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   629
     By placing a true into this channel, an accept can also be forced."
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   630
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   631
    ^ acceptChannel
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   632
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   633
    "Modified: / 30.1.1998 / 14:17:11 / cg"
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   634
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   635
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   636
acceptChannel:aValueHolder
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   637
    "set the valueHolder holding true if text was accepted.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   638
     By placing a true into this channel, an accept can also be forced."
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   639
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   640
    |prev|
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   641
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   642
    prev := acceptChannel.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   643
    acceptChannel := aValueHolder.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   644
    self setupChannel:aValueHolder for:nil withOld:prev
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   645
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   646
    "Created: / 30.1.1998 / 14:51:09 / cg"
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   647
!
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   648
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   649
accepted
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   650
    "return true if text was accepted"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   651
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   652
    ^ acceptChannel value
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   653
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   654
    "Created: 14.2.1997 / 16:43:46 / cg"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   655
!
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   656
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   657
accepted:aBoolean
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   658
    "set/clear the accepted flag.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   659
     This may force my current contents to be placed into my model."
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   660
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   661
    acceptChannel value:aBoolean.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   662
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   663
    "Created: / 14.2.1997 / 16:44:01 / cg"
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   664
    "Modified: / 30.1.1998 / 14:20:15 / cg"
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   665
!
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   666
1902
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   667
at:lineNr basicPut:aLine
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   668
    "change a line without change notification"
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   669
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   670
    (self at:lineNr) = aLine ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   671
        super at:lineNr put:aLine.
1902
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   672
    ].
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   673
!
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   674
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   675
at:lineNr put:aLine
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   676
    (self at:lineNr) = aLine ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   677
        super at:lineNr put:aLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   678
        self textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   679
    ].
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   680
!
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   681
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   682
characterBeforeCursor
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   683
    "return the character under the cursor - space if behond line.
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   684
     For non-block cursors, this is the character immediately to the right
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   685
     of the insertion-bar or caret."
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   686
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   687
    cursorCol == 1 ifTrue:[^ nil].
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   688
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   689
    ^ self characterAtLine:cursorLine col:cursorCol-1
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   690
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   691
    "Created: / 17.6.1998 / 15:16:41 / cg"
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   692
!
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   693
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   694
characterUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   695
    "return the character under the cursor - space if behond line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   696
     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
   697
     of the insertion-bar or caret."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   698
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   699
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   700
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   701
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   702
contents
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   703
    "return the contents as a String or Text (i.e. with emphasis)"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   704
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   705
    list isNil ifTrue:[^ ''].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   706
    self removeTrailingBlankLines.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   707
    ^ list asStringWithCRs
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   708
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   709
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   710
contentsAsString
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   711
    "return the contents as a String (i.e. without emphasis)"
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   712
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   713
    list isNil ifTrue:[^ ''].
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   714
    self removeTrailingBlankLines.
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   715
    ^ (list collect:[:each | each isNil ifTrue:['']
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   716
                                        ifFalse:[each string]
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   717
                    ]) asStringWithCRs
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   718
!
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   719
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   720
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   721
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   722
     This is the absolute col; NOT the visible col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   723
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   724
    ^ cursorCol
125
claus
parents: 123
diff changeset
   725
!
claus
parents: 123
diff changeset
   726
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   727
cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   728
    "return the cursors line (1..). 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   729
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   730
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   731
    ^ cursorLine
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   734
fixedSize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   735
    "make the texts size fixed (no lines may be added).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   736
     OBSOLETE: use readOnly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   737
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
   738
    <resource:#obsolete>
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
   739
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   740
    self obsoleteMethodWarning:'use #readOnly:'.
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   741
    readOnly == true ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   742
        readOnly := true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   743
        middleButtonMenu notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   744
            middleButtonMenu disableAll:#(cut paste replace indent)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   745
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   746
    ]
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   747
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   748
    "Modified: 14.2.1997 / 17:35:24 / cg"
127
claus
parents: 125
diff changeset
   749
!
claus
parents: 125
diff changeset
   750
1037
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   751
isReadOnly
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   752
    "return true, if the text is readonly."
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   753
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   754
    ^ readOnly value
1037
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   755
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   756
    "Modified: 14.2.1997 / 17:35:56 / cg"
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   757
!
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   758
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   759
list:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   760
    "position cursor home when setting contents"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   761
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   762
    |prevCursorLine prevCursorCol|
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   763
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   764
    prevCursorLine := cursorLine.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   765
    prevCursorCol := cursorCol.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   766
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   767
    super list:something.
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   768
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   769
    (cursorMovementWhenUpdating == #endOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   770
    or:[cursorMovementWhenUpdating == #end]) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   771
        ^ self cursorToEndOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   772
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   773
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   774
    (cursorMovementWhenUpdating == #endOfLine) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   775
        ^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   776
    ].    
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   777
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   778
    (cursorMovementWhenUpdating == #beginOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   779
    or:[cursorMovementWhenUpdating == #begin]) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   780
        ^ self cursorHome
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   781
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   782
    (cursorMovementWhenUpdating == #beginOfLine) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   783
        ^ self cursorLine:prevCursorLine col:1.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   784
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   785
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   786
    "/ default: stay where it was
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   787
    "/ self cursorLine:prevCursorLine col:prevCursorCol.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   788
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   789
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   790
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   791
modified
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   792
    "return true if text was modified"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   793
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   794
    ^ modifiedChannel value
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   795
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   796
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   797
modified:aBoolean
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   798
    "set/clear the modified flag"
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   799
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   800
    modifiedChannel value:aBoolean
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   801
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   802
    "Modified: 14.2.1997 / 16:44:05 / cg"
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   803
!
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   804
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   805
modifiedChannel
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   806
    "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
   807
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   808
    ^ modifiedChannel
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   809
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   810
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   811
modifiedChannel:aValueHolder
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   812
    "set the valueHolder holding true if text was modified"
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   813
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   814
    |prev|
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   815
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   816
    prev := modifiedChannel.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   817
    modifiedChannel := aValueHolder.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   818
    self setupChannel:aValueHolder for:nil withOld:prev
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   819
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   820
    "Created: / 30.1.1998 / 14:51:32 / cg"
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   821
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   822
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   823
readOnly
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   824
    "make the text readonly.
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   825
     Somewhat obsolete - use #readOnly:"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   826
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
   827
    <resource:#obsolete>
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
   828
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   829
    self obsoleteMethodWarning:'use #readOnly:'.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   830
    readOnly := true
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   831
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   832
    "Modified: 14.2.1997 / 17:35:56 / cg"
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   833
!
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   834
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   835
readOnly:aBoolean
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   836
    "make the text readonly (aBoolean == true) or writable (aBoolean == false).
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   837
     The argument may also be a valueHolder."
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   838
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   839
    readOnly := aBoolean
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   840
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   841
    "Created: 14.2.1997 / 17:35:39 / cg"
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   842
!
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   843
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   844
setContents:something
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   845
    |selType|
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   846
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   847
    selType := typeOfSelection.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   848
    super setContents:something.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   849
    typeOfSelection := selType.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   850
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   851
    "Created: / 31.3.1998 / 23:35:06 / cg"
259
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
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   854
!EditTextView methodsFor:'accessing-look'!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   855
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   856
cursorForegroundColor:color1 backgroundColor:color2
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   857
    "set both cursor foreground and cursor background colors"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   858
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   859
    |wasOn|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   860
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   861
    wasOn := self hideCursor.
1993
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   862
    cursorFgColor := color1 onDevice:device.
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   863
    cursorBgColor := color2 onDevice:device.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   864
    wasOn ifTrue:[self showCursor]
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   865
!
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   866
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   867
cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   868
    "return the style of the text cursor.
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   869
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   870
                               #bigCaret and #bigSolidCaret"
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   871
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   872
    ^ cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   873
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   874
    "Modified: / 5.5.1999 / 14:52:33 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   875
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   876
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   877
cursorType:aCursorTypeSymbol
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   878
    "set the style of the text cursor.
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   879
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   880
                               #bigCaret and #bigSolidCaret"
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   881
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   882
    cursorType := aCursorTypeSymbol.
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   883
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   884
    "Created: 21.9.1997 / 13:42:23 / cg"
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   885
    "Modified: 21.9.1997 / 13:43:35 / cg"
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   886
!
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   887
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   888
cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   889
    "return the style of the text cursor when the view has no focus.
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   890
     If left unspecified, this is the same as the regular cursorType."
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   891
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   892
    ^ cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   893
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   894
    "Created: / 5.5.1999 / 14:52:46 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   895
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   896
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   897
cursorTypeNoFocus:aCursorTypeSymbol
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   898
    "set the style of the text cursor when the view has no focus.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   899
     If left unspecified, this is the same as the regular cursorType."
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   900
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   901
    cursorTypeNoFocus := aCursorTypeSymbol
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   902
! !
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   903
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
   904
!EditTextView methodsFor:'change & update'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   905
125
claus
parents: 123
diff changeset
   906
accept
claus
parents: 123
diff changeset
   907
    "accept the current contents by executing the accept-action and/or
claus
parents: 123
diff changeset
   908
     changeMessage."
claus
parents: 123
diff changeset
   909
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   910
    acceptEnabled == false ifTrue:[
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   911
        device beep.
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   912
        ^ self
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   913
    ].
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   914
    (disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   915
        ^ self
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   916
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   917
125
claus
parents: 123
diff changeset
   918
    lockUpdates := true.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   919
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   920
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   921
    "/ ST-80 way of doing it
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   922
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   923
    model notNil ifTrue:[
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   924
        self sendChangeMessageWith:self argForChangeMessage.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   925
    ].
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   926
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   927
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   928
    "/ ST/X way of doing things
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   929
    "/ as a historic (and temporary) leftover,
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   930
    "/ the block is called with a stringCollection
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   931
    "/ - not with the actual string
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   932
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   933
    acceptAction notNil ifTrue:[
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   934
        acceptAction value:self list
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   935
    ].
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   936
1811
348df65055eb do not clear the modified flag on accept.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   937
    "/ NO - must be manually reset by application
348df65055eb do not clear the modified flag on accept.
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   938
    "/ self modified:false.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   939
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   940
    "/ self accepted:true.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   941
    "/ changed to:
2344
da0c69b10f2f only trigger accept channel, if there is a model.
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   942
    model notNil ifTrue:[
da0c69b10f2f only trigger accept channel, if there is a model.
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   943
        acceptChannel value:true withoutNotifying:self.
da0c69b10f2f only trigger accept channel, if there is a model.
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   944
    ].
125
claus
parents: 123
diff changeset
   945
claus
parents: 123
diff changeset
   946
    lockUpdates := false.
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   947
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   948
    "Modified: / 30.1.1998 / 14:19:00 / cg"
131
claus
parents: 130
diff changeset
   949
!
claus
parents: 130
diff changeset
   950
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   951
argForChangeMessage
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   952
    "return the argument to be passed with the change notification.
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   953
     Defined as separate method for easier subclassability."
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   954
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   955
    ^ self contents
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   956
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   957
    "Modified: 29.4.1996 / 12:42:14 / cg"
121
claus
parents: 118
diff changeset
   958
!
claus
parents: 118
diff changeset
   959
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   960
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   961
    "get my contents from the model.
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   962
     Redefined to ignore updates resulting from my own changes
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   963
     (i.e. if lockUpdates is true)."
121
claus
parents: 118
diff changeset
   964
claus
parents: 118
diff changeset
   965
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   966
     ignore updates from my own change
121
claus
parents: 118
diff changeset
   967
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   968
    lockUpdates ifTrue:[
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
   969
        lockUpdates := false.
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
   970
        ^ self
121
claus
parents: 118
diff changeset
   971
    ].
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
   972
    super getListFromModel.
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
   973
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
   974
    "/ validate the cursorLine
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   975
    (cursorLine notNil 
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   976
     and:[ cursorLine > list size ]) ifTrue:[
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
   977
        self cursorLine:list size + 1 col:1
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
   978
    ].
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   979
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   980
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   981
update:something with:aParameter from:changedObject
1438
bed1564b0640 fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1437
diff changeset
   982
    changedObject == acceptChannel ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   983
        acceptChannel value == true ifTrue:[ 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   984
            self accept.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   985
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   986
        ^ self.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   987
    ].
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   988
    super update:something with:aParameter from:changedObject
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   989
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   990
    "Created: / 30.1.1998 / 14:15:56 / cg"
1439
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
   991
    "Modified: / 1.2.1998 / 13:15:55 / cg"
121
claus
parents: 118
diff changeset
   992
! !
claus
parents: 118
diff changeset
   993
claus
parents: 118
diff changeset
   994
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
   995
2406
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   996
characterPositionOfCursor
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   997
    ^ self characterPositionOfLine:cursorLine col:cursorCol
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   998
!
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   999
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1000
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1001
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1002
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1003
    self cursorCol:(self prevTabBefore:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1004
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1005
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1006
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1007
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1008
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1009
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1010
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1011
    wasOn := self hideCursor.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1012
    cursorCol := self validateCursorCol:newCol inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1013
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1014
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1015
    "Modified: 22.5.1996 / 14:25:53 / cg"
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1018
cursorDown
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1019
    "move cursor down; scroll if at end of visible text;
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1020
     beep if at end of physical text."
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1021
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1022
    |wasOn|
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1023
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1024
    self cursorDown:1.
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1025
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1026
    "/ cursor behond text ?
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1027
    cursorLine > list size ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1028
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1029
        cursorLine := self validateCursorLine:(list size + 1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1030
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1031
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1032
        "/ wasOn ifTrue:[self showCursor].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1033
        self makeCursorVisibleAndShowCursor:wasOn.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1034
        self beep.
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1035
    ].
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1036
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  1037
    "Modified: / 10.6.1998 / 17:00:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1038
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1039
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1040
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1041
    "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
  1042
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1043
    |wasOn nv|
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
    cursorVisibleLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1046
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1047
        nv := cursorVisibleLine + n - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1048
        (nv >= nFullLinesShown) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1049
            self scrollDown:(nv - nFullLinesShown + 1)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1050
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1051
        cursorLine := self validateCursorLine:(cursorLine + n).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1052
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1053
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1054
        "/ wasOn ifTrue:[self showCursor].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1055
        self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1056
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1057
        cursorLine isNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1058
            cursorLine := firstLineShown
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1059
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1060
        cursorLine := self validateCursorLine:(cursorLine + n).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1061
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1062
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1063
        self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1064
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1065
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  1066
    "Modified: / 10.6.1998 / 16:59:17 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1067
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1068
121
claus
parents: 118
diff changeset
  1069
cursorHome
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1070
    "scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
  1071
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1072
    self cursorLine:1 col:1
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1073
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1074
"/    |wasOn|
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1075
"/
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1076
"/    wasOn := self hideCursor.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1077
"/    self scrollToTop.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1078
"/    cursorLine := cursorVisibleLine := 1.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1079
"/    cursorCol := self validateCursorCol:1 inLine:cursorLine.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1080
"/    self makeCursorVisibleAndShowCursor:wasOn.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1081
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1082
    "Modified: 22.5.1996 / 18:26:42 / cg"
121
claus
parents: 118
diff changeset
  1083
!
claus
parents: 118
diff changeset
  1084
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1085
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1086
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1087
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1088
    (cursorCol ~~ 1) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1089
        self cursorCol:(cursorCol - 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1090
    ] ifFalse:[
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1091
"/ no, do not wrap back to previous line
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1092
"/        cursorLine ~~ 1 ifTrue:[
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1093
"/            ST80Mode == true ifTrue:[
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1094
"/                self cursorUp.
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1095
"/                self cursorToEndOfLine.
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1096
"/           ]
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1097
"/        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1098
    ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1099
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1100
    "Modified: / 23.1.1998 / 12:37:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1101
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1102
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1103
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1104
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1105
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1106
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1107
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1108
    wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1109
    cursorLine := self validateCursorLine:line.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1110
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1111
    (col < 1) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1112
        newCol := 1
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1113
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1114
        newCol := col.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1115
    ].
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1116
    st80Mode ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1117
        (cursorLine == list size
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1118
        and:[cursorLine ~~ line]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1119
            newCol := (self listAt:(list size)) size + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1120
        ]
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1121
    ].
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1122
    cursorCol := self validateCursorCol:newCol inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1123
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1124
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1125
    "Modified: / 20.6.1998 / 18:19:06 / cg"
259
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
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1128
cursorMovementAllowed
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1129
    "return true, if the user may move the cursor around
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1130
     (via button-click, or cursor-key with selection).
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1131
     By default, true is returned, but this may be redefined
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1132
     in special subclasses (such as a terminal view), where
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1133
     this is not wanted"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1134
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1135
    ^ true
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1136
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1137
    "Created: / 18.6.1998 / 14:11:16 / cg"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1138
!
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1139
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1140
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1141
    "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
  1142
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1143
    |wasOn|
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
    self checkForExistingLine:(cursorLine + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1146
    cursorVisibleLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1147
        nFullLinesShown notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1148
            (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1149
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1150
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1151
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1152
    wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1153
    cursorLine := self validateCursorLine:cursorLine + 1.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1154
    cursorCol := self validateCursorCol:1 inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1155
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1156
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1157
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1158
    "Modified: 22.5.1996 / 18:27:34 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1159
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1160
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1161
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1162
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1163
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1164
    |l|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1165
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1166
    st80Mode == true ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1167
        l := (self listAt:cursorLine).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1168
        cursorCol >= (l size + 1) ifTrue:[
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1169
"/ no, do not wrap to next line
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1170
"/            cursorLine < list size ifTrue:[
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1171
"/                self cursorReturn.
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1172
"/            ].
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1173
            ^ self    
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1174
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1175
    ].    
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1176
    self cursorCol:(cursorCol + 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1177
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1178
    "Modified: / 20.6.1998 / 18:19:07 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1179
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1180
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1181
cursorShown:aBoolean
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1182
    "change cursor visibility
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1183
     return true if cursor was visible before."
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1184
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1185
    |oldState|
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1186
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1187
    oldState := cursorShown.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1188
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1189
    aBoolean ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1190
        self drawCursor.
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1191
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1192
        (cursorShown and:[shown]) ifTrue: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1193
            self undrawCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1194
        ].
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1195
    ].
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1196
    cursorShown := aBoolean.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1197
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1198
    ^ oldState
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1199
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1200
    "Modified: / 30.3.1999 / 15:32:43 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1201
    "Created: / 30.3.1999 / 15:59:30 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1202
!
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1203
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1204
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1205
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1206
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1207
    self cursorCol:(self nextTabAfter:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1208
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1209
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1210
cursorToBeginOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1211
    "move cursor to start of current line"
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
    self cursorCol:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1214
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1215
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1216
cursorToBottom
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1217
    "move cursor to the last line of text (col 1)"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1218
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1219
    |wasOn newTop|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1220
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1221
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1222
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1223
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1224
    (newTop < 1) ifTrue:[
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1225
        newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1226
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1227
    self scrollToLine:newTop.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1228
    cursorLine := self validateCursorLine:list size.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1229
    cursorCol := self validateCursorCol:1 inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1230
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
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
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1233
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1234
    "Modified: 22.5.1996 / 18:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1235
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1236
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1237
cursorToCharacterPosition:pos
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1238
    "compute line/col from character position (1..)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1239
     and move the cursor onto that char"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1240
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1241
    |line col|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1242
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1243
    line := self lineOfCharacterPosition:pos.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1244
    col := pos - (self characterPositionOfLine:line col:1) + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1245
    self cursorLine:line col:col
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1246
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1247
    "Created: / 15.1.1998 / 21:55:33 / cg"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1248
!
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1249
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1250
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1251
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1252
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1253
    |wasOn newTop l line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1254
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1255
    l := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1256
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1257
    cursorLine >= l ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1258
        line := self listAt:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1259
        (line isNil or:[line isEmpty]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1260
            ^ self
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1261
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1262
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1263
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1264
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1265
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1266
    l := l + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1267
    newTop :=  l - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1268
    (newTop < 1) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1269
        newTop := 1
259
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
    self scrollToLine:newTop.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1272
    cursorLine := self validateCursorLine:l.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1273
    cursorCol := self validateCursorCol:1 inLine:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1274
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1275
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1276
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1277
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1278
    "Modified: 22.5.1996 / 18:27:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1279
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1280
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1281
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1282
    "move cursor to end of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1283
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1284
    |line|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1285
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1286
    line := (self listAt:cursorLine).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1287
    self cursorCol:(line size + 1)
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1288
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1289
    "Modified: 13.8.1997 / 15:34:02 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1290
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1291
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1292
cursorToEndOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1293
    "move cursor to the end of the text (behinf last character in last line)"
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1294
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1295
    |wasOn newTop|
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1296
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1297
    wasOn := self hideCursor.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1298
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1299
    newTop := list size - nFullLinesShown.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1300
    (newTop < 1) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1301
        newTop := 1
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1302
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1303
    self scrollToLine:newTop.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1304
    cursorLine := self validateCursorLine:list size.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1305
    cursorCol := self validateCursorCol:(self listAt:cursorLine) size inLine:cursorLine.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1306
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1307
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1308
    self makeCursorVisibleAndShowCursor:wasOn.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1309
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1310
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1311
131
claus
parents: 130
diff changeset
  1312
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
  1313
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  1314
claus
parents: 130
diff changeset
  1315
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
  1316
!
claus
parents: 130
diff changeset
  1317
claus
parents: 130
diff changeset
  1318
cursorToLastVisibleLine
claus
parents: 130
diff changeset
  1319
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  1320
claus
parents: 130
diff changeset
  1321
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
  1322
!
claus
parents: 130
diff changeset
  1323
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1324
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1325
    "move the cursor to the beginning of the next word"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1326
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1327
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1328
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1329
    (cursorLine > list size) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1330
    self wordAtLine:cursorLine col:cursorCol do:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1331
        :beginLine :beginCol :endLine :endCol :style | 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1332
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1333
        line := endLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1334
        col := endCol + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1335
        searching := true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1336
        [searching 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1337
         and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1338
            self wordAtLine:line col:col do:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1339
                :beginLine :beginCol :endLine :endCol :style |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1340
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1341
                (line > list size) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1342
                    "break out"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1343
                    searching := false
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1344
                ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1345
                    line := endLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1346
                    col := endCol + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1347
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1348
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1349
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1350
        self cursorLine:line col:col
121
claus
parents: 118
diff changeset
  1351
    ]
claus
parents: 118
diff changeset
  1352
!
claus
parents: 118
diff changeset
  1353
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1354
cursorToPreviousWord
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1355
    "move the cursor to the beginning of this or the previous word"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1356
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1357
    |col line searching l|
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1358
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1359
    (cursorLine > list size) ifTrue:[^ self].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1360
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1361
    self wordAtLine:cursorLine col:cursorCol do:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1362
        :beginLine :beginCol :endLine :endCol :style | 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1363
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1364
        line := beginLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1365
        col := beginCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1366
        style == #wordLeft ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1367
            col := col + 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1368
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1369
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1370
        (cursorLine == line
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1371
        and:[cursorCol == col]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1372
            searching := true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1373
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1374
            col > 1 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1375
                col := col - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1376
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1377
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1378
            [searching] whileTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1379
                (col == 1) ifTrue:[    
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1380
                    line == 1 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1381
                        searching := false
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1382
                    ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1383
                        line := line - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1384
                        l := list at:line.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1385
                        col := l size + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1386
                    ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1387
                ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1388
                    (self characterAtLine:line col:col) isSeparator ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1389
                        self wordAtLine:line col:col do:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1390
                            :beginLine :beginCol :endLine :endCol :style |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1391
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1392
                            line := beginLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1393
                            col := beginCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1394
                            style == #wordLeft ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1395
                                col := col + 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1396
                            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1397
                            searching := false.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1398
                        ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1399
                    ] ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1400
                        col := col - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1401
                    ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1402
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1403
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1404
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1405
        self cursorLine:line col:col
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1406
    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1407
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1408
    "Created: 8.3.1996 / 21:52:48 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1409
    "Modified: 8.3.1996 / 22:12:45 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1410
!
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1411
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1412
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1413
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1414
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1415
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1416
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1417
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1418
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1419
    "move cursor up; scroll if at start of visible text"
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
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1422
!
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
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1425
    "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
  1426
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1427
    |wasOn nv nl|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1428
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1429
    cursorLine isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1430
        cursorLine := firstLineShown + nFullLinesShown - 1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1431
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1432
    nl := cursorLine - n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1433
    nl < 1 ifTrue:[nl := 1].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1434
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1435
    (nl ~~ cursorLine) ifTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1436
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1437
        cursorVisibleLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1438
            nv := cursorVisibleLine - n.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1439
            nv < 1 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1440
                self scrollUp:(nv negated + 1)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1441
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1442
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1443
        cursorLine := self validateCursorLine:nl.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1444
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1445
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1446
        wasOn ifTrue:[self showCursor].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1447
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1448
"/ to make cursor visible (even if below visible end):
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1449
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1450
"/      self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1451
    ]
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1452
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1453
    "Modified: 22.5.1996 / 18:28:11 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1454
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1455
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1456
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1457
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1458
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1459
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1460
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1461
    wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1462
    cursorLine := self validateCursorLine:(self visibleLineToAbsoluteLine:visibleLineNr).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1463
    cursorVisibleLine := visibleLineNr.
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1464
    newCol := colNr.
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1465
    (newCol < 1) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1466
        newCol := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1467
    ].
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1468
    cursorCol := self validateCursorCol:newCol inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1469
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1470
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  1471
    "Modified: / 20.6.1998 / 18:40:28 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1472
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1473
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1474
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1475
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
  1476
claus
parents: 118
diff changeset
  1477
    |line col|
claus
parents: 118
diff changeset
  1478
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1479
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1480
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1481
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
  1482
!
claus
parents: 118
diff changeset
  1483
claus
parents: 118
diff changeset
  1484
drawCursor
claus
parents: 118
diff changeset
  1485
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
  1486
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
  1487
claus
parents: 118
diff changeset
  1488
    shown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1489
        cursorVisibleLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1490
            self hasSelection ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1491
                self drawCursorCharacter
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1492
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1493
        ]
121
claus
parents: 118
diff changeset
  1494
    ]
claus
parents: 118
diff changeset
  1495
!
claus
parents: 118
diff changeset
  1496
claus
parents: 118
diff changeset
  1497
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
  1498
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
  1499
     of cursor should be drawn.
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1500
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1501
                               #bigCaret and #bigSolidCaret"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1502
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1503
    |x y w char y2 x1 x2 oldPaint oldClip line|
121
claus
parents: 118
diff changeset
  1504
claus
parents: 118
diff changeset
  1505
    self hasSelection ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1506
        "
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1507
         hide cursor, if there is a selection
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1508
        "
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1509
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1510
    ].
claus
parents: 118
diff changeset
  1511
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1512
    cursorType == #none ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1513
        ^ self
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1514
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1515
121
claus
parents: 118
diff changeset
  1516
    cursorType == #block ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1517
        super drawVisibleLine:cursorVisibleLine 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1518
                          col:cursorCol 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1519
                         with:fgColor
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1520
                          and:bgColor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1521
        ^ self
121
claus
parents: 118
diff changeset
  1522
    ].
claus
parents: 118
diff changeset
  1523
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - leftOffset.
claus
parents: 118
diff changeset
  1524
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
  1525
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1526
    oldPaint := self paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
  1527
    cursorType == #frame ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1528
        super redrawVisibleLine:cursorVisibleLine col:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1529
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1530
        char := self characterUnderCursor asString.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1531
        self paint:bgColor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1532
        self displayRectangleX:x y:y 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1533
                         width:(font widthOf:char) height:fontHeight.
133
claus
parents: 132
diff changeset
  1534
    ] ifFalse:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1535
        self paint:bgColor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1536
        cursorType == #ibeam ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1537
            x1 := x - 1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1538
            y2 := y + fontHeight - 1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1539
            self displayLineFromX:x1 y:y toX:x1 y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1540
            self displayLineFromX:x y:y toX:x y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1541
            ^ self
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1542
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1543
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1544
        cursorType == #Ibeam ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1545
            x1 := x - 1.
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  1546
            y := y + 1.
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1547
            y2 := y + fontHeight - 1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1548
            self displayLineFromX:x1 y:y toX:x1 y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1549
            self displayLineFromX:x y:y toX:x y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1550
            self displayLineFromX:x1-2 y:y toX:x+2 y:y. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1551
            self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1552
            ^ self
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1553
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1554
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1555
        y := y + fontHeight - 3.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1556
        ((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1557
            w := (fontWidth * 2 // 3) max:4.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1558
            y2 := y + w + (w//2).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1559
        ] ifFalse:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1560
            w := (fontWidth // 2) max:4.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1561
            y2 := y + w.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1562
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1563
        x1 := x - w.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1564
        x2 := x + w.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1565
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1566
        oldClip := self clippingRectangleOrNil.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1567
        self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1568
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1569
        cursorType == #caret ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1570
            self lineWidth:2.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1571
            self displayLineFromX:x1 y:y2 toX:x y:y. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1572
            self displayLineFromX:x y:y toX:x2 y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1573
        ] ifFalse:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1574
            "anything else: solidCaret"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1575
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1576
            self fillPolygon:(Array with:(x1 @ y2)
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1577
                                    with:(x @ y)
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1578
                                    with:(x2 @ y2))
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1579
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1580
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1581
        self clippingRectangle:oldClip
121
claus
parents: 118
diff changeset
  1582
    ].
133
claus
parents: 132
diff changeset
  1583
    self paint:oldPaint.
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1584
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  1585
    "Modified: / 15.12.1999 / 22:24:17 / cg"
121
claus
parents: 118
diff changeset
  1586
!
claus
parents: 118
diff changeset
  1587
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1588
drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1589
    "draw the cursor. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1590
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1591
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1592
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1593
    (hasKeyboardFocus 
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1594
    and:[self enabled
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1595
    and:[readOnly not]]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1596
        self drawFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1597
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1598
        self drawNoFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1599
    ]
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1600
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1601
    "Modified: / 23.3.1999 / 13:52:48 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1602
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1603
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1604
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1605
    "draw the cursor when the focus is in the view."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1606
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1607
    self hasSelection ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1608
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1609
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1610
    cursorType == #none ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1611
        ^ self undrawCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1612
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1613
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1614
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1615
    "Modified: 22.9.1997 / 00:16:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1616
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1617
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1618
drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1619
    "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
  1620
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1621
    |cType|
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1622
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1623
    self hasSelection ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1624
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1625
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1626
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1627
    cType := cursorTypeNoFocus ? cursorType.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1628
    cType == #none ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1629
        ^ self undrawCursor
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1630
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1631
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1632
    cType == #block ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1633
        ^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1634
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1635
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1636
    ^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1637
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1638
    "Modified: 22.9.1997 / 00:16:13 / cg"
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1641
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1642
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1643
     Make certain that this line is visible"
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
    self makeLineVisible:aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1646
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1647
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1648
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1649
hideCursor
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1650
    "make cursor invisible if currently invisible"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1651
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1652
    ^ self cursorShown:false
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1653
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1654
    "Modified: / 30.3.1999 / 16:02:28 / stefan"
121
claus
parents: 118
diff changeset
  1655
!
claus
parents: 118
diff changeset
  1656
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1657
makeCursorVisible
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1658
    "scroll text to make cursorline visible 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1659
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1660
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1661
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1662
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1663
    cursorLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1664
        line := cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1665
        col := cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1666
        "
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1667
         if there is a selection, its better to
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1668
         have its start being visible, instead of the end
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1669
        "
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1670
        (selectionStartLine notNil 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1671
        and:[selectionEndLine notNil]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1672
            expandingTop ~~ false ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1673
                line := selectionStartLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1674
                col := selectionStartCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1675
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1676
                line := selectionEndLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1677
                col := selectionEndCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1678
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1679
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1680
        self makeLineVisible:line.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1681
        self makeColVisible:col inLine:line 
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1682
    ]
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1683
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1684
    "Modified: 6.3.1996 / 13:46:46 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1685
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1686
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1687
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1688
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1689
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1690
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1691
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1692
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
  1693
!
claus
parents: 118
diff changeset
  1694
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1695
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1696
    "make cursor visible if currently invisible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1697
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1698
    ^ self cursorShown:true
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1699
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1700
    "Modified: / 30.3.1999 / 16:02:34 / stefan"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1701
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1702
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1703
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1704
    "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
  1705
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1706
    |prevCol line oldClip x y e1 e2 e3|
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1707
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1708
    cursorVisibleLine notNil ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1709
        prevCol := cursorCol - 1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1710
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1711
        "/ if there is any italic stuff in the cursor line,
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1712
        "/ redraw it completely (because characters overlap).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1713
        cursorCol > 1 ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1714
            (line := self listAt:cursorLine) notNil ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1715
                line hasChangeOfEmphasis ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1716
                    line size >= (cursorCol-1) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1717
                        e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1718
                        line size >= (cursorCol) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1719
                            e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1720
                            line size >= (cursorCol+1) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1721
                                e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1)
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1722
                            ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1723
                        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1724
                    ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1725
                    (e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1726
                        ^ super redrawVisibleLine:cursorVisibleLine 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1727
                    ]
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1728
                ]
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1729
            ]
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1730
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1731
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1732
        ((cursorType == #caret)
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1733
         or:[cursorType == #solidCaret
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1734
         or:[cursorType == #bigSolidCaret
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1735
         or:[cursorType == #bigCaret
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1736
         or:[cursorType == #Ibeam]]]]) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1737
            "caret-cursor touches 4 characters"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1738
            ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  1739
                super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol.
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1740
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1741
                super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1742
            ] ifFalse:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1743
                "care for left margin"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1744
                super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1745
            ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1746
            ^ self
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1747
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1748
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1749
        cursorType == #ibeam ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1750
            "ibeam-cursor touches 2 characters"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1751
            cursorCol > 1 ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1752
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1753
            ] ifFalse:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1754
                "care for left margin"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1755
                super redrawVisibleLine:cursorVisibleLine.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1756
            ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1757
            ^ self
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1758
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1759
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1760
        "block cursor is simple - just one character under cursor"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1761
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1762
        "/ however, if italic characters are involved, we must care
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1763
        "/ for the chars before/after the cursor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1764
        "/ We redraw the part of the previous character which got
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1765
        "/ detroyed by the block cursor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1766
        "/ (must change the clip, to avoid destroying the prev-prev character) 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1767
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1768
        line := self visibleAt:cursorVisibleLine.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1769
        (line notNil and:[line isText]) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1770
            cursorCol > 1 ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1771
                oldClip := self clippingRectangleOrNil.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1772
                x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - leftOffset.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1773
                y := self yOfVisibleLine:cursorVisibleLine.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1774
                self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1775
                super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1776
                self clippingRectangle:oldClip.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1777
                ^ self.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1778
            ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1779
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1780
        super redrawVisibleLine:cursorVisibleLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1781
    ]
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1782
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  1783
    "Modified: / 15.12.1999 / 22:25:59 / cg"
121
claus
parents: 118
diff changeset
  1784
!
claus
parents: 118
diff changeset
  1785
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1786
validateCursorCol:col inLine:line
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1787
    "check of col is a valid cursor position; return a new col-nr if not.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1788
     Here, no limits are enforced (and col is returned), 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1789
     but it may be redefined in EditFields or views which dont like the 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1790
     cursor to be positioned behind the end of a textLine (vi/st-80 behavior)"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1791
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1792
    |l max|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1793
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1794
    "/ in ST80 mode,
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1795
    "/ the cursor may not be positioned behond the
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1796
    "/ end of a line or behond the last line of the text
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1797
    "/
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1798
    st80Mode == true ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1799
        l := (self listAt:line).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1800
        max := l size + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1801
        col > max ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1802
            ^ max
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1803
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1804
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1805
    ^ col
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1806
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1807
    "Created: / 22.5.1996 / 14:25:30 / cg"
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1808
    "Modified: / 20.6.1998 / 18:19:24 / cg"
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1809
!
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1810
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1811
validateCursorLine:line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1812
    "check of line is a valid cursor line; return a fixed line-nr if not.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1813
     Here, no limits are enforced (and line is returned), but it may be 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1814
     redefined in views which dont like the cursor to be positioned
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1815
     behind the end of the text (vi/st-80 behavior), or want to
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1816
     skip reserved regions"
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1817
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1818
    "/
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1819
    "/ in st80Mode, the cursor may not be positioned
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1820
    "/ behond the last line
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1821
    "/
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1822
    st80Mode == true ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1823
        ^ (line min:(list size)) max:1
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1824
    ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1825
    ^ line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1826
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1827
    "Created: / 22.5.1996 / 18:22:23 / cg"
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1828
    "Modified: / 20.6.1998 / 18:19:26 / cg"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1829
!
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1830
121
claus
parents: 118
diff changeset
  1831
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
  1832
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
  1833
claus
parents: 118
diff changeset
  1834
    (shown not or:[cursorShown not]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1835
        ^ aBlock value
121
claus
parents: 118
diff changeset
  1836
    ].
claus
parents: 118
diff changeset
  1837
    self hideCursor.
claus
parents: 118
diff changeset
  1838
    aBlock valueNowOrOnUnwindDo:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1839
        self showCursor
121
claus
parents: 118
diff changeset
  1840
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1841
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1842
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1843
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1844
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1845
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1846
    "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
  1847
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1848
    selectionStartLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1849
        self setTextSelection:(self selection).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1850
        self deleteSelection.
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1851
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1852
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1853
    "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
  1854
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1855
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1856
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1857
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  1858
claus
parents: 118
diff changeset
  1859
    |wasOn|
claus
parents: 118
diff changeset
  1860
claus
parents: 118
diff changeset
  1861
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1862
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1863
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  1864
!
claus
parents: 118
diff changeset
  1865
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1866
deleteCharAtLine:lineNr col:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1867
    "delete a single character at colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1868
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1869
    self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1870
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1871
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1872
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1873
    "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
  1874
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1875
    |soCol wasOn lineNrAboveCursor ln|
121
claus
parents: 118
diff changeset
  1876
claus
parents: 118
diff changeset
  1877
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1878
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1879
        (autoIndent
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1880
    and:[cursorCol  ~~ 1
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1881
    and:[cursorLine <= (list size)]]) 
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1882
     ifTrue:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1883
        soCol := (self leftIndentForLine:cursorLine) + 1.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1884
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1885
        (cursorCol == soCol and:[soCol > 1]) ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1886
            ln := list at:cursorLine.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1887
            (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1888
                soCol := 1
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1889
            ]
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1890
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1891
    ] ifFalse:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1892
        soCol := 1
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1893
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1894
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1895
    (cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1896
        "
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1897
         somewhere in the middle of a line
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1898
        "
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1899
        self cursorLeft.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1900
        self deleteCharAtLine:cursorLine col:cursorCol.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1901
    ] ifFalse:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1902
        "
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1903
         at begin of line - merge with previous line;
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1904
         except for the very first line.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1905
        "
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1906
        (cursorLine == 1) ifFalse:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1907
            lineNrAboveCursor := self validateCursorLine:(cursorLine - 1).
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1908
            lineNrAboveCursor < cursorLine ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1909
                (lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1910
                    "/ we are behond the end of the text.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1911
                    "/ move the cursor to the previous line.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1912
                    self cursorLine:lineNrAboveCursor col:1.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1913
                ] ifFalse:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1914
                    self mergeLine:lineNrAboveCursor removeBlanks:false.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1915
                ]
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1916
            ]
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  1917
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1918
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1919
    wasOn ifTrue:[ self showCursor ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1920
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1921
    "Modified: / 16.1.1998 / 22:33:04 / cg"
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1922
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1923
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1924
deleteCharsAtLine:lineNr fromCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1925
    "delete characters from colNr up to the end in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1926
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1927
    |line|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1928
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1929
    (line := self listAt:lineNr) notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1930
        self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size)
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1931
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1932
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1933
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1934
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1935
deleteCharsAtLine:lineNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1936
    "delete characters from start up to colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1937
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1938
    self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1939
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1940
121
claus
parents: 118
diff changeset
  1941
!
claus
parents: 118
diff changeset
  1942
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1943
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1944
    "delete the line where the cursor sits"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1945
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1946
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  1947
!
claus
parents: 118
diff changeset
  1948
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1949
deleteFromCharacterPosition:charPos1 to:charPos2
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1950
    "delete a substring at a character position"
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1951
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1952
    |line1 col1 line2 col2|
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1953
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1954
    line1 := self lineOfCharacterPosition:charPos1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1955
    col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1956
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1957
    line2 := self lineOfCharacterPosition:charPos2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1958
    col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1959
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1960
    self deleteFromLine:line1 col:col1 toLine:line2 col:col2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1961
!
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1962
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1963
deleteLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1964
    "delete line"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1965
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1966
    self deleteFromLine:lineNr toLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1967
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1968
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1969
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1970
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1971
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1972
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1973
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1974
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1975
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1976
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1977
    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
  1978
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1979
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1980
    (endLine > list size) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1981
        lastLine := list size
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1982
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1983
        lastLine := endLine
259
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
    list removeFromIndex:startLine toIndex:lastLine.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1986
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1987
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1988
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1989
    "/ avoids slow delete with huge texts.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1990
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1991
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1992
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1993
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1994
    "Modified: / 10.11.1998 / 23:55:29 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1995
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1996
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1997
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1998
    "delete the selection"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1999
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2000
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2001
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2002
    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
  2003
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2004
    selectionStartLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2005
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2006
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2007
        startLine := selectionStartLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2008
        startCol := selectionStartCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2009
        endLine := selectionEndLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2010
        endCol := selectionEndCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2011
        self unselectWithoutRedraw.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2012
        self deleteFromLine:startLine col:startCol 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2013
                     toLine:endLine col:endCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2014
        cursorCol := startCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2015
        cursorLine := startLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2016
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2017
        self makeCursorVisibleAndShowCursor:wasOn
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2018
    ]
121
claus
parents: 118
diff changeset
  2019
!
claus
parents: 118
diff changeset
  2020
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2021
deleteWordBeforeCursor
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2022
    "delete the word to the left of cursor and move cursor to left"
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2023
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2024
    |wasOn beginCol beginLine endCol endLine deletedText|
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2025
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2026
    wasOn := self hideCursor.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2027
    endCol := cursorCol-1.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2028
    endLine := cursorLine.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2029
    self cursorToPreviousWord.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2030
    beginCol := cursorCol.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2031
    beginLine := cursorLine.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2032
    deletedText := self textFromLine:beginLine col:beginCol toLine:endLine col:endCol.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2033
    self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2034
    undoAction := [ self cursorLine:beginLine col:beginCol.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2035
                    self paste:deletedText].
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2036
    wasOn ifTrue:[ self showCursor ].
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2037
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2038
    "Modified: / 22.2.2000 / 23:59:04 / cg"
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2039
!
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2040
121
claus
parents: 118
diff changeset
  2041
insertCharAtCursor:aCharacter
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2042
    "insert a single character at cursor-position - advance cursor."
121
claus
parents: 118
diff changeset
  2043
claus
parents: 118
diff changeset
  2044
    |wasOn|
claus
parents: 118
diff changeset
  2045
claus
parents: 118
diff changeset
  2046
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2047
    aCharacter == Character tab ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2048
        "/ needs special care to advance cursor correctly
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2049
        self insertTabAtCursor
121
claus
parents: 118
diff changeset
  2050
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2051
        self insert:aCharacter atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2052
        aCharacter == (Character cr) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2053
            self cursorReturn
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2054
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2055
            self cursorRight.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2056
        ].
121
claus
parents: 118
diff changeset
  2057
    ].
claus
parents: 118
diff changeset
  2058
    self makeCursorVisibleAndShowCursor:wasOn.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2059
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2060
    "Modified: / 12.6.1998 / 21:50:20 / cg"
121
claus
parents: 118
diff changeset
  2061
!
claus
parents: 118
diff changeset
  2062
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2063
insertLine:aString before:lineNr
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2064
    "insert the line aString before line lineNr"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2065
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2066
    ^ self insertLines:(Array with:aString) from:1 to:1  before:lineNr.
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2067
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2068
    "Modified: 14.5.1996 / 13:42:54 / cg"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2069
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2070
155
claus
parents: 133
diff changeset
  2071
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  2072
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  2073
claus
parents: 133
diff changeset
  2074
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  2075
claus
parents: 133
diff changeset
  2076
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  2077
!
claus
parents: 133
diff changeset
  2078
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2079
insertLines:lines withCR:withCr
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2080
    "insert a bunch of lines at cursor position. 
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2081
     Cursor is moved behind insertion.
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2082
     If withCr is true, append cr after last line"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2083
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2084
    |start end nLines wasOn|
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2085
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2086
    lines notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2087
        nLines := lines size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2088
        (nLines == 1) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2089
            self insertStringAtCursor:(lines at:1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2090
            withCr ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2091
                self insertCharAtCursor:(Character cr)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2092
            ] 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2093
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2094
            (cursorCol ~~ 1) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2095
                self insertStringAtCursor:(lines at:1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2096
                self insertCharAtCursor:(Character cr).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2097
                start := 2
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2098
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2099
                start := 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2100
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2101
            withCr ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2102
                end := nLines
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2103
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2104
                end := nLines - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2105
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2106
            (start < nLines) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2107
                (end >= start) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2108
                    wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2109
                    self insertLines:lines from:start to:end before:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2110
                    cursorLine := cursorLine + (end - start + 1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2111
                    cursorVisibleLine := self absoluteLineToVisibleLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2112
                    wasOn ifTrue:[self showCursor].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2113
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2114
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2115
            withCr ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2116
                "last line without cr"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2117
                self insertStringAtCursor:(lines at:nLines)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2118
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2119
        ]
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2120
    ]
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2121
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2122
    "Created: / 18.5.1996 / 15:32:06 / cg"
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2123
    "Modified: / 12.6.1998 / 21:51:16 / cg"
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2124
!
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2125
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2126
insertLines:lines withCr:withCr
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2127
    "insert a bunch of lines at cursor position. Cursor
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2128
     is moved behind insertion.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2129
     If withCr is true, append cr after last line"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2130
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  2131
    <resource:#obsolete>
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  2132
1292
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2133
    self obsoleteMethodWarning:'use #insertLines:withCR:'.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2134
    self insertLines:lines withCR:withCr.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2135
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2136
    "Modified: 31.7.1997 / 23:07:22 / cg"
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2137
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2138
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2139
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2140
    "insert the argument, aString at cursor position and select it"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2141
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2142
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2143
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2144
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2145
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2146
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2147
    self selectFromLine:startLine col:startCol
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2148
                 toLine:cursorLine col:(cursorCol - 1)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2149
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2150
1935
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2151
insertString:aString atCharacterPosition:charPos
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2152
    "insert the argument, aString at a character position"
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2153
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2154
    |line col|
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2155
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2156
    line := self lineOfCharacterPosition:charPos.
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2157
    col := charPos - (self characterPositionOfLine:line col:1) + 1.
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2158
    self insertString:aString atLine:line col:col
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2159
!
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2160
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2161
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2162
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2163
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2164
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2165
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2166
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2167
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2168
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2169
     l               "{ Class: SmallInteger }" |
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
    aString isNil ifTrue:[^ self].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2172
    (aString includes:(Character cr)) ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2173
        ^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  2174
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2175
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2176
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2177
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2178
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2179
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2180
    [start <= end] whileTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2181
        stop := aString indexOf:(Character cr) startingAt:start.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2182
        stop == 0 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2183
            stop := end + 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2184
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2185
        subString := aString copyFrom:start to:(stop - 1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2186
        self insertStringWithoutCRs:subString atLine:l col:c.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2187
        (stop <= end) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2188
            c := c + subString size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2189
            self insert:(Character cr) atLine:l col:c.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2190
            l := l + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2191
            c := 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2192
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2193
        start := stop + 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2194
    ]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2195
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2196
    "Modified: / 10.6.1998 / 19:03:59 / cg"
121
claus
parents: 118
diff changeset
  2197
!
claus
parents: 118
diff changeset
  2198
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2199
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2200
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2201
     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
  2202
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2203
    aString isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2204
        "new:"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2205
        self insertCharAtCursor:(Character cr).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2206
        ^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2207
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2208
    (aString includes:(Character cr)) ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2209
        ^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2210
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2211
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2212
    self insertLines:aString asStringCollection withCR:false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2213
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2214
    "Modified: / 10.6.1998 / 19:03:21 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2215
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2216
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2217
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2218
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2219
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2220
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2221
    shown ifTrue:[self redrawLine:lineNr from:colNr]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2222
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2223
    "Modified: / 5.4.1998 / 16:51:14 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2224
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2225
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2226
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2227
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2228
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2229
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  2230
    |wasOn oldLen newLen|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2231
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2232
    aString notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2233
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2234
        (aString includes:Character tab) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2235
            self checkForExistingLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2236
            oldLen := (list at:cursorLine) size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2237
            self insertString:aString atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2238
            newLen := (list at:cursorLine) size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2239
            cursorCol := cursorCol + (newLen - oldLen).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2240
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2241
            self insertString:aString atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2242
            cursorCol := cursorCol + aString size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2243
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2244
        wasOn ifTrue:[self showCursor]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2245
    ]
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  2246
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  2247
    "Modified: / 10.6.1998 / 20:43:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2248
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2249
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2250
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2251
    "insert spaces to next tab"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2252
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2253
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2254
121
claus
parents: 118
diff changeset
  2255
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2256
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2257
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2258
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2259
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2260
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2261
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2262
    "remove all blank lines at end of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2263
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2264
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2265
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2266
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2267
    lastLine := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2268
    finished := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2269
    [finished] whileFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2270
        (lastLine <= 1) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2271
            finished := true
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2272
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2273
            line := list at:lastLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2274
            line notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2275
                line isBlank ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2276
                    list at:lastLine put:nil.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2277
                    line := nil
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2278
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2279
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2280
            line notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2281
                finished := true
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2282
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2283
                lastLine := lastLine - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2284
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2285
        ]
118
claus
parents: 105
diff changeset
  2286
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2287
    (lastLine ~~ list size) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2288
        list grow:lastLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2289
"/        self textChanged
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2290
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2291
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2292
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2293
replaceCharAtCursor:aCharacter
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2294
    "replace a single character at cursor-position - advance cursor"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2295
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2296
    |wasOn|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2297
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2298
    wasOn := self hideCursor.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2299
    aCharacter == (Character cr) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2300
        self cursorReturn
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2301
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2302
        self replace:aCharacter atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2303
        self cursorRight.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2304
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2305
    self makeCursorVisibleAndShowCursor:wasOn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2306
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2307
    "Created: 6.3.1996 / 12:27:42 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2308
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2309
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2310
replaceLines:lines withCR:withCr
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2311
    "replace a bunch of lines at cursor position. Cursor
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2312
     is moved behind replacement.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2313
     If withCr is true, move to the beginning of the next line
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2314
     after the last line"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2315
1809
111f603c0a1c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1807
diff changeset
  2316
    |line col nLines wasOn|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2317
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2318
    lines notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2319
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2320
        nLines := lines size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2321
        line := cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2322
        col := cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2323
        lines keysAndValuesDo:[:i :l |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2324
            self replaceString:l atLine:line col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2325
            (i ~~ nLines or:[withCr]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2326
                line := line + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2327
                col := 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2328
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2329
                col := col + (l size).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2330
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2331
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2332
        self cursorLine:line col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2333
        self makeCursorVisibleAndShowCursor:wasOn.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2334
        "/ wasOn ifTrue:[self showCursor].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2335
    ]
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2336
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2337
    "Created: / 18.5.1996 / 15:32:06 / cg"
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2338
    "Modified: / 12.6.1998 / 22:05:51 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2339
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2340
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2341
replaceSelectionBy:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2342
    "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
  2343
     leave cursor after insertion"
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
    self replaceSelectionBy:something keepCursor:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2346
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2347
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2348
replaceSelectionBy:something keepCursor:keep
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2349
    "delete the selection (if any) and insert something, a character or string;
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2350
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2351
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2352
    |sel l c|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2353
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2354
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2355
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2356
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2357
    sel := self selection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2358
    sel notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2359
        lastString := sel.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2360
        self deleteSelection.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2361
        replacing := true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2362
        lastReplacement := ''
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2363
    ].
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2364
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2365
    (something isMemberOf:Character) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2366
        lastReplacement notNil ifTrue:[
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2367
"/ "XXX - replacing text with spaces ..."
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2368
"/            (lastReplacement endsWith:Character space) ifTrue:[
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2369
"/                lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)".
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2370
"/                lastReplacement := lastReplacement copyWith:something.
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2371
"/                lastReplacement := lastReplacement copyWith:Character space
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2372
"/            ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2373
                lastReplacement := lastReplacement copyWith:something.
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2374
"/            ]
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2375
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2376
        insertMode ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2377
            self insertCharAtCursor:something
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2378
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2379
            self replaceCharAtCursor:something
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2380
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2381
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2382
        lastReplacement := something.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2383
        insertMode ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2384
            self insertStringAtCursor:something
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2385
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2386
            self replaceStringAtCursor
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2387
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2388
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2389
    keep ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2390
        self cursorLine:l col:c
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2391
    ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2392
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2393
    "Modified: 9.10.1996 / 16:14:35 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2394
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2395
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2396
replaceStringAtCursor:aString
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2397
    "replace multiple characters at cursor-position - advance cursor"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2398
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2399
    |wasOn i1 i2|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2400
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2401
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2402
    (aString includes:Character tab) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2403
        "/ need special care for TAB (to move cursor correctly)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2404
        i1 := 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2405
        [i1 ~~ 0] whileTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2406
            i2 := aString indexOf:Character tab startingAt:i1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2407
            i2 ~~ 0 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2408
                i1 ~~ i2 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2409
                    self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2410
                    self cursorCol:(cursorCol + (i2 - i1)).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2411
                ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2412
                self replaceTABAtCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2413
                i2 := i2 + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2414
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2415
                self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2416
                self cursorCol:(cursorCol + (aString size - i1 + 1)).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2417
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2418
            i1 := i2.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2419
        ]
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2420
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2421
        self replaceString:aString atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2422
        self cursorCol:(cursorCol + aString size).
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2423
    ].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2424
    self makeCursorVisibleAndShowCursor:wasOn.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2425
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2426
    "Created: / 9.6.1998 / 20:33:20 / cg"
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2427
    "Modified: / 20.6.1998 / 19:41:02 / cg"
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2428
!
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2429
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2430
replaceTABAtCursor
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2431
    "replace a single character at cursor-position by a TAB character"
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2432
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2433
    |wasOn nextTab|
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2434
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2435
    wasOn := self hideCursor.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2436
    nextTab := self nextTabAfter:cursorCol.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2437
    self replaceStringAtCursor:(String new:(nextTab - cursorCol)).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2438
    self makeCursorVisibleAndShowCursor:wasOn.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2439
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2440
    "Created: / 12.6.1998 / 21:53:23 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2441
! !
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2442
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2443
!EditTextView methodsFor:'editing - basic'!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2444
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2445
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2446
    "delete characters from startCol to endCol in line lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2447
    "
1803
ac7cc1b99407 scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  2448
    |line lineSize newLine start stop prevWidth newWidth|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2449
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2450
    line := self listAt:lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2451
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2452
    (self checkModificationsAllowed and:[line notNil]) ifTrue:[ 
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2453
        lineSize := line size.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2454
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2455
        startCol == 0     ifFalse:[ start := startCol ]
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2456
                           ifTrue:[ start := 1 ]. 
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2457
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2458
        endCol > lineSize ifFalse:[ stop  := endCol ]
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2459
                           ifTrue:[ stop  := lineSize ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2460
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2461
        stop >= start ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2462
            start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ]
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2463
                      ifFalse:[ newLine := '' ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2464
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2465
            stop == lineSize ifFalse:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2466
                line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2467
                    newLine := line string species fromString:newLine.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2468
                ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2469
                newLine := newLine, (line copyFrom:(stop + 1) to:lineSize)
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2470
            ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2471
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2472
            (trimBlankLines and:[newLine isBlank]) ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2473
                newLine := nil
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2474
            ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2475
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2476
            prevWidth := self widthOfLine:lineNr.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2477
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2478
            list at:lineNr put:newLine.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2479
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2480
            (prevWidth = widthOfWidestLine) ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2481
                "/ remember old width of this line,
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2482
                "/ only clear widthOfWidestLine, if this lines
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2483
                "/ length was (one of) the longest.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2484
                "/ avoids slow delete with huge texts.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2485
                widthOfWidestLine := nil.   "i.e. unknown"
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2486
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2487
                "/ scroll left if reqiured
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2488
                viewOrigin x > 0 ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2489
                    newWidth := self widthOfLine:lineNr.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2490
                    newWidth < (viewOrigin x + width) ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2491
                        self scrollHorizontalTo:(newWidth 
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2492
                                                 - width 
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2493
                                                 + margin + margin 
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2494
                                                 + (font widthOf:'  '))
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2495
                    ]
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2496
                ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2497
                self textChanged.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2498
            ] ifFalse:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2499
                self textChangedButNoSizeChane
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2500
            ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2501
            self redrawLine:lineNr from:start.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2502
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2503
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2504
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2505
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2506
    "Modified: / 11.11.1998 / 00:01:09 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2507
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2508
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2509
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2510
    "delete all text from startLine/startCol to endLine/endCol -
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2511
     joining lines if nescessary"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2512
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  2513
    |line newLine lineSize nMore|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2514
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2515
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2516
    list isNil ifTrue:[^ self].
960
29a592101ad4 care for deleting a selection behond the texts end
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  2517
    startLine > list size ifTrue:[ ^ self]. "/ deleted space below text
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2518
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2519
    (startLine == endLine) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2520
        "/ delete chars within a line
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2521
        self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2522
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2523
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2524
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2525
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2526
        "/ delete full lines only
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2527
        endLine > startLine ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2528
            self deleteFromLine:startLine toLine:(endLine - 1)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2529
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2530
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2531
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2532
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2533
    "/ delete right rest of 1st line
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2534
    self deleteCharsAtLine:startLine fromCol:startCol.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2535
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2536
    "/ delete the inner lines ...
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2537
    endLine > (startLine + 1) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2538
        self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2539
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2540
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2541
    (endCol ~~ 0) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2542
        "/ delete the left rest of the last line
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2543
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2544
        self deleteCharsAtLine:(startLine + 1) toCol:endCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2545
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2546
        "/ must add blanks, if startCol lies behond end of startLine
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2547
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2548
        line := list at:startLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2549
        lineSize := line size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2550
        (startCol > lineSize) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2551
            newLine := line.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2552
            line isNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2553
                newLine := String new:(startCol - 1)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2554
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2555
                nMore := startCol - 1 - lineSize.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2556
                nMore > 0 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2557
                    newLine := line , (line species new:nMore)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2558
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2559
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2560
            newLine ~~ line ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2561
                list at:startLine put:newLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2562
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2563
            "/ TODO: remember old maxwidth of linerange,
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2564
            "/ only clear widthOfWidestLine, if this max
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2565
            "/ length was (one of) the longest.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2566
            "/ avoids slow delete with huge texts.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2567
            widthOfWidestLine := nil. "/ i.e. unknown
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2568
            self textChanged.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2569
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2570
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2571
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2572
    "/ merge the left rest of 1st line with right rest of last line into one
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  2573
    self mergeLine:startLine removeBlanks:false
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2574
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2575
    "Modified: / 10.11.1998 / 23:52:59 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2576
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2577
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2578
deleteFromLine:startLineNr toLine:endLineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2579
    "delete some lines"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2580
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2581
    |wasOn nLines|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2582
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2583
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2584
    list isNil ifTrue:[^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2585
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2586
    wasOn := self hideCursor.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2587
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2588
    "/ isnt this the same as:
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2589
    "/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2590
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2591
    list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2592
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2593
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2594
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2595
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2596
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2597
    self textChanged.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2598
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2599
    self redrawFromLine:startLineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2600
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2601
    nLines := list size.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2602
    (firstLineShown >= nLines) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2603
        self makeLineVisible:nLines
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2604
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2605
    wasOn ifTrue:[self showCursor].
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2606
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2607
    "Modified: / 10.11.1998 / 23:55:05 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2608
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2609
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2610
deleteLineWithoutRedraw:lineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2611
    "delete line - no redraw;
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2612
     return true, if something was really deleted"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2613
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2614
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2615
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2616
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2617
    list removeIndex:lineNr.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2618
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2619
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2620
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2621
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2622
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2623
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2624
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2625
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2626
    "Modified: / 10.11.1998 / 23:53:24 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2627
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2628
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2629
insert:aCharacter atLine:lineNr col:colNr
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2630
    "insert a single character at lineNr/colNr; 
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2631
     set emphasis to character at current position"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2632
1929
8e70fb7c9701 fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2633
    |line lineSize newLine drawCharacterOnly attribute oldClip x y|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2634
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2635
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2636
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2637
    aCharacter == (Character cr) ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2638
        self splitLine:lineNr before:colNr.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2639
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2640
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2641
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2642
    drawCharacterOnly := false.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2643
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2644
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2645
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2646
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2647
    st80Mode ~~ true ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2648
        (trimBlankLines 
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2649
        and:[colNr > lineSize
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2650
        and:[aCharacter == Character space]]) ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2651
            ^ self
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2652
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2653
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2654
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2655
    (lineSize == 0) ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2656
        newLine := aCharacter asString species new:colNr.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2657
        drawCharacterOnly := true
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2658
    ] ifFalse: [
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2659
        (colNr > lineSize) ifTrue: [
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2660
            colNr == (lineSize +1) ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2661
                attribute := line emphasisAt:lineSize
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2662
            ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2663
            newLine := line species new:colNr.
2210
94f6ffcb06ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  2664
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2665
            drawCharacterOnly := true
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2666
        ] ifFalse: [
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2667
            attribute := line emphasisAt:colNr.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2668
            newLine   := line species new:(lineSize + 1).
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2669
2210
94f6ffcb06ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  2670
            newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1.
94f6ffcb06ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  2671
            newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2672
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2673
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2674
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2675
    newLine at:colNr put:aCharacter.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2676
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2677
    attribute notNil ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2678
        newLine emphasisAt:colNr put:attribute
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2679
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2680
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2681
    aCharacter == (Character tab) ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2682
        newLine := self withTabsExpanded:newLine.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2683
        drawCharacterOnly := false
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2684
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2685
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2686
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2687
    widthOfWidestLine notNil ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2688
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2689
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2690
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2691
    shown ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2692
        "/ care for italic text - in this case, we must also
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2693
        "/ redraw the character before the insertion in order
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2694
        "/ to fix the slanted piece of the character.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2695
        "/ (but we must clip, to avoid destoying the character before)
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2696
        (newLine notNil and:[newLine isText]) ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2697
            colNr > 1 ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2698
                cursorVisibleLine notNil ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2699
                    oldClip := self clippingRectangleOrNil.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2700
                    x := (self xOfCol:colNr inVisibleLine:cursorVisibleLine) - leftOffset.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2701
                    y := self yOfVisibleLine:cursorVisibleLine.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2702
                    drawCharacterOnly ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2703
                        self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)).
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2704
                        self redrawLine:lineNr from:colNr-1 to:colNr
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2705
                    ] ifFalse:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2706
                        self clippingRectangle:(x@y extent:((width - x) @ fontHeight)).
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2707
                        self redrawLine:lineNr from:colNr-1
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2708
                    ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2709
                    self clippingRectangle:oldClip.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2710
                ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2711
                ^ self.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2712
            ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2713
        ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2714
        drawCharacterOnly ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2715
            self redrawLine:lineNr col:colNr
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2716
        ] ifFalse:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2717
            self redrawLine:lineNr from:colNr
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2718
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2719
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2720
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2721
    "Modified: / 20.6.1998 / 18:19:22 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2722
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2723
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2724
insertLines:someText from:start to:end before:lineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2725
    "insert a bunch of lines before line lineNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2726
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2727
    |text indent visLine w nLines "{ Class: SmallInteger }"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2728
     srcY "{ Class: SmallInteger }"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2729
     dstY "{ Class: SmallInteger }" |
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2730
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  2731
    self isReadOnly ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2732
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2733
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2734
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2735
    autoIndent ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2736
        indent := self leftIndentForLine:lineNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2737
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2738
        text := someText collect:[:ln||line|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2739
            ln notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2740
                line := ln withoutLeadingSeparators.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2741
                (line isEmpty or:[indent == 0]) ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2742
                    line := (String new:indent), line
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2743
                ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2744
                line
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2745
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2746
                nil
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2747
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2748
        ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2749
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2750
        text := someText
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2751
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2752
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2753
    visLine := self listLineToVisibleLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2754
    (shown not or:[visLine isNil]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2755
        self withoutRedrawInsertLines:text
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2756
                                 from:start to:end
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2757
                               before:lineNr.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2758
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2759
        nLines := end - start + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2760
        ((visLine + nLines) >= nLinesShown) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2761
            self withoutRedrawInsertLines:text
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2762
                                     from:start to:end
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2763
                                   before:lineNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2764
            self redrawFromVisibleLine:visLine to:nLinesShown
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2765
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2766
            w := self widthForScrollBetween:(lineNr + nLines)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2767
                                        and:(firstLineShown + nLines + nLinesShown).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2768
            srcY := topMargin + ((visLine - 1) * fontHeight).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2769
            dstY := srcY + (nLines * fontHeight).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2770
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2771
            "/
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2772
            "/ scroll ...
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2773
            "/
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2774
            "
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2775
             stupid: must catchExpose before inserting new
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2776
             stuff - since catchExpose may perform redraws
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2777
            "
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2778
            self catchExpose.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2779
            self withoutRedrawInsertLines:text
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2780
                                     from:start to:end
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2781
                                   before:lineNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2782
            self 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2783
                copyFrom:self 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2784
                x:textStartLeft y:srcY
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2785
                toX:textStartLeft y:dstY
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2786
                width:w
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2787
                height:(height - dstY)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2788
                async:true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2789
            self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2790
            self waitForExpose
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2791
        ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2792
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2793
    widthOfWidestLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2794
        text do:[:line |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2795
            widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2796
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2797
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2798
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2799
984
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2800
    "Modified: 29.1.1997 / 13:02:39 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2801
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2802
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2803
mergeLine:lineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2804
    "merge line lineNr with line lineNr+1"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2805
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2806
    self mergeLine:lineNr removeBlanks:true
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2807
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2808
    "Modified: 9.9.1997 / 09:28:03 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2809
!
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2810
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2811
mergeLine:lineNr removeBlanks:removeBlanks
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2812
    "merge line lineNr with line lineNr+1"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2813
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2814
    |leftPart rightPart bothParts nextLineNr i|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2815
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2816
    (list notNil and:[(list size) >= lineNr]) ifFalse:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2817
        "/ empty list or behond end of text
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2818
        ^ self
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2819
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2820
    leftPart := self listAt:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2821
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2822
    leftPart isNil ifTrue:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2823
        leftPart := ''.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2824
        autoIndent ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2825
            (i := self leftIndentForLine:cursorLine) == 0 ifFalse:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2826
                leftPart := String new:i
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2827
            ]
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2828
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2829
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2830
    self cursorLine:lineNr col:((leftPart size) + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2831
    nextLineNr := self validateCursorLine:(lineNr + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2832
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2833
    nextLineNr > (list size) ifFalse:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2834
        (rightPart := self listAt:nextLineNr) isNil ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2835
            rightPart := ''
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2836
        ] ifFalse:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2837
            removeBlanks ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2838
                rightPart := rightPart withoutLeadingSeparators.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2839
            ]
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2840
        ].
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2841
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2842
        bothParts := leftPart , rightPart.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2843
        (trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil].
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2844
        list at:lineNr put:bothParts.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2845
        self redrawLine:lineNr.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2846
        self deleteLine:nextLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2847
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2848
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2849
    "Created: 9.9.1997 / 09:27:38 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2850
    "Modified: 9.9.1997 / 09:28:27 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2851
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2852
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2853
replace:aCharacter atLine:lineNr col:colNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2854
    "replace a single character at lineNr/colNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2855
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2856
    |line lineSize newLine drawCharacterOnly|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2857
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2858
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2859
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2860
    aCharacter == (Character cr) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2861
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2862
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2863
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2864
    drawCharacterOnly := true.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2865
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2866
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2867
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2868
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2869
    (trimBlankLines
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2870
    and:[colNr > lineSize
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2871
    and:[aCharacter == Character space]]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2872
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2873
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2874
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2875
    (lineSize == 0) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2876
        newLine := aCharacter asString species new:colNr.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2877
    ] ifFalse: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2878
        (colNr > lineSize) ifTrue: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2879
            newLine := line species new:colNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2880
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2881
        ] ifFalse: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2882
            newLine := line copy.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2883
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2884
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2885
    newLine at:colNr put:aCharacter.
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2886
    aCharacter == (Character tab) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2887
        newLine := self withTabsExpanded:newLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2888
        drawCharacterOnly := false
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2889
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2890
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2891
    widthOfWidestLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2892
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2893
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2894
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2895
    shown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2896
        drawCharacterOnly ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2897
            self redrawLine:lineNr col:colNr
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2898
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2899
            self redrawLine:lineNr from:colNr
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2900
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2901
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2902
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2903
    "Created: / 6.3.1996 / 12:29:20 / cg"
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  2904
    "Modified: / 10.6.1998 / 18:50:18 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2905
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2906
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2907
replaceString:aString atLine:lineNr col:colNr
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2908
    "replace multiple characters starting at lineNr/colNr.
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2909
     This is not prepared to encounter special chars (except TAB)
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2910
     in the string."
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2911
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2912
    |line lineSize newLine endCol|
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2913
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2914
    self checkModificationsAllowed ifFalse:[ ^ self].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2915
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2916
    self checkForExistingLine:lineNr.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2917
    line := list at:lineNr.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2918
    lineSize := line size.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2919
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2920
    endCol := colNr + aString size - 1.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2921
    (lineSize == 0) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2922
        newLine := aString species new:endCol.
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2923
    ] ifFalse: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2924
        (endCol > lineSize) ifTrue: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2925
            aString isText ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2926
                newLine := aString species new:endCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2927
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2928
                newLine := line species new:endCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2929
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2930
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2931
        ] ifFalse: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2932
            aString isText ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2933
                newLine := aString species new:line size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2934
                newLine replaceFrom:1 to:lineSize with:line startingAt:1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2935
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2936
                newLine := line copy.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2937
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2938
        ]
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2939
    ].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2940
    newLine replaceFrom:colNr with:aString.
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  2941
    (aString includes:(Character tab)) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2942
        newLine := self withTabsExpanded:newLine.
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  2943
    ].
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2944
    list at:lineNr put:newLine.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2945
    widthOfWidestLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2946
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2947
    ].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2948
    self textChanged.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2949
    shown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2950
        self redrawLine:lineNr from:colNr
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2951
    ]
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2952
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2953
    "Created: / 11.6.1998 / 10:38:32 / cg"
1599
63636b356b1f care for emphasis when replacing.
Claus Gittinger <cg@exept.de>
parents: 1597
diff changeset
  2954
    "Modified: / 20.6.1998 / 20:23:50 / cg"
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2955
!
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2956
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2957
splitLine:lineNr before:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2958
    "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
  2959
     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
  2960
981
6e52d3876ea7 dont catchExpose, if copy is empty
Claus Gittinger <cg@exept.de>
parents: 960
diff changeset
  2961
    |line lineSize leftRest rightRest visLine w h mustWait    
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2962
     srcY    "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2963
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2964
    list isNil ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2965
        lineNr > (list size) ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2966
            (colNr == 1) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2967
                self insertLine:nil before:lineNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2968
                ^ self
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2969
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2970
            line := list at:lineNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2971
            line isNil ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2972
                lineSize := line size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2973
                (colNr <= lineSize) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2974
                    rightRest := line copyFrom:colNr to:lineSize.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2975
                    (colNr > 1) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2976
                        leftRest := line copyTo:(colNr - 1)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2977
                    ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2978
                ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2979
                    leftRest := line
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2980
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2981
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2982
            leftRest notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2983
                (trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2984
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2985
            list at:lineNr put:leftRest.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2986
            self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2987
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2988
            visLine := self listLineToVisibleLine:(lineNr).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2989
            visLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2990
                w := self widthForScrollBetween:lineNr
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2991
                                            and:(firstLineShown + nLinesShown).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2992
                srcY := topMargin + (visLine * fontHeight).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2993
                h := ((nLinesShown - visLine - 1) * fontHeight).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2994
                (mustWait := (w > 0 and:[h > 0])) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2995
                    self catchExpose.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2996
                    self 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2997
                        copyFrom:self 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2998
                        x:textStartLeft y:srcY
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2999
                        toX:textStartLeft y:(srcY + fontHeight)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3000
                        width:w
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3001
                        height:((nLinesShown - visLine - 1) * fontHeight)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3002
                        async:true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3003
                ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3004
                self redrawLine:lineNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3005
                self redrawLine:(lineNr + 1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3006
                mustWait ifTrue:[self waitForExpose]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3007
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3008
            widthOfWidestLine := nil. "/ unknown
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3009
            self textChanged.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3010
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3011
    ]
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3012
984
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  3013
    "Modified: 29.1.1997 / 13:03:22 / cg"
259
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
withoutRedrawInsertLine:aString before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3017
    "insert the argument, aString before line lineNr; the string
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3018
     becomes line nileNr; everything else is moved down; the view
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3019
     is not redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3020
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3021
    |line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3022
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3023
    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
  3024
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3025
    line := aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3026
    line notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3027
        line isString ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3028
            line isBlank ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3029
                line := nil
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3030
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3031
                (line includes:(Character tab)) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3032
                    line := self withTabsExpanded:line
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3033
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3034
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3035
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3036
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3037
    list isNil ifTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3038
        list := StringCollection new:lineNr
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3039
    ] ifFalse: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3040
        list grow:((list size + 1) max:lineNr)
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3043
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3044
     overlapping copy - if it didn't, we had to use:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3045
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3046
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3047
    [index > lineNr] whileTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3048
        pIndex := index - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3049
        list at:index put:(list at:pIndex).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3050
        index := pIndex
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3051
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3052
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3053
    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
  3054
    list at:lineNr put:line.
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  3055
    self contentsChanged
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  3056
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3057
    "Modified: / 10.6.1998 / 19:00:56 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3058
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3059
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3060
withoutRedrawInsertLines:lines from:start to:end before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3061
    "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
  3062
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3063
    |newLine newLines nLines|
121
claus
parents: 118
diff changeset
  3064
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3065
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3066
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3067
    nLines := end - start + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3068
    newLines := Array new:(lines size).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3069
    start to:end do:[:index |
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3070
        newLine := lines at:index.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3071
        newLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3072
            newLine isString ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3073
                newLine isBlank ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3074
                    newLine := nil
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3075
                ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3076
                    (newLine includes:(Character tab)) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3077
                        newLine := self withTabsExpanded:newLine
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3078
                    ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3079
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3080
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3081
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3082
        newLines at:index put:newLine
121
claus
parents: 118
diff changeset
  3083
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3084
    list isNil ifTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3085
        list := StringCollection new:(lineNr + nLines + 1)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3086
    ] ifFalse: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3087
        list grow:((list size + nLines) max:(lineNr + nLines - 1))
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3088
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3089
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3090
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3091
     overlapping copy - if it didn't, we had to use:"
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
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3094
    [index > lineNr] whileTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3095
        pIndex := index - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3096
        list at:index put:(list at:pIndex).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3097
        index := pIndex
259
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
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3100
    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
  3101
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  3102
    self contentsChanged
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  3103
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3104
    "Modified: / 10.6.1998 / 19:01:16 / cg"
121
claus
parents: 118
diff changeset
  3105
!
claus
parents: 118
diff changeset
  3106
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3107
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3108
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3109
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3110
    |isText strLen line lineSize newLine stringType sz|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3111
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3112
    (aString notNil) ifFalse:[ ^ self].
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3113
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3114
    strLen := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3115
    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
  3116
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3117
    stringType := aString string species.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3118
    isText     := aString isText.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3119
    line       := list at:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3120
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3121
    line notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3122
        lineSize := line size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3123
        line bitsPerCharacter > aString bitsPerCharacter ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3124
            stringType := line string species
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3125
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3126
        line isText ifTrue:[ isText := true ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3127
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3128
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3129
        lineSize := 0
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3130
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3131
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3132
    ((colNr == 1) and:[lineSize == 0]) ifTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3133
        newLine := aString
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3134
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3135
        (lineSize == 0 or:[colNr > lineSize]) ifTrue: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3136
            sz := colNr + strLen - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3137
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3138
            sz := lineSize + strLen
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3139
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3140
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3141
        isText ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3142
            newLine := stringType new:sz
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3143
        ] ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3144
            newLine := Text string:(stringType new:sz)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3145
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3146
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3147
        (lineSize ~~ 0) ifTrue: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3148
            (colNr > lineSize) ifTrue: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3149
                newLine replaceFrom:1 to:lineSize
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3150
                               with:line startingAt:1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3151
            ] ifFalse: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3152
                newLine replaceFrom:1 to:(colNr - 1)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3153
                               with:line startingAt:1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3154
                newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3155
                               with:line startingAt:colNr
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3156
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3157
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3158
        newLine replaceFrom:colNr to:(colNr + strLen - 1)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3159
                       with:aString startingAt:1
259
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
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3162
    (aString includes:(Character tab)) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3163
        newLine := self withTabsExpanded:newLine
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3166
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3167
    widthOfWidestLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3168
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3169
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3170
    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
  3171
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3172
    "Modified: / 10.6.1998 / 19:01:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3173
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3174
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3175
!EditTextView methodsFor:'event processing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3176
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3177
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3178
    "hide the cursor when button is activated"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3179
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3180
    hasKeyboardFocus := true.
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  3181
    cursorShown ifTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3182
        self drawCursor
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  3183
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3184
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3185
    ((button == 1) or:[button == #select]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3186
        self hideCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3187
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3188
    (button == #paste) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3189
        self pasteOrReplace.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3190
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3191
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3192
    super buttonPress:button x:x y:y
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  3193
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  3194
    "Modified: / 23.3.1999 / 13:51:40 / cg"
121
claus
parents: 118
diff changeset
  3195
!
claus
parents: 118
diff changeset
  3196
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3197
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3198
    "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
  3199
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3200
    ((button == 1) or:[button == #select]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3201
        typeOfSelection := nil. 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3202
        selectionStartLine isNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3203
            clickCol notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3204
                self cursorMovementAllowed ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3205
                    self cursorLine:clickLine col:clickCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3206
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3207
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3208
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3209
            lastString := nil. "new selection invalidates remembered string"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3210
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3211
        self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3212
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3213
    super buttonRelease:button x:x y:y
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3214
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3215
    "Modified: / 18.6.1998 / 14:14:05 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3216
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3217
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3218
keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3219
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3220
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  3221
    <resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Accept
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3222
                          #Delete #BasicDelete #BackSpace #BasicBackspace
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3223
                          #SelectWord
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3224
                          #SearchMatchingParent #SelectMatchingParents 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3225
                          #SelectToEnd #SelectFromBeginning
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3226
                          #BeginOfLine #EndOfLine #NextWord #PreviousWord
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3227
                          #CursorRight #CursorDown #CursorLeft #CursorUp
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3228
                          #Return #Tab #Escape
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3229
                          #GotoLine #Delete #BeginOfText #EndOfText
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3230
                          #SelectLine #ExpandSelectionByLine #DeleteLine
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3231
                          #InsertLine
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3232
                          #SelectLineFromBeginning
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3233
                          #LearnKeyboardMacro #ExecuteKeyboardMacro
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3234
                          #'F*' #'f*')>
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3235
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  3236
    |sensor n fKeyMacros shifted i
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3237
     selStartLine selEndLine selStartCol selEndCol sel event|
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3238
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3239
    event := WindowGroup lastEventQuerySignal query.
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3240
    shifted := event hasShift.
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3241
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3242
    (key == #BackSpace
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3243
     or:[key == #BasicBackspace]) ifTrue:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3244
        selectionStartLine notNil ifTrue:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3245
            (key == #BasicBackspace) ifTrue:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3246
                ^ self deleteSelection.
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3247
            ] ifFalse:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3248
                ^ self copyAndDeleteSelection.
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3249
            ].
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3250
        ].
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3251
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3252
        self makeCursorVisible.
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3253
        shifted ifTrue:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3254
            self deleteWordBeforeCursor.
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3255
        ] ifFalse:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3256
            self deleteCharBeforeCursor. 
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3257
        ].
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  3258
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3259
        ^ self
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3260
    ].
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3261
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3262
    (key == #LearnKeyboardMacro) ifTrue:[
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3263
        learnMode := (learnMode ? false) not.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3264
        learnMode ifTrue:[
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3265
            learnedMacro := OrderedCollection new.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3266
            self cursorForegroundColor:Color white backgroundColor:Color black.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3267
        ] ifFalse:[
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3268
            cursorFgColor := DefaultCursorForegroundColor.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3269
            cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3270
            cursorBgColor := DefaultCursorBackgroundColor.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3271
            cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3272
            self cursorForegroundColor:(DefaultCursorForegroundColor ? bgColor)
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3273
                       backgroundColor:(DefaultCursorBackgroundColor ? fgColor).
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3274
        ].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3275
        ^ self
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3276
    ].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3277
    (key == #ExecuteKeyboardMacro) ifTrue:[
2186
1047dc01d950 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2185
diff changeset
  3278
        ((learnMode == false) and:[learnedMacro size > 0]) ifTrue:[
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3279
            learnedMacro do:[:event |
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3280
                                WindowGroup lastEventQuerySignal answer:event
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3281
                                do:[
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3282
                                    self 
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3283
                                        dispatchEvent:event
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3284
                                        withFocusOn:nil
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3285
                                        delegate:false
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3286
                                ]
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3287
                            ].
2185
d5af5babc2d9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
  3288
        ] ifFalse:[
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3289
            self flash.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3290
        ].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3291
        ^ self.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3292
    ].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3293
    learnMode == true ifTrue:[
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3294
        learnedMacro add:event.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3295
    ].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3296
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3297
    sensor := self sensor.
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3298
"/    shifted := (sensor ? device) shiftDown.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3299
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3300
    (key isMemberOf:Character) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3301
        self isReadOnly ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3302
            self flash
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3303
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3304
            typeOfSelection == #paste ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3305
                "pasted selection will NOT be replaced by keystroke"
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3306
                self unselect
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3307
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3308
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3309
            selStartLine := selectionStartLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3310
            selStartCol := self selectionStartCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3311
            selEndLine := selectionEndLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3312
            selEndCol := self selectionEndCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3313
            sel := self selection.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3314
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3315
            "replace selection by what is typed in -
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3316
             if word was selected with a space, keep it"
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3317
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3318
            (selectStyle == #wordLeft) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3319
                self replaceSelectionBy:(' ' copyWith:key)
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3320
            ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3321
                (selectStyle == #wordRight) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3322
                    self replaceSelectionBy:(key asString , ' ').
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3323
                    self cursorLeft
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3324
                ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3325
                    self replaceSelectionBy:key
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3326
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3327
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3328
            selectStyle := nil.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3329
2018
5a6801e68caa checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  3330
            sel size > 0 ifTrue:[
5a6801e68caa checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  3331
                undoAction := [
5a6801e68caa checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  3332
                                self cursorLine:selStartLine col:selStartCol.
5a6801e68caa checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  3333
                                self deleteCharAtCursor.
5a6801e68caa checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  3334
                                self paste:sel.    
5a6801e68caa checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  3335
                              ].
5a6801e68caa checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2017
diff changeset
  3336
            ].
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3337
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3338
            showMatchingParenthesis ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3339
                "emacs style parenthesis shower"
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3340
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3341
                "claus: only do it for closing parenthesis -
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3342
                        otherwise its too anoying.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3343
                "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3344
"
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3345
                (#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3346
"
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3347
                (#( $) $] $} ) includes:key) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3348
                self searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1)
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3349
                                   ifFound:[:line :col |
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3350
                                                |savLine savCol|
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3351
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3352
                                                self withCursor:Cursor eye do:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3353
                                                    savLine := cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3354
                                                    savCol := cursorCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3355
                                                    self cursorLine:line col:col.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3356
                                                    device flush.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3357
                                                    "/ want to wait 200ms, but not if another keyPress
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3358
                                                    "/ arrives in the meantime ...
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3359
                                                    "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3360
                                                    5 timesRepeat:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3361
                                                        (sensor notNil and:[sensor hasKeyPressEventFor:self]) ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3362
                                                            Processor activeProcess millisecondDelay:40.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3363
                                                        ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3364
                                                    ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3365
                                                    self cursorLine:savLine col:savCol
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3366
                                                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3367
                                           ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3368
                                ifNotFound:[self showNotFound]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3369
                                   onError:[self beep]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3370
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3371
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3372
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3373
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3374
    ].                         
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3375
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3376
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3377
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3378
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3379
     Fn      pastes a key-sequence (but only if not overlayed with
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3380
             another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3381
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3382
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3383
    "
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  3384
    (key at:1) asLowercase == $f ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3385
        (('[fF][0-9]' match:key)
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3386
        or:['[fF][0-9][0-9]' match:key]) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3387
            shifted ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3388
                fKeyMacros := UserPreferences current functionKeySequences.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3389
                fKeyMacros notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3390
                    (fKeyMacros includesKey:key) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3391
                        self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3392
                        ^ self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3393
                    ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3394
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3395
            ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3396
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3397
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3398
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  3399
    (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
  3400
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3401
    ((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3402
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3403
    (key == #Again) ifTrue:[self again. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3404
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3405
    (key == #Replace) ifTrue:[self replace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3406
    (key == #SelectWord) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3407
        self makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3408
        ^ self selectWordUnderCursor. 
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3409
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3410
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3411
    (key == #SearchMatchingParent) ifTrue:[^ self searchForMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3412
    (key == #SelectMatchingParents) ifTrue:[^ self searchForAndSelectMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3413
    (key == #SelectToEnd) ifTrue:[^ self selectUpToEnd.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3414
    (key == #SelectFromBeginning) ifTrue:[^ self selectFromBeginning.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3415
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3416
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3417
  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
  3418
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  3419
    (key == #Ctrlb) ifTrue:[self unselect. self cursorLeft. ^ self].
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  3420
    (key == #Ctrlf) ifTrue:[self unselect. self cursorRight. ^ self].
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  3421
    (key == #Ctrln) ifTrue:[self unselect. self cursorDown. ^ self].
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  3422
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3423
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3424
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  3425
    (key == #BeginOfLine) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3426
        self unselect.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3427
        shifted ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3428
            self cursorHome
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3429
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3430
            self cursorToBeginOfLine. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3431
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3432
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  3433
    ].
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  3434
    (key == #EndOfLine) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3435
        self unselect.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3436
        shifted ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3437
            self cursorToBottom
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3438
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3439
            self cursorToEndOfLine. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3440
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3441
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  3442
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3443
    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  3444
    (key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3445
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3446
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3447
    (key == #CursorRight) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3448
        (shifted and:[selectionStartLine isNil]) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3449
            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3450
            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3451
            expandingTop := false.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3452
            ^ self redrawLine:selectionStartLine. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3453
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3454
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3455
        selectionStartLine notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3456
            self cursorMovementAllowed ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3457
                "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3458
                "/ treat the whole selection as cursor
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3459
                "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3460
                cursorLine := selectionEndLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3461
                cursorVisibleLine := self listLineToVisibleLine:cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3462
                selectionEndCol == 0 ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3463
                    selectionEndCol := 1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3464
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3465
                cursorCol := selectionEndCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3466
                shifted ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3467
                    self expandSelectionRight.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3468
                    ^ self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3469
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3470
                self unselect; makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3471
                cursorCol == 1 ifTrue:[^ self].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3472
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3473
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3474
        self cursorRight. ^self
121
claus
parents: 118
diff changeset
  3475
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3476
    (key == #CursorDown) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3477
        (shifted and:[selectionStartLine isNil]) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3478
            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3479
            selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3480
            self redrawLine:selectionStartLine. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3481
            expandingTop := false.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3482
            ^ self redrawLine:selectionEndLine. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3483
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3484
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3485
        selectionStartLine notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3486
            self cursorMovementAllowed ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3487
                "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3488
                "/ treat the whole selection as cursor
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3489
                "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3490
                cursorLine := selectionEndLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3491
                cursorVisibleLine := self listLineToVisibleLine:cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3492
                cursorCol := selectionStartCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3493
                cursorCol == 0 ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3494
                    cursorCol := 1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3495
                    cursorLine := cursorLine - 1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3496
                    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3497
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3498
                self makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3499
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3500
                shifted ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3501
                    clickLine := cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3502
                    clickCol := cursorCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3503
                    self expandSelectionDown.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3504
                    ^ self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3505
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3506
                self unselect. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3507
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3508
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3509
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3510
        sensor isNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3511
            n := 1
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3512
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3513
            n := 1 + (sensor compressKeyPressEventsWithKey:#CursorDown).
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3514
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3515
        self cursorDown:n. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3516
        "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3517
        "/ flush keyboard to avoid runaway cursor
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3518
        "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3519
        sensor notNil ifTrue:[self sensor flushKeyboardFor:self].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3520
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3521
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3522
    (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3523
        (shifted and:[selectionStartLine isNil]) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3524
            expandingTop := true.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3525
            key == #CursorLeft ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3526
                cursorCol > 1 ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3527
                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3528
                    selectionEndCol := clickStartCol := cursorCol-1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3529
                    selectionStartCol := cursorCol-1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3530
                    ^ self redrawLine:selectionStartLine. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3531
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3532
            ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3533
                cursorLine > 1 ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3534
                    selectionEndLine := clickStartLine := cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3535
                    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3536
                    selectionStartLine := cursorLine - 1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3537
                    ^ self redrawFromLine:selectionStartLine to:cursorLine. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3538
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3539
            ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3540
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3541
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3542
        selectionStartLine notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3543
            self cursorMovementAllowed ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3544
                "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3545
                "/ treat the whole selection as cursor
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3546
                "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3547
                cursorLine := selectionStartLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3548
                cursorVisibleLine := self listLineToVisibleLine:cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3549
                cursorCol := selectionStartCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3550
                (key == #CursorLeft) ifTrue:[    
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3551
                    cursorCol := cursorCol+1.  "/ compensate for followup crsr-left
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3552
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3553
                self makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3554
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3555
                shifted ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3556
                    (key == #CursorUp) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3557
                        clickLine := cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3558
                        ^ self expandSelectionUp.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3559
                    ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3560
                    ^ self expandSelectionLeft.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3561
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3562
                self unselect. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3563
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3564
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3565
        (key == #CursorLeft) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3566
            self cursorLeft. ^self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3567
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3568
        (key == #CursorUp)        ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3569
            sensor isNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3570
                n := 1
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3571
            ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3572
                n := 1 + (sensor compressKeyPressEventsWithKey:#CursorUp).
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3573
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3574
            self cursorUp:n. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3575
            "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3576
            "/ flush keyboard to avoid runaway cursor
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3577
            "/
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3578
            sensor notNil ifTrue:[sensor flushKeyboardFor:self].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3579
            ^ self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3580
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3581
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3582
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3583
    (key == #Return)    ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3584
        shifted ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3585
            self unselect. self cursorReturn. ^self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3586
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3587
        self isReadOnly ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3588
            self unselect; makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3589
            self cursorReturn
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3590
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3591
            insertMode ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3592
                self cursorReturn.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3593
                autoIndent == true ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3594
                    i := self leftIndentForLine:(cursorLine + 1).
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3595
                    self cursorCol:(i+1 max:1)
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3596
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3597
            ] ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3598
                "/ old version just unselected ...
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3599
                "/ self unselect; makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3600
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3601
                "/ new version deletes ...
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3602
                typeOfSelection == #paste ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3603
                    self unselect; makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3604
                ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3605
                    self copyAndDeleteSelection.            
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3606
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3607
                self insertCharAtCursor:(Character cr). 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3608
                autoIndent == true ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3609
                    i := self leftIndentForLine:cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3610
                    self indentFromLine:cursorLine toLine:cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3611
                    self cursorCol:(i+1 max:1)
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3612
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3613
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3614
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3615
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3616
    ].
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
  3617
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3618
    (key == #Tab) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3619
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3620
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3621
        shifted ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3622
            "
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3623
             the old version used shift-tab as backtab,
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3624
             however, backtab was seldom used.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3625
             An alternative is to make it a non-inserting tab ...
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3626
            "
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3627
            "/ self unselect. self cursorBacktab.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3628
            self unselect. self cursorTab. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3629
            ^self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3630
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3631
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3632
        "
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3633
         uncomment line below, if you like RAND/INed/MAXed editor behavior
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3634
         (where tab-key is only cursor positioning)
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3635
         this was the original behavior of the TAB key, but many people
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3636
         complained ....
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3637
        "
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3638
        insertMode ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3639
            self unselect. self cursorTab. ^self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3640
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3641
        self unselect. self insertTabAtCursor. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3642
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3643
    ].
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
  3644
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  3645
    (key == #Delete
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  3646
     or:[key == #BasicDelete]) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3647
        selectionStartLine notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3648
            (key == #BasicDelete) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3649
                ^ self deleteSelection.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3650
            ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3651
                ^ self copyAndDeleteSelection.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3652
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3653
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3654
        self makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3655
        self deleteCharAtCursor. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3656
    ].
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
  3657
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3658
    (key == #BeginOfText) ifTrue:[     "i.e. HOME"
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3659
        self unselect. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3660
        cursorVisibleLine == 1 ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3661
            self cursorHome.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3662
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3663
            self cursorToFirstVisibleLine
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3664
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3665
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3666
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3667
    (key == #EndOfText) ifTrue:[       "i.e. END"
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3668
        self unselect.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3669
        cursorVisibleLine == nFullLinesShown ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3670
            self cursorToBottom.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3671
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3672
            self cursorToLastVisibleLine
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3673
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3674
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3675
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3676
    ((key == #Escape)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3677
    or:[key == #SelectLineFromBeginning])    ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3678
        self makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3679
        self unselect. self selectCursorLineFromBeginning. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3680
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3681
    (key == #SelectLine)    ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3682
        self makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3683
        self unselect. self selectCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3684
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3685
    (key == #ExpandSelectionByLine)    ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3686
"/        self makeCursorVisible.
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3687
        self selectExpandCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3688
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3689
    (key == #DeleteLine)    ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3690
        self makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3691
        self unselect. self deleteCursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3692
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3693
    (key == #InsertLine)    ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3694
        self makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3695
        self unselect. self insertLine:nil before:cursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3696
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3697
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3698
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3699
    "Modified: / 6.2.1998 / 11:59:59 / stefan"
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3700
    "Modified: / 22.2.2000 / 23:01:23 / cg"
121
claus
parents: 118
diff changeset
  3701
!
claus
parents: 118
diff changeset
  3702
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3703
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3704
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3705
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3706
    super mapped.
915
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  3707
"/    self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3708
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
915
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  3709
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  3710
    "Modified: 20.12.1996 / 14:15:56 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3711
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3712
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3713
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3714
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3715
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3716
    |cv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3717
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3718
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3719
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3720
    cv notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3721
        self makeLineVisible:cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3722
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3723
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3724
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3725
!EditTextView methodsFor:'focus handling'!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3726
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3727
hasKeyboardFocus:aBoolean
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3728
    "sent by the windowGroup, a delegate or myself to make me show a block cursor
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3729
     (otherwise, I would not know about this)"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3730
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3731
    hasKeyboardFocus := aBoolean.
1816
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  3732
    (cursorShown 
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  3733
    and:[self enabled 
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  3734
    and:[readOnly value not]]) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  3735
        self drawCursor
1816
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  3736
    ].
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  3737
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  3738
    "Modified: / 23.3.1999 / 13:49:35 / cg"
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3739
!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3740
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3741
showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3742
    "in addition to however my superclass thinks how a focusView is to be
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3743
     displayed, show the cursor when I got the focus"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3744
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3745
    self showCursor.
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3746
    self hasKeyboardFocus:true.
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3747
    super showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3748
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3749
    "Modified: 11.12.1996 / 16:56:54 / cg"
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3750
!
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3751
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3752
wantsFocusWithPointerEnter
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3753
    "return true, if I want the focus when
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3754
     the mouse pointer enters"
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3755
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3756
    |pref|
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3757
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3758
    pref := UserPreferences current focusFollowsMouse.
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3759
    (pref ~~ false
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3760
    and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true)
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3761
    and:[self enabled 
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3762
    and:[readOnly not]]]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3763
        ^ true
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3764
    ].
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3765
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3766
    ^ false
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3767
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3768
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  3769
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3770
! !
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  3771
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3772
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3773
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3774
indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3775
    "indent selected line-range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3776
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3777
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3778
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3779
    selectionStartLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3780
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3781
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3782
    (selectionEndCol == 0) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3783
        end := end - 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3784
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3785
    self unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3786
    self indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3787
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3788
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3789
indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3790
    "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
  3791
     last non-empty line before start, and change the indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3792
     of the line based on that indent."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3793
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3794
    |leftStart delta d line spaces|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3795
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3796
    leftStart := self leftIndentForLine:start.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3797
    (leftStart == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3798
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3799
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3800
    (delta == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3801
    (delta > 0) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3802
        spaces := String new:delta
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3803
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3804
    start to:end do:[:lineNr |
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3805
        line := self listAt:lineNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3806
        line notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3807
            line isBlank ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3808
                list at:lineNr put:nil
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3809
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3810
                (delta > 0) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3811
                    line := spaces , line.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3812
                    widthOfWidestLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3813
                        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3814
                    ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3815
                ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3816
                    "check if deletion is ok"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3817
                    d := delta negated + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3818
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3819
                    line size > d ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3820
                        (line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3821
                            line := line copyFrom:d
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3822
                        ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3823
                    ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3824
                    widthOfWidestLine := nil
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3825
                ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3826
                list at:lineNr put:line.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3827
                self textChanged.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3828
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3829
        ]
121
claus
parents: 118
diff changeset
  3830
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3831
    self redrawFromLine:start to:end
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3832
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3833
    "Modified: 5.3.1996 / 14:59:18 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3834
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3835
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3836
leftIndentForLine:lineNr
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3837
    "find an appropriate indent for a line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3838
     this is done by searching for the last non-empty line before it
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3839
     and returning its indent."
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3840
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3841
    "SHOULD GO TO ListView"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3842
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3843
    |line lnr indent|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3844
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3845
    lnr := lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3846
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3847
    [lnr ~~ 1] whileTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3848
        lnr  := lnr - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3849
        line := self listAt:lnr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3850
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3851
        line notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3852
            indent := line indexOfNonSeparatorStartingAt:1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3853
            indent ~~ 0 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3854
                ^ indent - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3855
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3856
        ]
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3857
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3858
    ^ 0
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3859
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3860
    "Created: 5.3.1996 / 14:58:53 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3861
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3862
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3863
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3864
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3865
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3866
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3867
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3868
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3869
1993
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  3870
    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device].
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  3871
    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device].
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  3872
    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3873
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3874
    "Created: 14.1.1997 / 00:15:24 / cg"
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3875
    "Modified: 18.2.1997 / 15:02:46 / cg"
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3876
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3877
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3878
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3879
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3880
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3881
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3882
    self enableEnterLeaveEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3883
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3884
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3885
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3886
    "initialize style specific stuff"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3887
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3888
    super initStyle.
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  3889
    lineSpacing := 1.       "/ for underwave - also looks better
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3890
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3891
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3892
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3893
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3894
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3895
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  3896
    cursorType := cursorTypeNoFocus := DefaultCursorType.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3897
    DefaultCursorTypeNoFocus notNil ifTrue:[
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  3898
        cursorTypeNoFocus := DefaultCursorTypeNoFocus.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3899
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3900
    cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3901
    cursorNoFocusFgColor isNil ifTrue:[
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  3902
        cursorType ~~ #block ifTrue:[
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  3903
            cursorNoFocusFgColor := cursorBgColor
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  3904
        ] ifFalse:[
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  3905
            cursorNoFocusFgColor := cursorFgColor
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  3906
        ]
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3907
    ].
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3908
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  3909
    "Modified: / 15.12.1999 / 22:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3910
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3911
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3912
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3913
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3914
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3915
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3916
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3917
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3918
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3919
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3920
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3921
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3922
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3923
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3924
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3925
    cursorCol := 1.
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  3926
    modifiedChannel := ValueHolder with:false.
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  3927
    acceptChannel := ValueHolder with:false.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  3928
    acceptChannel addDependent:self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3929
    showMatchingParenthesis := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3930
    hasKeyboardFocus := false. "/ true.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3931
    tabMeansNextField := false.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3932
    autoIndent := false.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3933
    insertMode := true.
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  3934
    st80Mode := ST80Mode.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  3935
    trimBlankLines := st80Mode not. "true."
2131
858209ba8509 cursor movement default
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
  3936
    cursorMovementWhenUpdating := #beginOfText.
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  3937
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  3938
    "Modified: / 6.2.2000 / 15:06:03 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3939
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3940
121
claus
parents: 118
diff changeset
  3941
!EditTextView methodsFor:'menu actions'!
claus
parents: 118
diff changeset
  3942
claus
parents: 118
diff changeset
  3943
cut
claus
parents: 118
diff changeset
  3944
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  3945
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  3946
    |line col history sel s|
121
claus
parents: 118
diff changeset
  3947
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3948
    (self checkModificationsAllowed) ifFalse:[
2121
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3949
        self flash.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3950
        ^ self
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3951
    ].
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3952
121
claus
parents: 118
diff changeset
  3953
    sel := self selection.
claus
parents: 118
diff changeset
  3954
    sel notNil ifTrue:[
2121
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3955
        lastString := s := sel asStringWithCRs.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3956
        line := selectionStartLine.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3957
        col := selectionStartCol.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3958
        undoAction := [ 
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3959
                        self cursorLine:line col:col.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3960
                        self paste:sel "/ (Array with:s) withCR:false.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3961
                      ].
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3962
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3963
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3964
         remember in CopyBuffer
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3965
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3966
        self setTextSelection:sel. "/ lastString.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3967
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3968
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3969
         append to DeleteHistory (if there is one)
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3970
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3971
        history := Smalltalk at:#DeleteHistory.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3972
        history notNil ifTrue:[
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3973
            history addAll:(sel asStringCollection).
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3974
            history size > 1000 ifTrue:[
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3975
                history := history copyFrom:(history size - 1000)
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3976
            ].
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3977
        ].
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3978
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3979
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3980
         now, delete it
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3981
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3982
        self deleteSelection.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3983
        lastReplacement := nil
121
claus
parents: 118
diff changeset
  3984
    ] ifFalse:[
2121
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3985
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3986
         a cut without selection will search&cut again
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3987
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  3988
        self again
121
claus
parents: 118
diff changeset
  3989
    ]
1290
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3990
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3991
    "Modified: / 5.4.1998 / 16:51:53 / cg"
121
claus
parents: 118
diff changeset
  3992
!
claus
parents: 118
diff changeset
  3993
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3994
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3995
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3996
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3997
    cursorLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3998
        ^ cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3999
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4000
    ^ super defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4001
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4002
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4003
editMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4004
    "return the views middleButtonMenu"
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4005
488
d10fe3a5f0cf resources
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
  4006
    <resource: #keyboard (#Again #Copy #Cut #Paste #Accept #Find #GotoLine #SaveAs #Print)>
1261
bdb18f73205c resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1198
diff changeset
  4007
    <resource: #programMenu>
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1049
diff changeset
  4008
1809
111f603c0a1c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1807
diff changeset
  4009
    |items m sub sensor|
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  4010
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  4011
    ((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4012
        items := #(
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4013
                        ('Again (for all)'      multipleAgain)  
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4014
                  ).
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4015
    ] ifFalse:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4016
        undoAction notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4017
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4018
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4019
        items := #(
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4020
                        ('Again'   again            Again  )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4021
                        ('-'                               )
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4022
                        ('Copy'    copySelection    Copy   )
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4023
                        ('Cut'     cut              Cut    )
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4024
                        ('Paste'   pasteOrReplace   Paste  )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4025
                        ('-'                               )
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4026
                        ('Accept'  accept           Accept )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4027
                        ('='                               )
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4028
                        ('Others'  others                  )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4029
                  ).
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4030
        undoAction notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4031
            items := #(
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4032
                        ('Undo'     undo                   )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4033
                      ) , items
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4034
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4035
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4036
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4037
1546
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  4038
    m := PopUpMenu itemList:items resources:resources.
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  4039
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  4040
    items := #(
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4041
                    ('Search ...'    search         Find         )
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4042
                    ('Goto ...'      gotoLine       GotoLine     )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4043
                    ('-'                                         )
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4044
                    ('Font ...'      changeFont                  )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4045
                    ('-'                                         )
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4046
                    ('Indent'        indent                      )
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4047
                    ('AutoIndent \c' autoIndent:                 )
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4048
                    ('InsertMode \c' insertMode:                 )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4049
                    ('-'                                         )
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4050
                    ('Save as ...'   save           SaveAs       )
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4051
                    ('Print'         doPrint        Print        )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4052
              ).
1546
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  4053
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  4054
    sub := PopUpMenu itemList:items resources:resources performer:model.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4055
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4056
    m subMenuAt:#others put:sub.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4057
    sub checkToggleAt:#autoIndent: put:autoIndent.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4058
    sub checkToggleAt:#insertMode: put:insertMode.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4059
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  4060
    self isReadOnly ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4061
        m disableAll:#(paste pasteOrReplace cut indent autoIndent: insertMode:)
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4062
    ].
2350
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  4063
    self hasSelectionForCopy not ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4064
        m disable:#copySelection.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4065
    ].
2350
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
  4066
    self hasSelection not ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4067
        m disable:#cut.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4068
    ].
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  4069
    (undoAction isNil) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4070
        m disable:#undo.
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  4071
    ].
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  4072
    acceptEnabled == false ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4073
        m disable:#accept
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  4074
    ].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4075
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4076
1546
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  4077
    "Modified: / 21.5.1998 / 15:52:38 / cg"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4078
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4079
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4080
paste
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4081
    "paste the copybuffer; if there is a selection, unselect first.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4082
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4083
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4084
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4085
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  4086
    self checkModificationsAllowed ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4087
        self flash.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4088
        ^ self
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  4089
    ].
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4090
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4091
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4092
    self unselect.  
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4093
    sel notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4094
        self paste:sel.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4095
    ]
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4096
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4097
    "Modified: / 5.4.1998 / 16:55:02 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4098
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4099
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4100
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4101
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4102
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  4103
    |s nLines startLine startCol l1 l2 c1 c2|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4104
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4105
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4106
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4107
    someText notNil ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4108
        s := someText.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4109
        s isString ifTrue:[
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  4110
            s := s asStringCollection.
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  4111
            (someText endsWith:Character cr) ifTrue:[    
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  4112
                s := s copyWith:''
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  4113
            ]            
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4114
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4115
            (s isStringCollection) ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4116
                self warn:'selection (' , s class name , ') is not convertable to Text'.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4117
                ^ self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4118
            ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4119
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4120
        (nLines := s size) == 0 ifTrue:[^ self].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4121
        (nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4122
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4123
        startLine := l1 := cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4124
        startCol := c1 := cursorCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4125
        self insertLines:(s withTabsExpanded) withCR:false.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4126
        l2 := cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4127
        c2 := (cursorCol - 1).
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4128
        self selectFromLine:l1 col:c1 toLine:l2 col:c2.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4129
        typeOfSelection := #paste.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4130
        undoAction := [ 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4131
                        self unselect.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4132
                        self deleteFromLine:l1 col:c1 toLine:l2 col:c2.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4133
                        self cursorLine:l1 col:c1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4134
                      ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4135
    ]
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  4136
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4137
    "Modified: / 14.2.1996 / 11:14:14 / stefan"
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  4138
    "Modified: / 30.1.2000 / 02:32:42 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4139
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4140
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4141
pasteOrReplace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4142
    "paste the copybuffer; if there is a selection, replace it.
2010
ca8dcc8723dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  4143
     otherwise paste at cursor position. 
ca8dcc8723dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  4144
     Replace is not done for selections which were created by a paste, 
ca8dcc8723dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  4145
     to allow multiple paste operations in a row."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4146
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4147
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4148
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  4149
    self checkModificationsAllowed ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4150
        self flash.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4151
        ^ self
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  4152
    ].
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4153
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4154
    sel := self getTextSelection.
2010
ca8dcc8723dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  4155
    sel notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4156
        self pasteOrReplace:sel.
2010
ca8dcc8723dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  4157
    ].
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4158
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4159
    "Modified: / 5.4.1998 / 16:55:16 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4160
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4161
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4162
pasteOrReplace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4163
    "paste someText; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4164
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4165
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4166
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4167
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4168
    self checkModificationsAllowed ifFalse:[^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4169
    ((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  4170
        ^ self replace:someText
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4171
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4172
    self paste:someText.
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4173
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  4174
    "Modified: / 30.1.2000 / 02:33:00 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4175
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4176
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4177
replace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4178
    "replace the selection by the contents of the copybuffer"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4179
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4180
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4181
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4182
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4183
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4184
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4185
    sel notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4186
        self replace:sel
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4187
    ]
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4188
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4189
    "Modified: / 5.4.1998 / 16:55:24 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4190
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4191
121
claus
parents: 118
diff changeset
  4192
replace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4193
    "replace the selection by someText"
121
claus
parents: 118
diff changeset
  4194
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4195
    |selected selectedString 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4196
     selStartLine selStartCol selEndLine selEndCol pasteUndoAction| 
121
claus
parents: 118
diff changeset
  4197
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4198
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4199
121
claus
parents: 118
diff changeset
  4200
    selected := self selection.
claus
parents: 118
diff changeset
  4201
    selected isNil ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4202
        ^ self paste:someText
121
claus
parents: 118
diff changeset
  4203
    ].
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4204
121
claus
parents: 118
diff changeset
  4205
    self deleteSelection.
claus
parents: 118
diff changeset
  4206
claus
parents: 118
diff changeset
  4207
    "take care, if we replace a selection without space by a word selected
claus
parents: 118
diff changeset
  4208
     with one - in this case we usually do not want the space.
claus
parents: 118
diff changeset
  4209
     But, if we replace a word-selected selection by something without a
claus
parents: 118
diff changeset
  4210
     space, we DO want the space added."
claus
parents: 118
diff changeset
  4211
claus
parents: 118
diff changeset
  4212
    selected size == 1 ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4213
        selectedString := selected at:1.
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  4214
    ].
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  4215
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  4216
    someText size == 1 ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4217
        |cutOffSpace addSpace replacement replacementString|
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4218
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4219
        cutOffSpace := false.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4220
        addSpace := false.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4221
        replacement := someText copy.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4222
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4223
        selectedString notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4224
            ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4225
               "selection has no space"
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4226
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4227
                ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4228
                    cutOffSpace := true
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4229
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4230
            ] ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4231
                addSpace := true
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4232
            ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4233
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4234
        replacementString := replacement at:1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4235
        cutOffSpace ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4236
            (replacementString startsWith:' ') ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4237
                replacementString := replacementString withoutSpaces
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4238
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4239
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4240
            selectStyle == #wordLeft ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4241
                "want a space at left"
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4242
                (replacementString startsWith:' ') ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4243
                    replacementString := replacementString withoutSpaces.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4244
                    replacementString := ' ' , replacementString
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4245
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4246
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4247
            selectStyle == #wordRight ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4248
                "want a space at right"
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4249
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4250
                (replacementString endsWith:' ') ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4251
                    replacementString := replacementString withoutSpaces.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4252
                    replacementString := replacementString , ' '
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4253
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4254
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4255
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4256
        replacement at:1 put: replacementString.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4257
        self paste:replacement.
121
claus
parents: 118
diff changeset
  4258
    ] ifFalse:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4259
        self paste:someText
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  4260
    ].
121
claus
parents: 118
diff changeset
  4261
    lastString := selectedString.
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4262
    lastReplacement := someText.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4263
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4264
    selStartLine := selectionStartLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4265
    selStartCol := self selectionStartCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4266
    selEndLine := selectionEndLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4267
    selEndCol := self selectionEndCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4268
    pasteUndoAction := undoAction.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4269
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4270
    undoAction := [
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4271
                    pasteUndoAction value.    
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4272
                    self cursorLine:selStartLine col:selEndLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4273
                    self paste:selected.    
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4274
                  ].
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  4275
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4276
    "Modified: / 14.2.1996 / 10:37:02 / stefan"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4277
    "Modified: / 5.4.1998 / 16:55:28 / cg"
121
claus
parents: 118
diff changeset
  4278
!
claus
parents: 118
diff changeset
  4279
claus
parents: 118
diff changeset
  4280
showDeleted
claus
parents: 118
diff changeset
  4281
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  4282
claus
parents: 118
diff changeset
  4283
    |v|
claus
parents: 118
diff changeset
  4284
claus
parents: 118
diff changeset
  4285
    v := EditTextView openWith:(Smalltalk at:#DeleteHistory).
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  4286
    v readOnly:true.
121
claus
parents: 118
diff changeset
  4287
    v topView label:'deleted text'.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4288
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4289
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4290
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4291
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  4292
checkModificationsAllowed
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  4293
    "check if the text can be modified (i.e. is not readOnly).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  4294
     evaluate the exceptionBlock if not.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  4295
     This block should be provided by the application or user of the textView,
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  4296
     and may show a warnBox or whatever."
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  4297
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  4298
    self isReadOnly ifTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4299
        exceptionBlock isNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4300
            ^ false
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4301
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4302
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4303
        (exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4304
            ^ false
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4305
        ]
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  4306
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  4307
    ^ true
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  4308
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  4309
    "Modified: / 17.6.1998 / 15:51:10 / cg"
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  4310
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  4311
2225
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  4312
suppressEmphasisInSelection
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  4313
    "selection is shown without emphasis"
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  4314
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  4315
    ^ true
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  4316
!
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  4317
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4318
textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  4319
    "my text was modified (internally).
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  4320
     Sent whenever text has been edited (not to confuse with
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4321
     contentsChanged, which is triggered when the size has changed, and
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4322
     is used to notify scrollers, other views etc.)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4323
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  4324
    self contentsChanged.
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  4325
    self modified:true.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4326
    contentsWasSaved := false
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  4327
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  4328
    "Modified: 14.2.1997 / 16:58:38 / cg"
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4329
!
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4330
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4331
textChangedButNoSizeChane
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4332
    "my text was modified (internally).
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4333
     Sent whenever text has been edited (not to confuse with
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4334
     contentsChanged, which is triggered when the size has changed, and
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4335
     is used to notify scrollers, other views etc.)"
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4336
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4337
    self modified:true.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4338
    contentsWasSaved := false
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4339
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  4340
    "Modified: 14.2.1997 / 16:58:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4341
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4342
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4343
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4344
1526
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  4345
currentLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  4346
    "the current line (for relative gotos)"
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  4347
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  4348
    ^ cursorLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  4349
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  4350
    "Created: / 17.5.1998 / 20:07:52 / cg"
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  4351
!
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  4352
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  4353
isKeyboardConsumer
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  4354
    "return true, if the receiver is a keyboard consumer;
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  4355
     Return true here, redefined from SimpleView."
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  4356
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  4357
    ^ true
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  4358
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  4359
!
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  4360
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  4361
specClass
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  4362
    "redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)"
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  4363
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  4364
    self class == EditTextView ifTrue:[^ TextEditorSpec].
1049
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  4365
    ^ super specClass
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  4366
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  4367
    "Modified: / 31.10.1997 / 19:48:19 / cg"
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  4368
!
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  4369
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  4370
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  4371
    "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
  4372
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  4373
    "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
  4374
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  4375
    ^ self isReadOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  4376
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  4377
    "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
  4378
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  4379
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4380
widthOfContents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4381
    "return the width of the contents in pixels
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4382
     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
  4383
     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
  4384
     line (and possibly see the cursor behind the line)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4385
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  4386
    |w dev|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4387
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4388
    w := super widthOfContents.
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  4389
    (dev := device) isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4390
        "/ really dont know ...
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4391
        dev := Screen current
606
682579fa3b62 fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  4392
    ].
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  4393
    ^ w + (font widthOn:dev)
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  4394
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  4395
    "Modified: 28.5.1996 / 19:32:25 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4396
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4397
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4398
!EditTextView methodsFor:'realization'!
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4399
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4400
realize
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4401
    "make the view visible - scroll to make the cursor visible."
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4402
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4403
    super realize.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4404
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4405
    self makeCursorVisible.
1993
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  4406
    cursorFgColor := cursorFgColor onDevice:device.
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  4407
    cursorBgColor := cursorBgColor onDevice:device.
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4408
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4409
    "Modified: 20.12.1996 / 14:16:05 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4410
    "Created: 24.7.1997 / 18:24:12 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4411
! !
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  4412
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4413
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4414
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4415
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4416
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4417
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4418
    cursorShown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4419
        cursorVisibleLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4420
            (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4421
                self drawCursorCharacter
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4422
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4423
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4424
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4425
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4426
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4427
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4428
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4429
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4430
    cursorShown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4431
        (visLine == cursorVisibleLine) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4432
            self drawCursorCharacter
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4433
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4434
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4435
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4436
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4437
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4438
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4439
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4440
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4441
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4442
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4443
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4444
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4445
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4446
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4447
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4448
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4449
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4450
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4451
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4452
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4453
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4454
    cursorShown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4455
        (visLine == cursorVisibleLine) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4456
            (colNr == cursorCol) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4457
                self drawCursorCharacter.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4458
                ^ self
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4459
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4460
        ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4461
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4462
    super redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4463
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4464
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4465
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4466
    "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
  4467
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4468
    super redrawVisibleLine:visLine from:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4469
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4470
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4471
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4472
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4473
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4474
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4475
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4476
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4477
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4478
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4479
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4480
2331
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4481
additionalMarginForHorizontalScroll
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4482
    "return the number of pixels by which we may scroll more than the actual
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4483
     width of the document would allow.
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4484
     This is redefined by editable textViews, to allo for the cursor
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4485
     to be visible if it is positioned right behind the longest line of text.
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4486
     The default returned here is 10 pixels, which should be ok for most cursors"
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4487
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4488
    ^ 10 max:font width
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4489
!
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  4490
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4491
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4492
    "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
  4493
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4494
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4495
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4496
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4497
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4498
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4499
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4500
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4501
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4502
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4503
    "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
  4504
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4505
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4506
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4507
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4508
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4509
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4510
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4511
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4512
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4513
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4514
    "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
  4515
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4516
    super originChanged:delta.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4517
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4518
     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
  4519
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4520
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4521
    prevCursorState ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4522
        self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4523
    ]
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  4524
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  4525
    "Modified: / 17.6.1998 / 16:13:24 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4526
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4527
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4528
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4529
    "sent before scrolling - have to hide the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4530
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4531
    prevCursorState := cursorShown.
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  4532
    "/ cursorShown := false.
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  4533
    cursorShown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4534
        self hideCursor
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  4535
    ]
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  4536
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  4537
    "Modified: / 6.7.1998 / 13:07:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4538
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4539
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4540
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4541
    "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
  4542
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4543
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4544
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4545
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4546
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4547
    super pageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4548
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4549
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4550
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4551
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4552
    "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
  4553
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4554
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4555
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4556
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4557
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4558
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4559
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4560
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4561
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4562
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4563
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4564
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4565
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4566
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4567
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4568
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4569
    cursorLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4570
    selectionStartLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4571
        startLine := selectionStartLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4572
        startCol := selectionStartCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4573
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4574
        startLine := cursorLine min:list size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4575
        startCol := cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4576
    ].
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4577
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4578
        searchBackwardFor:pattern 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4579
        startingAtLine:startLine col:startCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4580
        ifFound:[:line :col |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4581
            self cursorLine:line col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4582
            self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4583
"/            self makeLineVisible:cursorLine
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4584
            typeOfSelection := #search] 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4585
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4586
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4587
    "Modified: 9.10.1997 / 13:02:04 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4588
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4589
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4590
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4591
    "do a backward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4592
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4593
    |startLine startCol|
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4594
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4595
    cursorLine isNil ifTrue:[^ self].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4596
    selectionStartLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4597
        startLine := selectionStartLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4598
        startCol := selectionStartCol
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4599
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4600
        startLine := cursorLine min:list size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4601
        startCol := cursorCol
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4602
    ].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4603
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4604
        searchBackwardFor:pattern
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4605
        ignoreCase:ign
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4606
        startingAtLine:startLine col:startCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4607
        ifFound:[:line :col |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4608
            self cursorLine:line col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4609
            self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4610
"/            self makeLineVisible:cursorLine
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4611
            typeOfSelection := #search] 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4612
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4613
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4614
    "Modified: 9.10.1997 / 13:02:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4615
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4616
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4617
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4618
    "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
  4619
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4620
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4621
        searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4622
        ifFound:[:line :col | 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4623
                  self selectFromLine:cursorLine col:cursorCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4624
                               toLine:line col:col]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4625
        ifNotFound:[self showNotFound]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4626
        onError:[self beep]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4627
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4628
    "Modified: 9.10.1997 / 12:57:34 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4629
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4630
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4631
searchForMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4632
    "search for a matching parenthesis starting at cursor position. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4633
     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
  4634
     backwards if its a closing parenthesis.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4635
     Positions the cursor if found, peeps if not"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4636
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4637
     self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4638
        searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4639
        ifFound:[:line :col | self cursorLine:line col:col]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4640
        ifNotFound:[self showNotFound]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4641
        onError:[self beep]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4642
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4643
    "Modified: 9.10.1997 / 12:56:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4644
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4645
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4646
searchFwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4647
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4648
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4649
    |startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4650
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4651
    "/ 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
  4652
    "/ 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
  4653
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4654
    self hasSelection ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4655
        (cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4656
            startCol := 0
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4657
        ]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4658
    ].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4659
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4660
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4661
        searchFwd:pattern 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4662
        startingAtLine:cursorLine col:startCol 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4663
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4664
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4665
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4666
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4667
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4668
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4669
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4670
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4671
    |startCol|
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4672
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4673
    "/ if there is no selection and the cursor is at the origin, 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4674
    "/ assume its the first search and do not skip the very first match
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4675
    startCol := cursorCol.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4676
    self hasSelection ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4677
        (cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4678
            startCol := 0
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4679
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4680
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4681
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4682
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4683
        searchFwd:pattern
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4684
        ignoreCase:ign
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4685
        startingAtLine:cursorLine col:startCol 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4686
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4687
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4688
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4689
    "Created: 9.10.1997 / 13:04:10 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4690
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4691
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4692
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4693
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4694
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4695
    cursorLine isNil ifTrue:[^ self].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4696
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4697
        searchForwardFor:pattern 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4698
        ignoreCase:ign
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4699
        startingAtLine:startLine col:startCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4700
        ifFound:[:line :col |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4701
            self cursorLine:line col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4702
            self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4703
"/            self makeLineVisible:cursorLine
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4704
            typeOfSelection := #search]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4705
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4706
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4707
    "Modified: 9.10.1997 / 12:57:47 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4708
    "Created: 9.10.1997 / 13:01:12 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4709
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4710
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4711
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4712
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4713
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4714
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4715
        searchForwardFor:pattern 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4716
        startingAtLine:startLine col:startCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4717
        ifFound:[:line :col |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4718
            self cursorLine:line col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4719
            self showMatch:pattern atLine:line col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4720
            typeOfSelection := #search]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4721
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4722
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4723
    "Modified: 9.10.1997 / 13:07:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4724
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4725
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4726
setSearchPattern
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4727
    "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
  4728
     cursor to start of pattern"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4729
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4730
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4731
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4732
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4733
    "/ if the last operation was a replcae, set pattern to last
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4734
    "/ original string (for search after again)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4735
    "/
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  4736
    (lastString notNil 
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  4737
     and:[lastReplacement notNil
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  4738
     and:[typeOfSelection ~~ #search]]) ifTrue:[
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  4739
        lastSearchPattern := lastString asString withoutSeparators.
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  4740
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4741
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4742
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4743
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4744
    "/ if there is a selection:
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4745
    "/    if there was no previous search, take it as search pattern.
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4746
    "/    if there was a previous search, only take the selection if
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4747
    "/    it did not result from a paste.
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4748
    "/    (to allow search-paste to be repeated)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4749
    "/
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4750
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4751
    sel notNil ifTrue:[
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  4752
        (lastSearchPattern isNil
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  4753
        or:[typeOfSelection ~~ #paste]) ifTrue:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  4754
            self cursorLine:selectionStartLine col:selectionStartCol.
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  4755
            lastSearchPattern := sel asString withoutSeparators withMatchEscapes
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  4756
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4757
    ]
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4758
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  4759
    "Modified: 20.4.1996 / 12:50:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4760
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4761
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4762
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4763
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4764
autoMoveCursorToEndOfSelection
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4765
    "return true, if the cursor should be automatically moved to the
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4766
     end of a selection.
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4767
     Redefined to return false in terminaViews, where the cursor should
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4768
     not be affected by selecting"
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4769
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4770
    ^ true
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4771
!
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4772
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4773
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4774
    "select the whole text.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4775
     redefined to send super selectFrom... since we dont want the
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4776
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4777
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4778
    list isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4779
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4780
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4781
        super selectFromLine:1 col:1 toLine:(list size + 1) col:0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4782
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4783
    ]
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4784
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4785
    "Modified: 28.2.1997 / 19:14:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4786
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4787
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4788
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4789
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4790
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4791
    self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4792
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4793
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4794
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4795
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4796
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  4797
    cursorCol > 1 ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4798
        self selectFromLine:cursorLine col:1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4799
                     toLine:cursorLine col:(cursorCol-1)
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  4800
    ]
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  4801
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  4802
    "Modified: 16.8.1996 / 19:14:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4803
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4804
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4805
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4806
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4807
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4808
    selectionStartLine isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4809
        self selectCursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4810
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4811
        self selectFromLine:selectionStartLine col:selectionStartCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4812
                     toLine:cursorLine+1 col:0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4813
        self makeLineVisible:selectionEndLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4814
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4815
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4816
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4817
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4818
    "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
  4819
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4820
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4821
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4822
    list isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4823
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4824
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4825
        cursorCol == 0 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4826
            col := 0
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4827
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4828
            col := cursorCol - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4829
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4830
        super selectFromLine:1 col:1 toLine:cursorLine col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4831
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4832
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4833
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4834
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4835
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4836
    "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
  4837
     for easier editing. Also typeOfSelection is nilled here."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4838
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4839
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  4840
    (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4841
        self cursorLine:selectionEndLine col:(selectionEndCol + 1).
1198
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  4842
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4843
    typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4844
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4845
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4846
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4847
    "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
  4848
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4849
    list isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4850
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4851
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4852
        super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4853
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4854
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4855
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4856
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4857
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4858
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4859
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4860
    self selectWordAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4861
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4862
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4863
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4864
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4865
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4866
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4867
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4868
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4869
    super unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4870
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4871
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4872
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4873
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4874
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4875
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4876
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4877
     If current selection is not last string, search forward to
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4878
     next occurence of it before repeating the last operation."
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4879
2323
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4880
    |s l c sel savedSelectStyle startColForSearch|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4881
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4882
    lastString notNil ifTrue:[
2323
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4883
        s := lastString asString.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4884
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4885
        "remove final cr"
2404
9dedc6b66762 replace-again fixed (eventually!)
Claus Gittinger <cg@exept.de>
parents: 2403
diff changeset
  4886
        (s endsWith:Character cr) ifTrue:[s := s copyWithoutLast:1].
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4887
"/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
2323
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4888
        savedSelectStyle := selectStyle.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4889
        selectStyle := nil.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4890
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4891
        sel := self selection.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4892
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4893
        "if we are already there (after a find), ommit search"
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4894
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4895
        (sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4896
            undoAction := [self insertLines:lastString atLine:cursorLine col:cursorCol].
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4897
            l := selectionStartLine "cursorLine". 
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4898
            c := selectionStartCol "cursorCol".
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4899
            self deleteSelection.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4900
            lastReplacement notNil ifTrue:[
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4901
                self insertLines:lastReplacement asStringCollection withCR:false.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4902
                self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4903
            ].
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4904
            selectStyle := savedSelectStyle.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4905
            ^ true
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4906
        ].
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4907
        startColForSearch := cursorCol.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4908
        sel isNil ifTrue:[
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4909
            startColForSearch := startColForSearch - 1
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4910
        ].
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4911
        self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch 
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4912
            ifFound:
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4913
                [
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4914
                    :line :col |
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4915
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4916
                    |repl|
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4917
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4918
                    self selectFromLine:line col:col
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4919
                                 toLine:line col:(col + s size - 1).
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4920
                    self makeLineVisible:line.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4921
                    undoAction := [self insertLines:lastString atLine:line col:col].
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4922
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4923
                    self deleteSelection.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4924
                    lastReplacement notNil ifTrue:[
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4925
                        lastReplacement isString ifFalse:[
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4926
                            repl := lastReplacement asString withoutSpaces
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4927
                        ] ifTrue:[
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4928
                            repl := lastReplacement withoutSpaces.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4929
                        ].
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4930
                        self insertLines:repl asStringCollection withCR:false.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4931
                        self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4932
                    ].
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4933
                    selectStyle := savedSelectStyle.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4934
                    ^ true
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4935
                ] 
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4936
           ifAbsent:
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4937
                [
2373
b910fedbbd58 avoid annoying beeps in again
Claus Gittinger <cg@exept.de>
parents: 2363
diff changeset
  4938
                    |sensor|
b910fedbbd58 avoid annoying beeps in again
Claus Gittinger <cg@exept.de>
parents: 2363
diff changeset
  4939
b910fedbbd58 avoid annoying beeps in again
Claus Gittinger <cg@exept.de>
parents: 2363
diff changeset
  4940
                    (sensor := self sensor) notNil ifTrue:[
b910fedbbd58 avoid annoying beeps in again
Claus Gittinger <cg@exept.de>
parents: 2363
diff changeset
  4941
                        sensor compressKeyPressEventsWithKey:#Again.
b910fedbbd58 avoid annoying beeps in again
Claus Gittinger <cg@exept.de>
parents: 2363
diff changeset
  4942
                    ].
2323
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4943
                    self showNotFound.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4944
                    selectStyle := savedSelectStyle.
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4945
                    ^ false
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  4946
                ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4947
    ]
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4948
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4949
    "Modified: 9.10.1996 / 16:14:11 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4950
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4951
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4952
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4953
    "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
  4954
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4955
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4956
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4957
121
claus
parents: 118
diff changeset
  4958
undo
claus
parents: 118
diff changeset
  4959
    "currently not implemented"
claus
parents: 118
diff changeset
  4960
claus
parents: 118
diff changeset
  4961
    undoAction notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4962
        undoAction value.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4963
        undoAction := nil.
121
claus
parents: 118
diff changeset
  4964
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4965
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4966
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  4967
!EditTextView class methodsFor:'documentation'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4968
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4969
version
2406
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  4970
    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.253 2001-09-24 08:04:22 cg Exp $'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4971
! !