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