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