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