TextView.st
author Claus Gittinger <cg@exept.de>
Tue, 14 Jun 2011 14:08:52 +0200
changeset 4255 9bf0cc2595a9
parent 4254 eaf0560ba269
child 4310 ff92dd203d7e
permissions -rw-r--r--
changed: #doubleClickX:y:
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
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
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
"
2191
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    12
"{ Package: 'stx:libwidg' }"
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    13
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    14
ListView subclass:#TextView
3394
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    15
	instanceVariableNames:'selectionStartLine selectionStartCol selectionEndLine
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    16
		selectionEndCol clickPos clickStartLine clickStartCol clickLine
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    17
		clickCol clickCount expandingTop wordStartCol wordStartLine
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    18
		wordEndCol wordEndLine selectionFgColor selectionBgColor
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    19
		selectStyle directoryForFileDialog defaultFileNameForFileDialog
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    20
		externalEncoding contentsWasSaved searchAction lastSearchPattern
3964
f272bb5029f0 *** empty log message ***
fm
parents: 3914
diff changeset
    21
		lastSearchWasMatch lastSearchIgnoredCase lastSearchDirection
f272bb5029f0 *** empty log message ***
fm
parents: 3914
diff changeset
    22
		parenthesisSpecification dropSource dragIsActive saveAction
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
    23
		st80SelectMode searchBarActionBlock'
3394
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    24
	classVariableNames:'DefaultViewBackground DefaultSelectionForegroundColor
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    25
		DefaultSelectionBackgroundColor
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    26
		DefaultAlternativeSelectionForegroundColor
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    27
		DefaultAlternativeSelectionBackgroundColor MatchDelayTime
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    28
		WordSelectCatchesBlanks LastSearchPatterns
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    29
		NumRememberedSearchPatterns LastSearchIgnoredCase
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
    30
		LastSearchWasMatch DefaultParenthesisSpecification'
3394
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    31
	poolDictionaries:''
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
    32
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    33
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    34
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
    35
!TextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    36
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    37
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    38
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    39
 COPYRIGHT (c) 1989 by Claus Gittinger
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
    40
              All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    41
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    42
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    43
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    44
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    45
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    46
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    47
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    48
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    49
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    50
22
ac872628ef2d *** empty log message ***
claus
parents: 15
diff changeset
    51
documentation
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    52
"
120
claus
parents: 119
diff changeset
    53
    a view for readOnly text - this class adds selections to a simple list.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
    54
    The text is not editable and there is no cursor.
120
claus
parents: 119
diff changeset
    55
    Use TextViews for readonly text, EditTextView for editable text.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    56
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    57
    Please read the historic notice in the ListView class.
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    58
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
    59
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    60
120
claus
parents: 119
diff changeset
    61
      selectionStartLine      <Number>                the line of the selection start (or nil)
claus
parents: 119
diff changeset
    62
      selectionStartCol       <Number>                the col of the selection start
claus
parents: 119
diff changeset
    63
      selectionEndLine        <Number>                the line of the selection end
claus
parents: 119
diff changeset
    64
      selectionEndCol         <Number>                the col of the selection end
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    65
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    66
      clickStartLine          <Number>                temporary - remember where select operation started
120
claus
parents: 119
diff changeset
    67
      clickStartCol           <Number>                temporary
claus
parents: 119
diff changeset
    68
      clickLine               <Number>                temporary
claus
parents: 119
diff changeset
    69
      clickCol                <Number>                temporary
claus
parents: 119
diff changeset
    70
      clickCount              <Number>                temporary
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    71
      expandingTop            <Boolean>               temporary - for expandSelection
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    72
120
claus
parents: 119
diff changeset
    73
      selectionFgColor        <Color>                 color used to draw selections
claus
parents: 119
diff changeset
    74
      selectionBgColor        <Color>                 color used to draw selections
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    75
120
claus
parents: 119
diff changeset
    76
      selectStyle             <Symbol>                how words are selected
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    77
120
claus
parents: 119
diff changeset
    78
      directoryForFileDialog  <nil|pathName>          directory where save dialog should start
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
    79
120
claus
parents: 119
diff changeset
    80
      contentsWasSaved        <Boolean>               set to true, whenever saved in a file
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
    81
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    82
      externalEncoding        <Symbol|nil>            external encoding, used when text is saved to
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
    83
                                                      a file. Usually something like
96256221e3af support drag
ca
parents: 2581
diff changeset
    84
                                                      #jis7, #euc, #sjis etc.
96256221e3af support drag
ca
parents: 2581
diff changeset
    85
                                                      (currently only passed down from the
96256221e3af support drag
ca
parents: 2581
diff changeset
    86
                                                       fileBrowser)
96256221e3af support drag
ca
parents: 2581
diff changeset
    87
96256221e3af support drag
ca
parents: 2581
diff changeset
    88
      dropSource              <DropSource>            drag operation descriptor or nil (dragging disabled)
96256221e3af support drag
ca
parents: 2581
diff changeset
    89
      dragIsActive            <Boolean>               true, drag operation is activated  
96256221e3af support drag
ca
parents: 2581
diff changeset
    90
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
    91
      searchAction            <Block>                 an autosearch action; typically set by the browser. 
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
    92
                                                      Will be used as default when searchFwd/searchBwd is 
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
    93
                                                      pressed. If the searchPattern is changed, no autosearch 
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
    94
                                                      action will be executed.
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
    95
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
    96
      searchBarActionBlock    <Block>                 search action block for embedded search
3909
373f8a5ba609 autosearch: cleared when the first explicit search is done
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
    97
                                                      panel. Used as second chance for searchFwd/bwd
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    98
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
    99
    [class variables:]
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
   100
        ST80Selections        <Boolean>               enables ST80 style doubleclick behavior
96256221e3af support drag
ca
parents: 2581
diff changeset
   101
                                                      (right after opening parenthesis, right before
96256221e3af support drag
ca
parents: 2581
diff changeset
   102
                                                       closing parenthesis, at begin of a line
96256221e3af support drag
ca
parents: 2581
diff changeset
   103
                                                       at begin of text)
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   104
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   105
    [StyleSheet parameters:]
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   106
2600
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   107
      textView.background                       defaults to viewBackground
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   108
      textView.ViewFont                         defaults to textFont
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   109
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   110
      text.st80Selections                       st80 behavior (click on char after parent or quote)
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   111
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   112
      text.selectionForegroundColor             defaults to textBackgroundColor
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   113
      text.selectionBackgroundColor             defaults to textForegroundColor
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   114
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   115
      text.alternativeSelectionForegroundColor  pasted text (i.e. paste will not replace)
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   116
                                                defaults to selectionForegroundColor
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   117
      text.alternativeSelectionBackgroundColor  pasted text (i.e. paste will not replace)
27417bb497f3 comment
Claus Gittinger <cg@exept.de>
parents: 2596
diff changeset
   118
                                                defaults to selectionBackgroundColor
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   119
    [author:]
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
   120
        Claus Gittinger
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   121
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 504
diff changeset
   122
    [see also:]
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
   123
        EditTextView CodeView Workspace
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   124
"
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   125
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   126
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   127
examples
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   128
"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   129
    although textViews (and instances of subclasses) are mostly used
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   130
    as components (in the fileBrowser, the browser, the launcher etc.),
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   131
    they may also be opened as a textEditor;
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   132
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   133
    open a (readonly) textView on some information text:
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   134
                                                        [exBegin]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   135
        TextView 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   136
            openWith:'read this' 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   137
            title:'demonstration'
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   138
                                                        [exEnd]
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   139
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   140
    the same, but open it modal:
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   141
                                                        [exBegin]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   142
        TextView 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   143
            openModalWith:'read this first' 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   144
            title:'demonstration'
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   145
                                                        [exEnd]
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   146
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   147
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   148
    open it modal (but editable) on some text:
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   149
    (must accept before closing)
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   150
    This is somewhat kludgy - when closed, the view has already
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   151
    nilled its link to the model. Therefore, the accept must be
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   152
    done 'manually' below.
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   153
    However, usually an applicationModel is installed as the
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   154
    editor-topViews application. This would get a closeRequest,
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   155
    where it could handle things.
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   156
                                                        [exBegin]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   157
        |m textView|
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   158
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   159
        m := 'read this first' asValue.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   160
        textView := EditTextView openModalOnModel:m.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   161
        textView modified ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   162
            (self confirm:'text was not accepted - do it now ?')
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   163
            ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   164
                m value:textView contents
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   165
            ]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   166
        ].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   167
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   168
        Transcript showCR:m value.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   169
                                                        [exEnd]
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   170
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   171
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   172
    open a textEditor on some file:
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   173
                                                        [exBegin]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   174
        EditTextView openOn:'Makefile'
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   175
                                                        [exEnd]
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   176
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   177
"
1016
6b49dc4b059d examples
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   178
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   179
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   180
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   181
!TextView class methodsFor:'instance creation'!
119
claus
parents: 97
diff changeset
   182
claus
parents: 97
diff changeset
   183
on:aModel aspect:aspect change:change menu:menu initialSelection:initial
claus
parents: 97
diff changeset
   184
    "for ST-80 compatibility"
claus
parents: 97
diff changeset
   185
120
claus
parents: 119
diff changeset
   186
    ^ (self new) 
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   187
        on:aModel 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   188
        aspect:aspect
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   189
        list:aspect
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   190
        change:change 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   191
        menu:menu
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   192
        initialSelection:initial
3280
703642244271 +with:someText (VW-compat.)
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   193
!
703642244271 +with:someText (VW-compat.)
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   194
703642244271 +with:someText (VW-compat.)
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   195
with:someText
703642244271 +with:someText (VW-compat.)
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   196
    ^ (self new) 
703642244271 +with:someText (VW-compat.)
Claus Gittinger <cg@exept.de>
parents: 3275
diff changeset
   197
        contents:someText 
119
claus
parents: 97
diff changeset
   198
! !
claus
parents: 97
diff changeset
   199
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   200
!TextView class methodsFor:'class initialization'!
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   201
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   202
initialize
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   203
    DefaultParenthesisSpecification isNil ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   204
        DefaultParenthesisSpecification := IdentityDictionary new.       
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   205
        DefaultParenthesisSpecification at:#open        put:#( $( $[ ${ "$> $<") .
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   206
        DefaultParenthesisSpecification at:#close       put:#( $) $] $} "$> $<").
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   207
        DefaultParenthesisSpecification at:#ignore      put:#( $' $" '$[' '$]' '${' '$)' ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   208
        DefaultParenthesisSpecification at:#eolComment  put:'"/'.     "/ sigh - must be 2 characters
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   209
    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   210
! !
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   211
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   212
!TextView class methodsFor:'defaults'!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 22
diff changeset
   213
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   214
defaultIcon
1195
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   215
    "return the default icon if started as a topView"
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   216
3496
8c92a96c4e27 icon resource
Claus Gittinger <cg@exept.de>
parents: 3491
diff changeset
   217
    <resource: #programImage>
1195
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   218
    <resource: #style (#ICON #ICON_FILE)>
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   219
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   220
    |nm i|
1143
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   221
1146
027884518745 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   222
    i := self classResources at:'ICON' default:nil.
1143
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   223
    i isNil ifTrue:[
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   224
        nm := ClassResources at:'ICON_FILE' default:'Editor.xbm'.
2074
24e9d7beed2b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2063
diff changeset
   225
        i := Smalltalk imageFromFileNamed:nm forClass:self.
1195
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   226
    ].
29102801022f defaultIcon improved
Claus Gittinger <cg@exept.de>
parents: 1193
diff changeset
   227
    i notNil ifTrue:[
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   228
        i := i onDevice:Display
1143
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   229
    ].
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   230
    ^ i
f5c02d0c66cf icon from resources
Claus Gittinger <cg@exept.de>
parents: 1109
diff changeset
   231
3496
8c92a96c4e27 icon resource
Claus Gittinger <cg@exept.de>
parents: 3491
diff changeset
   232
    "Modified: / 17-09-2007 / 11:36:29 / cg"
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   233
!
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   234
910
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   235
defaultMenuMessage
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   236
    "This message is the default yo be sent to the menuHolder to get a menu"
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   237
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   238
    ^ #editMenu
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   239
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   240
    "Created: 3.1.1997 / 01:52:21 / stefan"
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   241
!
0446030ce647 Move rest of menuHolder/menuPerformer stuff to View.
Stefan Vogel <sv@exept.de>
parents: 906
diff changeset
   242
4254
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   243
defaultParenthesisSpecification
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   244
    ^ DefaultParenthesisSpecification
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   245
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   246
    "Created: / 14-06-2011 / 14:00:59 / cg"
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   247
!
eaf0560ba269 added: #defaultParenthesisSpecification
Claus Gittinger <cg@exept.de>
parents: 4234
diff changeset
   248
2306
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   249
defaultSelectionBackgroundColor
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   250
    "return the default selection background color"
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   251
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   252
    ^DefaultSelectionBackgroundColor
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   253
!
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   254
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   255
defaultSelectionForegroundColor
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   256
    "return the default selection foreground color"
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   257
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   258
    ^DefaultSelectionForegroundColor
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   259
!
39f295426770 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   260
1477
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   261
defaultViewBackgroundColor
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   262
    "return the default view background"
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   263
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   264
    ^DefaultViewBackground
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   265
!
2d4b6115e2c5 redefine #defaultViewBackgroundColor for the spec class
tz
parents: 1476
diff changeset
   266
3226
43c19d2a074d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   267
lastSearchIgnoredCase
43c19d2a074d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   268
    ^ LastSearchIgnoredCase
43c19d2a074d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   269
!
43c19d2a074d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   270
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   271
lastSearchWasMatch
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   272
    ^ LastSearchWasMatch
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   273
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   274
1729
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   275
st80SelectMode
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   276
    ^ UserPreferences current st80SelectMode
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   277
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   278
    "Modified: / 03-07-2006 / 16:26:44 / cg"
1729
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   279
!
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   280
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   281
st80SelectMode:aBoolean
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   282
    UserPreferences current st80SelectMode:aBoolean
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   283
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   284
    "Created: / 07-01-1999 / 13:35:24 / cg"
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   285
    "Modified: / 03-07-2006 / 16:27:01 / cg"
1729
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   286
!
71462ffec5e3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1728
diff changeset
   287
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
   288
updateStyleCache
441
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   289
    "extract values from the styleSheet and cache them in class variables"
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   290
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   291
    <resource: #style (#'textView.background'
4056
b0cf275fc450 changed: #updateStyleCache
Claus Gittinger <cg@exept.de>
parents: 4009
diff changeset
   292
                       #'text.selectionForegroundColor' 
b0cf275fc450 changed: #updateStyleCache
Claus Gittinger <cg@exept.de>
parents: 4009
diff changeset
   293
                       #'text.selectionBackgroundColor'
b0cf275fc450 changed: #updateStyleCache
Claus Gittinger <cg@exept.de>
parents: 4009
diff changeset
   294
                       #'text.alternativeSelectionForegroundColor' 
b0cf275fc450 changed: #updateStyleCache
Claus Gittinger <cg@exept.de>
parents: 4009
diff changeset
   295
                       #'text.alternativeSelectionBackgroundColor'
b0cf275fc450 changed: #updateStyleCache
Claus Gittinger <cg@exept.de>
parents: 4009
diff changeset
   296
                       #'textView.font' 
b0cf275fc450 changed: #updateStyleCache
Claus Gittinger <cg@exept.de>
parents: 4009
diff changeset
   297
                       #'text.wordSelectCatchesBlanks'
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
   298
                       #'text.st80Selections')>
441
e170bca66a78 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   299
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   300
    DefaultViewBackground := StyleSheet colorAt:'textView.background' default:White.
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
   301
    DefaultSelectionForegroundColor := StyleSheet colorAt:'text.selectionForegroundColor'.
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
   302
    DefaultSelectionBackgroundColor := StyleSheet colorAt:'text.selectionBackgroundColor'.
2630
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
   303
"/    DefaultAlternativeSelectionForegroundColor := StyleSheet colorAt:'text.alternativeSelectionForegroundColor' default:DefaultSelectionForegroundColor.
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
   304
"/    DefaultAlternativeSelectionBackgroundColor := StyleSheet colorAt:'text.alternativeSelectionBackgroundColor' default:DefaultSelectionBackgroundColor.
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
   305
    DefaultAlternativeSelectionForegroundColor := DefaultSelectionForegroundColor.
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
   306
    DefaultAlternativeSelectionBackgroundColor := DefaultSelectionBackgroundColor.
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   307
    DefaultFont := StyleSheet fontAt:'textView.font'.
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
   308
    MatchDelayTime := 0.6.
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
   309
    WordSelectCatchesBlanks := StyleSheet at:'text.wordSelectCatchesBlanks' default:false.
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   310
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
   311
    "Modified: / 03-07-2006 / 16:29:42 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   312
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   313
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   314
!TextView class methodsFor:'interface specs'!
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   315
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   316
searchDialogSpec
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   317
    "This resource specification was automatically generated
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   318
     by the UIPainter of ST/X."
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   319
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   320
    "Do not manually edit this!! If it is corrupted,
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   321
     the UIPainter may not be able to read the specification."
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   322
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   323
    "
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   324
     UIPainter new openOnClass:TextView andSelector:#searchDialogSpec
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   325
    "
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   326
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   327
    <resource: #canvas>
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   328
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   329
    ^ 
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   330
     #(FullSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   331
        name: searchDialogSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   332
        window: 
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   333
       (WindowSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   334
          label: 'String search'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   335
          name: 'String search'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   336
          min: (Point 10 10)
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   337
          max: (Point 1280 1024)
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   338
          bounds: (Rectangle 0 0 299 135)
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   339
        )
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   340
        component: 
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   341
       (SpecCollection
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   342
          collection: (
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   343
           (HorizontalPanelViewSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   344
              name: 'horizontalPanelView'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   345
              layout: (LayoutFrame 0 0.0 -26 1.0 0 1.0 0 1.0)
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   346
              level: 0
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   347
              horizontalLayout: fitSpace
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   348
              verticalLayout: center
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   349
              horizontalSpace: 3
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   350
              verticalSpace: 3
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   351
              ignoreInvisibleComponents: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   352
              reverseOrderIfOKAtLeft: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   353
              component: 
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   354
             (SpecCollection
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   355
                collection: (
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   356
                 (ActionButtonSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   357
                    label: 'Cancel'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   358
                    name: 'cancelButton'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   359
                    level: 2
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   360
                    translateLabel: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   361
                    tabable: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   362
                    model: cancel
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   363
                    extent: (Point 95 21)
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   364
                  )
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   365
                 (ActionButtonSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   366
                    label: 'Prev'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   367
                    name: 'prevButton'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   368
                    level: 2
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   369
                    translateLabel: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   370
                    tabable: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   371
                    model: prevAction
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   372
                    extent: (Point 95 21)
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   373
                  )
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   374
                 (ActionButtonSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   375
                    label: 'Next'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   376
                    name: 'nextButton'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   377
                    level: 2
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   378
                    borderWidth: 1
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   379
                    translateLabel: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   380
                    tabable: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   381
                    model: nextAction
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   382
                    isDefault: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   383
                    extent: (Point 95 21)
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   384
                  )
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   385
                 )
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   386
               
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   387
              )
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   388
            )
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   389
           (LabelSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   390
              label: 'SearchPattern:'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   391
              name: 'label'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   392
              layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   393
              level: 0
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   394
              translateLabel: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   395
              adjust: left
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   396
            )
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   397
           (ComboBoxSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   398
              name: 'patternComboBox'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   399
              layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0)
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   400
              tabable: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   401
              model: searchPattern
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   402
              immediateAccept: false
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   403
              acceptOnLeave: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   404
              acceptOnReturn: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   405
              acceptOnTab: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   406
              acceptOnLostFocus: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   407
              acceptOnPointerLeave: false
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   408
              autoSelectInitialText: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   409
              comboList: patternList
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   410
            )
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   411
           (CheckBoxSpec
3984
e3870ec952ef \"Ignore Case\" -> \"Case Sensitive\"
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
   412
              label: 'Case Sensitive'
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   413
              name: 'ignoreCaseCheckBox'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   414
              layout: (LayoutFrame 3 0.0 54 0 -3 1.0 77 0)
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   415
              level: 0
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   416
              tabable: true
3984
e3870ec952ef \"Ignore Case\" -> \"Case Sensitive\"
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
   417
              model: caseSensitive
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   418
              translateLabel: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   419
            )
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   420
           (CheckBoxSpec
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   421
              label: 'Match (for Forward only)'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   422
              name: 'matchCheckBox'
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   423
              layout: (LayoutFrame 3 0.0 82 0 -3 1.0 104 0)
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   424
              level: 0
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   425
              tabable: true
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   426
              model: match
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
   427
              translateLabel: true
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   428
            )
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   429
           )
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   430
         
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   431
        )
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   432
      )
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   433
! !
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
   434
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
   435
!TextView class methodsFor:'startup'!
121
claus
parents: 120
diff changeset
   436
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   437
open
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   438
    "start an empty TextView"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   439
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   440
    ^ self openWith:nil
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   441
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   442
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   443
openModalOnModel:aModel
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   444
    "start a textView on a model; return the textView"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   445
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   446
    |textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   447
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   448
    textView := self setupForModel:aModel.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   449
    textView topView openModal.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   450
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   451
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   452
    "Created: 14.2.1997 / 15:24:12 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   453
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   454
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   455
openModalWith:aString
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   456
    "start a textView with aString as initial contents"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   457
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   458
    ^ self openModalWith:aString title:nil 
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   459
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   460
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   461
     TextView openModalWith:'some text'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   462
     EditTextView openModalWith:'some text'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   463
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   464
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   465
    "Created: 14.2.1997 / 15:19:04 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   466
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   467
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   468
openModalWith:aString title:aTitle
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   469
    "start a textView with aString as initial contents. Return the textView."
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   470
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   471
    |textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   472
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   473
    textView := self setupWith:aString title:aTitle.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   474
    textView topView openModal.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   475
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   476
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   477
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   478
     TextView openModalWith:'some text' title:'testing'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   479
     EditTextView openModalWith:'some text' title:'testing'
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   480
    "
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   481
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   482
    "Modified: 9.9.1996 / 19:32:29 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   483
    "Created: 14.2.1997 / 15:19:18 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   484
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   485
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   486
openOn:aFileName
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   487
    "start a textView on a file; return the textView"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   488
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   489
    |textView|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   490
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   491
    textView := self setupForFile:aFileName.
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   492
    textView topView open.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   493
    ^ textView
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   494
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   495
    "
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   496
     TextView openOn:'../../doc/overview.doc'
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   497
     EditTextView openOn:'../../doc/overview.doc'
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   498
    "
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   499
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   500
    "Modified: 14.2.1997 / 15:21:51 / cg"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   501
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   502
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   503
openOnModel:aModel
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   504
    "start a textView on a model; return the textView"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   505
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   506
    |textView|
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   507
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   508
    textView := self setupForModel:aModel.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   509
    textView topView open.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   510
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   511
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   512
    "Created: 14.2.1997 / 15:23:36 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   513
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   514
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   515
openWith:aStringOrStringCollection
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   516
    "start a textView with aStringOrStringCollection as initial contents"
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   517
2794
90115a2de9d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2793
diff changeset
   518
    ^ self openWith:aStringOrStringCollection selected:false 
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   519
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   520
    "
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   521
     TextView openWith:'some text'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   522
     EditTextView openWith:'some text'
2794
90115a2de9d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2793
diff changeset
   523
     Workspace openWith:'some text'
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   524
    "
119
claus
parents: 97
diff changeset
   525
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   526
    "Created: 10.12.1995 / 17:41:32 / cg"
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   527
    "Modified: 5.3.1997 / 15:37:19 / cg"
126
claus
parents: 121
diff changeset
   528
!
claus
parents: 121
diff changeset
   529
2793
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   530
openWith:aStringOrStringCollection selected:selectedBoolean
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   531
    "start a textView with aStringOrStringCollection as initial (optionally selected) contents. 
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   532
     Return the textView."
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   533
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   534
    |textView|
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   535
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   536
    textView := self setupEmpty.
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   537
    textView contents:aStringOrStringCollection selected:selectedBoolean.
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   538
    textView topView open.
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   539
    ^ textView
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   540
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   541
    "
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   542
     TextView openWith:'some text' selected:true
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   543
     EditTextView openWith:'some text' selected:false
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   544
    "
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   545
!
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   546
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   547
openWith:aStringOrStringCollection title:aTitle
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   548
    "start a textView with aStringOrStringCollection as initial contents. Return the textView."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   549
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   550
    |textView|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   551
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   552
    textView := self setupWith:aStringOrStringCollection title:aTitle.
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   553
    textView topView open.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   554
    ^ textView
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   555
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   556
    "
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   557
     TextView openWith:'some text' title:'testing'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   558
     EditTextView openWith:'some text' title:'testing'
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   559
    "
126
claus
parents: 121
diff changeset
   560
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   561
    "Created: 10.12.1995 / 17:40:02 / cg"
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   562
    "Modified: 5.3.1997 / 15:37:26 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   563
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   564
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   565
setupEmpty
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   566
    "create a textview in a topview, with horizontal and
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   567
     vertical scrollbars - a helper for #startWith: and #startOn:"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   568
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   569
    |top frame label|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   570
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   571
    label := 'unnamed'.
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   572
    top := StandardSystemView label:label icon:self defaultIcon.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   573
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   574
    frame := HVScrollableView 
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   575
                for:self 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   576
                miniScrollerH:true miniScrollerV:false
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   577
                in:top.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   578
    frame origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   579
    ^ frame scrolledView
896
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   580
963dc303b753 use Image instead of Form
Claus Gittinger <cg@exept.de>
parents: 863
diff changeset
   581
    "Modified: 23.5.1965 / 14:12:32 / cg"
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   582
!
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   583
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   584
setupForFile:aFileName
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   585
    "setup a textView on a file; return the textView"
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   586
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   587
    |textView f|
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   588
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   589
    textView := self setupEmpty.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   590
    aFileName notNil ifTrue:[
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   591
        textView setupForFile:aFileName.
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   592
    ].
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   593
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   594
    ^ textView
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   595
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   596
    "Created: / 14-02-1997 / 15:21:43 / cg"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   597
    "Modified: / 25-10-2006 / 14:46:54 / cg"
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   598
!
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   599
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   600
setupForModel:aModel
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   601
    "setup a textView on a model; return the textView"
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   602
2793
e4c3cfbe02cf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2791
diff changeset
   603
    |textView|
1014
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   604
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   605
    textView := self setupEmpty.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   606
    textView model:aModel.
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   607
    ^ textView
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   608
d70cad164cd0 more startup protocol; examples.
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   609
    "Created: 14.2.1997 / 15:22:42 / cg"
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   610
!
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   611
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   612
setupWith:aStringOrStringCollection title:aTitle
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   613
    "setup a textView with aStringOrStringCollection as initial contents in a topView"
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   614
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   615
    |top textView|
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   616
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   617
    textView := self setupEmpty.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   618
    top := textView topView.
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   619
    aTitle notNil ifTrue:[top label:aTitle].
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   620
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   621
    aStringOrStringCollection notNil ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   622
        textView contents:aStringOrStringCollection
830
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   623
    ].
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   624
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   625
    ^ textView
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   626
0441903116d6 separated setup from opening (in class method);
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   627
    "Created: 9.9.1996 / 19:31:22 / cg"
1100
2256f369ee96 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   628
    "Modified: 5.3.1997 / 15:37:37 / cg"
119
claus
parents: 97
diff changeset
   629
! !
claus
parents: 97
diff changeset
   630
2744
cb920467a4b4 method category rename
Claus Gittinger <cg@exept.de>
parents: 2740
diff changeset
   631
!TextView methodsFor:'Compatibility-ST80'!
1584
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   632
2291
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   633
displaySelection:aBoolean
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   634
    "ST-80 compatibility: ignored here."
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   635
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   636
!
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   637
2118
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   638
editText:someText
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   639
    "ST-80 compatibility: set the edited text."
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   640
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   641
    self contents:someText
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   642
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   643
    "Created: / 5.2.2000 / 17:06:18 / cg"
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   644
!
f9d8bfb35b03 added #editText: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2109
diff changeset
   645
2291
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   646
selectAndScroll
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   647
    "ST-80 compatibility: ignored here."
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   648
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   649
!
469168037c42 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2217
diff changeset
   650
1584
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   651
selectionStartIndex
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   652
    "ST-80 compatibility: return the selections start character position."
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   653
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   654
    ^ self characterPositionOfSelection
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   655
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   656
    "Created: / 19.6.1998 / 00:21:44 / cg"
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   657
!
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   658
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   659
selectionStopIndex
2052
6f9798507b6c ST80 compatibility:
Claus Gittinger <cg@exept.de>
parents: 2036
diff changeset
   660
    "ST-80 compatibility: return the character position of
6f9798507b6c ST80 compatibility:
Claus Gittinger <cg@exept.de>
parents: 2036
diff changeset
   661
     the character right after the selection."
6f9798507b6c ST80 compatibility:
Claus Gittinger <cg@exept.de>
parents: 2036
diff changeset
   662
2109
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   663
    |idx|
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   664
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   665
    idx := self characterPositionOfSelectionEnd.
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   666
    idx == 0 ifTrue:[^ 0].
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   667
    ^ idx + 1
1584
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   668
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   669
    "Created: / 19.6.1998 / 00:22:08 / cg"
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   670
! !
9f3875dc341e added selectionStartIndex and selectionStopIndex (for ST80-controller compatibility)
Claus Gittinger <cg@exept.de>
parents: 1545
diff changeset
   671
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   672
!TextView methodsFor:'accessing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   673
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   674
characterEncoding:encodingArg
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
   675
    "define how the contents is encoded internally.
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   676
     This should normally never be required, as ST/X now assumes
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   677
     unicode (of which iso8859-1 is a subset) encoding.
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   678
     The possibility to change the characterEncoding is provided as
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   679
     a backward compatibility hook for programs which want to use
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   680
     another encoding internally."
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   681
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   682
    |encodingSymOrNil|
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   683
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   684
    encodingSymOrNil := encodingArg isNil ifTrue:[#'iso10646-1'] ifFalse:[encodingArg asSymbol].
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   685
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   686
    characterEncoding ~~ encodingSymOrNil ifTrue:[
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   687
        "/ TODO: reencode contents if required.
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   688
        (list size ~~ 0
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   689
        and:[ list contains:[:line | line size > 0]]) ifTrue:[
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   690
            (self confirm:'Your text may need to be re-coded - this is not yet supported.\\Proceed ?')
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   691
            ifFalse:[^ self].
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   692
        ].
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   693
        characterEncoding := encodingSymOrNil.
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   694
    ].
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
   695
!
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
   696
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   697
characterPositionOfSelection
1303
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   698
    "return the character index of the first character in the selection.
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   699
     Returns 0 if there is no selection."
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   700
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   701
    selectionStartLine isNil ifTrue:[^ 0].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   702
    ^ self characterPositionOfLine:selectionStartLine
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   703
                               col:selectionStartCol
1303
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   704
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   705
    "Modified: 14.8.1997 / 16:35:37 / cg"
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   706
!
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   707
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   708
characterPositionOfSelectionEnd
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   709
    "return the character index of the last character in the selection.
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   710
     Returns 0 if there is no selection."
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   711
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   712
    selectionStartLine isNil ifTrue:[^ 0].
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   713
    ^ self characterPositionOfLine:selectionEndLine
2109
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
   714
                               col:selectionEndCol
1303
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   715
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   716
    "Created: 14.8.1997 / 16:35:24 / cg"
6e2aa19c1aed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1288
diff changeset
   717
    "Modified: 14.8.1997 / 16:35:45 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   718
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   719
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   720
contentsWasSaved
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   721
    "return true, if the contents was saved (by a save action),
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   722
     false if not (or was modified again after the last save)."
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   723
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   724
    ^ contentsWasSaved
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   725
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   726
3214
7ab9bba4883d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3212
diff changeset
   727
contentsWasSaved:aBoolean
7ab9bba4883d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3212
diff changeset
   728
    contentsWasSaved := aBoolean
7ab9bba4883d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3212
diff changeset
   729
!
7ab9bba4883d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3212
diff changeset
   730
3212
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   731
defaultFileNameForFileDialog
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   732
    "return the default fileName to use for the save-box"
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   733
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   734
    ^ defaultFileNameForFileDialog 
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   735
!
c14cadfd6752 remember last-saved fileName
Claus Gittinger <cg@exept.de>
parents: 3202
diff changeset
   736
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   737
defaultFileNameForFileDialog:aBaseName
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   738
    "define the default fileName to use for the save-box"
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   739
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   740
    defaultFileNameForFileDialog := aBaseName
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   741
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   742
    "Created: 13.2.1997 / 18:29:53 / cg"
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   743
!
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   744
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   745
directoryForFileDialog:aDirectory
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   746
    "define the default directory to use for save-box"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   747
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   748
    directoryForFileDialog := aDirectory
1003
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   749
b1affa654489 added #defaultFileNameForFileDialog
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   750
    "Modified: 13.2.1997 / 18:30:01 / cg"
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   751
!
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   752
2941
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   753
externalEncoding
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   754
    "return the encoding used when the contents is saved via the 'save / save as' dialog.
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   755
     This is (currently only) passed down from the fileBrowser,
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   756
     and required when  utf8/japanese/chinese/korean text is edited.
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   757
     (encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc).
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   758
     Notice: this only affects the external representation of the text."
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   759
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   760
    ^ externalEncoding
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   761
!
1df9eff1ddbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2929
diff changeset
   762
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   763
externalEncoding:encodingSymOrNil
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   764
    "define how the contents should be encoded when saved
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   765
     via the 'save / save as' dialog.
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   766
     This is (currently only) passed down from the fileBrowser,
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   767
     and required when  utf8/japanese/chinese/korean text is edited.
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   768
     (encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc).
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
   769
     Notice: this only affects the external representation of the text."
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   770
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   771
    externalEncoding := encodingSymOrNil
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   772
!
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   773
2581
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   774
parenthesisSpecification
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   775
    "return the value of the instance variable 'parenthesisSpecification' (automatically generated)"
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   776
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   777
    ^ parenthesisSpecification
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   778
!
03ffde9bbf6a add parenthesisSpecification getter method
penk
parents: 2558
diff changeset
   779
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   780
parenthesisSpecification:aDictionary
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   781
    "set the dictionary which specifies which characters are opening, which are closing
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   782
     and which are ignored characters w.r.t. parenthesis matching.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   783
     See the classes initialize method for a useful value."
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   784
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
   785
    parenthesisSpecification := aDictionary
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
   786
!
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
   787
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
   788
saveAction:something
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
   789
    saveAction := something.
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
   790
!
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
   791
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
   792
searchBarActionBlock
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
   793
    ^ searchBarActionBlock
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
   794
!
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
   795
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
   796
searchBarActionBlock:something
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
   797
    searchBarActionBlock := something.
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   798
! !
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   799
3787
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   800
!TextView methodsFor:'accessing-behavior'!
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   801
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   802
readOnly:aBoolean
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   803
    "for protocol compatibility with editTextViews,
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   804
     but actually ignored"
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   805
! !
a3654b479897 +dummy readOnly:
Claus Gittinger <cg@exept.de>
parents: 3727
diff changeset
   806
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   807
!TextView methodsFor:'accessing-contents'!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   808
2791
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   809
contents:newContents selected:selectedBoolean
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   810
    self contents:newContents.
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   811
    selectedBoolean ifTrue:[
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   812
        list size == 1 ifTrue:[
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   813
            self selectFromLine:1 col:1 toLine:1 col:(list at:1) size
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   814
        ] ifFalse:[
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   815
            self selectAll
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   816
        ]
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   817
    ]
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   818
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   819
    "
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   820
     |w|
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   821
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   822
     w := Workspace new open.
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   823
     w contents:'Hello world' selected:true.
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   824
    "
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   825
!
09e73617cc09 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   826
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   827
fromFile:aFileName
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   828
    "take contents from a named file"
3724
5db1580f82ba mark obsolete message
Stefan Vogel <sv@exept.de>
parents: 3708
diff changeset
   829
    <resource: #obsolete>
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   830
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   831
    self obsoleteMethodWarning.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   832
    ^ self loadTextFile:aFileName.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   833
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   834
    "Modified: / 25-10-2006 / 14:47:35 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   835
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   836
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   837
list:something
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   838
    "set the displayed contents (a collection of strings)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   839
     with redraw.
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   840
     Redefined since changing the contents implies deselect"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   841
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   842
    self unselect.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   843
    super list:something
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   844
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   845
    "Modified: 29.4.1996 / 12:13:24 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   846
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   847
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   848
loadTextFile:aFileName
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   849
    "take contents from a named file"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   850
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   851
    |f|
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   852
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   853
    f := aFileName asFilename.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   854
    self directoryForFileDialog:(f directoryName).
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   855
    self contents:(f contents)
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   856
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   857
    "Created: / 25-10-2006 / 14:44:01 / cg"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   858
!
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   859
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   860
setContents:something
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   861
    "set the contents (either a string or a Collection of strings)
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   862
     dont change the position (i.e. do not scroll) or the selection."
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   863
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   864
    |selStartLine selStartCol selEndLine selEndCol selStyle|
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   865
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   866
    selStartLine := selectionStartLine.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   867
    selStartCol := selectionStartCol.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   868
    selEndLine := selectionEndLine.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   869
    selEndCol := selectionEndCol.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   870
    selStyle := selectStyle.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   871
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   872
    super setContents:something.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   873
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   874
    selStartLine notNil ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   875
        self 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   876
            selectFromLine:selStartLine col:selStartCol
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   877
            toLine:selEndLine col:selEndCol.
4099
46aba06de32f comment/format in: #redrawVisibleLine:
Claus Gittinger <cg@exept.de>
parents: 4063
diff changeset
   878
        selectStyle := selStyle
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   879
    ].
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   880
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   881
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   882
    "Modified: / 31.3.1998 / 23:33:21 / cg"
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   883
!
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
   884
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   885
setList:something
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   886
    "set the displayed contents (a collection of strings)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   887
     without redraw.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   888
     Redefined since changing contents implies deselect"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   889
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   890
    self unselect.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   891
    super setList:something
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   892
!
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   893
3417
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   894
setupForFile:aFileName
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   895
    "take contents from a named file"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   896
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   897
    |baseName|
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   898
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   899
    self loadTextFile:aFileName.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   900
    aFileName notNil ifTrue:[
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   901
        baseName := aFileName asFilename baseName.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   902
        self topView label:baseName.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   903
        self defaultFileNameForFileDialog:baseName.
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   904
    ].
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   905
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   906
    "Created: / 25-10-2006 / 14:47:13 / cg"
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   907
!
44c33c650dc0 fromFile setup code cleanup
Claus Gittinger <cg@exept.de>
parents: 3399
diff changeset
   908
1487
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   909
text
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   910
    "for ST80 compatibility"
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   911
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   912
    ^ self contents
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   913
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   914
    "Created: / 19.4.1998 / 12:53:10 / cg"
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   915
!
4a9bfda28991 added #text for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1477
diff changeset
   916
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   917
wordAtLine:selectLine col:selectCol do:aFiveArgBlock
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   918
    "find word boundaries, evaluate the block argument with those.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   919
     A helper for nextWord and selectWord functions."
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   920
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   921
    |beginCol endCol endLine thisCharacter flag|
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   922
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   923
    flag := #word.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   924
    beginCol := selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   925
    endCol := selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   926
    endLine := selectLine.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   927
    thisCharacter := self characterAtLine:selectLine col:beginCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   928
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   929
    beginCol := self findBeginOfWordAtLine:selectLine col:selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   930
    endCol := self findEndOfWordAtLine:selectLine col:selectCol.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   931
    endCol == 0 ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   932
        endLine := selectLine + 1
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   933
    ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   934
1750
d87cc464fde2 comment
Claus Gittinger <cg@exept.de>
parents: 1729
diff changeset
   935
    "is the initial character within a word ?"
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   936
    (wordCheck value:thisCharacter) ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   937
        "
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   938
         try to catch a blank ...
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   939
        "
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   940
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   941
        WordSelectCatchesBlanks ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   942
            ((beginCol == 1)
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   943
            or:[(self characterAtLine:selectLine col:(beginCol - 1))
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   944
                 ~~ Character space]) ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   945
                ((self characterAtLine:selectLine col:(endCol + 1))
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   946
                  == Character space) ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   947
                    endCol := endCol + 1.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   948
                    flag := #wordRight
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   949
                ]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   950
            ] ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   951
                beginCol := beginCol - 1.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   952
                flag := #wordLeft
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   953
            ].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   954
        ].
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   955
    ].
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   956
    aFiveArgBlock value:selectLine 
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   957
                  value:beginCol 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   958
                  value:endLine 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   959
                  value:endCol
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
   960
                  value:flag
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   961
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   962
    "Modified: 18.3.1996 / 17:31:04 / cg"
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   963
! !
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   964
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   965
!TextView methodsFor:'accessing-look'!
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   966
2027
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   967
selectionBackgroundColor
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   968
    "return the selection-background color."
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   969
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   970
    ^ selectionBgColor
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   971
!
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   972
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   973
selectionForegroundColor
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   974
    "return the selection-foreground color."
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   975
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   976
    ^ selectionFgColor
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   977
!
0bde8408361a accessors for selection fg/bg color
Claus Gittinger <cg@exept.de>
parents: 2024
diff changeset
   978
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   979
selectionForegroundColor:color1 backgroundColor:color2
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   980
    "set both the selection-foreground and cursor background colors.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   981
     The default is defined by the styleSheet; 
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   982
     typically black-on-green for color displays and white-on-black for b&w displays."
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   983
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   984
    selectionFgColor := color1 onDevice:device.
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   985
    selectionBgColor := color2 onDevice:device.
2913
bdf4fb09cfc0 invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   986
    self hasSelection ifTrue:[
bdf4fb09cfc0 invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   987
        self invalidate
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   988
    ]
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   989
722
3f297a438fec use #invalidate instead of #redraw
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   990
    "Modified: 29.5.1996 / 16:22:15 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   991
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   992
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   993
!TextView methodsFor:'accessing-mvc'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   994
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   995
on:aModel aspect:aspectSym list:listSym change:changeSym menu:menuSym initialSelection:initial
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   996
    "set all of model, aspect, listMessage, changeSymbol, menySymbol
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   997
     and selection. Added for ST-80 compatibility"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   998
906
a8b9b481ce70 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
   999
    aspectSym notNil ifTrue:[aspectMsg := aspectSym. 
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1000
                             listMsg isNil ifTrue:[listMsg := aspectSym]].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1001
    changeSym notNil ifTrue:[changeMsg := changeSym].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1002
    listSym notNil ifTrue:[listMsg := listSym].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1003
    menuSym notNil ifTrue:[menuMsg := menuSym].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1004
"/    initial notNil ifTrue:[initialSelectionMsg := initial].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1005
    self model:aModel.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1006
824
f62922fcfa5d Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  1007
    "Modified: 15.8.1996 / 12:52:54 / stefan"
906
a8b9b481ce70 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
  1008
    "Modified: 2.1.1997 / 16:11:28 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1009
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1010
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1011
!TextView methodsFor:'drag & drop'!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1012
96256221e3af support drag
ca
parents: 2581
diff changeset
  1013
allowDrag:aBoolean
96256221e3af support drag
ca
parents: 2581
diff changeset
  1014
    "enable/disable dragging support
96256221e3af support drag
ca
parents: 2581
diff changeset
  1015
    "
96256221e3af support drag
ca
parents: 2581
diff changeset
  1016
    aBoolean ifFalse:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  1017
        dropSource := nil.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1018
    ] ifTrue:[
3438
d83030fd5005 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3426
diff changeset
  1019
        dropSource isNil ifTrue:[
2721
c94666d11e8f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2701
diff changeset
  1020
            dropSource := DropSource 
c94666d11e8f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2701
diff changeset
  1021
                            receiver:self
c94666d11e8f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2701
diff changeset
  1022
                            argument:nil
c94666d11e8f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2701
diff changeset
  1023
                            dropObjectSelector:#collectionOfDragObjects
c94666d11e8f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2701
diff changeset
  1024
                            displayObjectSelector:nil
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1025
        ]
96256221e3af support drag
ca
parents: 2581
diff changeset
  1026
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  1027
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1028
96256221e3af support drag
ca
parents: 2581
diff changeset
  1029
canDrag
96256221e3af support drag
ca
parents: 2581
diff changeset
  1030
    "returns true if dragging is enabled
96256221e3af support drag
ca
parents: 2581
diff changeset
  1031
    "
96256221e3af support drag
ca
parents: 2581
diff changeset
  1032
    dropSource notNil ifTrue:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  1033
        ^ self hasSelection
96256221e3af support drag
ca
parents: 2581
diff changeset
  1034
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  1035
    ^ false
96256221e3af support drag
ca
parents: 2581
diff changeset
  1036
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1037
96256221e3af support drag
ca
parents: 2581
diff changeset
  1038
collectionOfDragObjects
96256221e3af support drag
ca
parents: 2581
diff changeset
  1039
    "returns collection of dragable objects assigned to selection
96256221e3af support drag
ca
parents: 2581
diff changeset
  1040
     Here, by default, a collection of text-dragObjects is generated;
96256221e3af support drag
ca
parents: 2581
diff changeset
  1041
     however, if a dragObjectConverter is defined, that one gets a chance
96256221e3af support drag
ca
parents: 2581
diff changeset
  1042
     to convert as appropriate.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1043
    "
96256221e3af support drag
ca
parents: 2581
diff changeset
  1044
    |selection|
96256221e3af support drag
ca
parents: 2581
diff changeset
  1045
96256221e3af support drag
ca
parents: 2581
diff changeset
  1046
    selection := self selection.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1047
96256221e3af support drag
ca
parents: 2581
diff changeset
  1048
    selection size == 0 ifTrue:[^ nil].
96256221e3af support drag
ca
parents: 2581
diff changeset
  1049
  ^ Array with:(DropObject newText:selection).
96256221e3af support drag
ca
parents: 2581
diff changeset
  1050
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1051
96256221e3af support drag
ca
parents: 2581
diff changeset
  1052
dropSource
3245
b17c15b61e94 ugly comments
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1053
    "returns the dropSource or nil"
b17c15b61e94 ugly comments
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1054
    
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1055
    ^ dropSource
96256221e3af support drag
ca
parents: 2581
diff changeset
  1056
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  1057
3245
b17c15b61e94 ugly comments
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1058
dropSource:aDropSourceOrNil 
b17c15b61e94 ugly comments
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1059
    "set the dropSource or nil"
b17c15b61e94 ugly comments
Claus Gittinger <cg@exept.de>
parents: 3226
diff changeset
  1060
    
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1061
    dropSource := aDropSourceOrNil.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1062
! !
96256221e3af support drag
ca
parents: 2581
diff changeset
  1063
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1064
!TextView methodsFor:'encoding'!
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1065
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1066
validateFontEncodingFor:newEncoding ask:ask
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1067
    "if required, query user if he/she wants to change to another font,
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1068
     which is able to display text encoded as specified by newEncoding"
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1069
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1070
    |fontsEncoding msg filter f defaultFont pref matchingFonts 
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1071
     matchingFamilyFonts matchingFamilyFaceFonts matchingFamilyFaceStyleFonts
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1072
     matchingFamilyFaceStyleSizeFonts|
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1073
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1074
    fontsEncoding := font encoding.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1075
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1076
    pref := FontDescription preferredFontEncodingFor:newEncoding.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1077
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1078
    (pref match:fontsEncoding) ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1079
        ^ self
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1080
    ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1081
    (CharacterEncoder isEncoding:pref subSetOf:fontsEncoding) ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1082
        ^ self
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1083
    ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1084
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1085
    filter := [:f | |coding|
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1086
                    (coding := f encoding) notNil 
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1087
                    and:[pref match:coding]].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1088
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1089
    device flushListOfAvailableFonts.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1090
    matchingFonts := device listOfAvailableFonts select:filter.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1091
    matchingFamilyFonts := matchingFonts select:[:f | f family = font family].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1092
    matchingFamilyFaceFonts := matchingFamilyFonts select:[:f | f face = font face].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1093
    matchingFamilyFaceStyleFonts := matchingFamilyFaceFonts select:[:f | f style = font style].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1094
    matchingFamilyFaceStyleSizeFonts := matchingFamilyFaceStyleFonts select:[:f | f size = font size].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1095
    matchingFamilyFaceStyleSizeFonts size > 0 ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1096
        defaultFont := matchingFamilyFaceStyleSizeFonts first
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1097
    ] ifFalse:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1098
        matchingFamilyFaceStyleFonts size > 0 ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1099
            defaultFont := matchingFamilyFaceStyleFonts first
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1100
        ] ifFalse:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1101
            matchingFamilyFaceFonts size > 0 ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1102
                defaultFont := matchingFamilyFaceFonts first
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1103
            ] ifFalse:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1104
                matchingFamilyFonts size > 0 ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1105
                    defaultFont := matchingFamilyFonts first
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1106
                ] ifFalse:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1107
                    matchingFonts size > 0 ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1108
                        defaultFont := matchingFonts first
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1109
                    ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1110
                ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1111
            ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1112
        ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1113
    ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1114
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1115
    defaultFont isNil ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1116
        defaultFont isNil ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1117
            self warn:'Your display does not seem to provide any ' , newEncoding allBold , ' encoded font.\\Please select an appropriate font (iso10646-Unicode recommended)'.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1118
            pref := #'iso10646-1'.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1119
        ]
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1120
    ].
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1121
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
  1122
    msg := 'Switch to a %1 encoded font ?'.
3189
945a221e5cb2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3045
diff changeset
  1123
    (ask not or:[self confirm:(resources stringWithCRs:msg with:pref)])
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1124
    ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1125
        self withWaitCursorDo:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1126
            f := FontPanel 
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1127
                    fontFromUserInitial:defaultFont
3275
435d179c606f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3270
diff changeset
  1128
                    title:(resources string:'Font selection')
2889
092e6d12df95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
  1129
                    filter:filter
092e6d12df95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2886
diff changeset
  1130
                    encoding:pref.
2881
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1131
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1132
            f notNil ifTrue:[
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1133
                self font:f.
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1134
            ]
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1135
        ]
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1136
    ]
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1137
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1138
    "Created: 26.10.1996 / 12:06:54 / cg"
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1139
    "Modified: 30.6.1997 / 17:46:46 / cg"
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1140
! !
0c8e7e9edc0a encoding stuff
Claus Gittinger <cg@exept.de>
parents: 2877
diff changeset
  1141
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  1142
!TextView methodsFor:'event handling'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1143
3040
f5e9092f3312 buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents: 3001
diff changeset
  1144
buttonMotion:buttonState x:x y:y
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1145
    "mouse-move while button was pressed - handle selection changes"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1146
3219
e8c7679a8a94 buttonrelease behavior, when released in another view
Claus Gittinger <cg@exept.de>
parents: 3214
diff changeset
  1147
    (clickLine isNil or:[clickPos isNil]) ifTrue:[
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1148
        dragIsActive := false.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1149
        ^ self
96256221e3af support drag
ca
parents: 2581
diff changeset
  1150
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  1151
96256221e3af support drag
ca
parents: 2581
diff changeset
  1152
    dragIsActive ifTrue:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  1153
        (clickPos dist:(x@y)) >= 5.0 ifTrue:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  1154
            dragIsActive := false.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1155
96256221e3af support drag
ca
parents: 2581
diff changeset
  1156
            self hasSelection ifTrue:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  1157
                dropSource startDragIn:self at:(x@y)
96256221e3af support drag
ca
parents: 2581
diff changeset
  1158
            ]
96256221e3af support drag
ca
parents: 2581
diff changeset
  1159
        ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  1160
        ^ self
96256221e3af support drag
ca
parents: 2581
diff changeset
  1161
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1162
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
  1163
    "is it the select or 1-button ?"
3040
f5e9092f3312 buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents: 3001
diff changeset
  1164
    buttonState == 0 ifTrue:[^ self].
1619
f600c27c2c47 ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents: 1584
diff changeset
  1165
    self sensor leftButtonPressed ifFalse:[^ self].
3040
f5e9092f3312 buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents: 3001
diff changeset
  1166
"/    (device buttonMotionMask:buttonState includesButton:#select) ifFalse:[
f5e9092f3312 buttonState handling sensor bug workaround
Claus Gittinger <cg@exept.de>
parents: 3001
diff changeset
  1167
"/        (device buttonMotionMask:buttonState includesButton:1) ifFalse:[
1619
f600c27c2c47 ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents: 1584
diff changeset
  1168
"/            ^ self
f600c27c2c47 ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents: 1584
diff changeset
  1169
"/        ].
f600c27c2c47 ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents: 1584
diff changeset
  1170
"/    ].
53
b587b15eafab *** empty log message ***
claus
parents: 45
diff changeset
  1171
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1172
    "if moved outside of view, start autoscroll"
3202
8217b0acc9f2 select from beginning (in editField
Claus Gittinger <cg@exept.de>
parents: 3201
diff changeset
  1173
4160
a9c329c2784d changed: buttonMotion:x:y:
Claus Gittinger <cg@exept.de>
parents: 4156
diff changeset
  1174
    ((y < 0) and:[firstLineShown ~~ 0]) ifTrue:[
1922
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1175
        self compressMotionEvents:false.
4160
a9c329c2784d changed: buttonMotion:x:y:
Claus Gittinger <cg@exept.de>
parents: 4156
diff changeset
  1176
        self startAutoScrollUp:y negated.
1922
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1177
        ^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1178
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1179
    (y > height) ifTrue:[
1922
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1180
        self compressMotionEvents:false.
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1181
        self startAutoScrollDown:(y - height).
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1182
        ^ self
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1183
    ].
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  1184
    ((x < 0) and:[viewOrigin x ~~ 0]) ifTrue:[
1922
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1185
        self compressMotionEvents:false.
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1186
        self startAutoScrollLeft:x.
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1187
        ^ self
59
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1188
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 53
diff changeset
  1189
    (x > width) ifTrue:[
1922
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1190
        self compressMotionEvents:false.
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1191
        self startAutoScrollRight:(x - width).
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1192
        ^ self
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1193
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1194
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1195
    "move inside - stop autoscroll if any"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1196
    autoScrollBlock notNil ifTrue:[
1922
87222b5b9e32 oops - care for clickPos being nil.
Claus Gittinger <cg@exept.de>
parents: 1909
diff changeset
  1197
        self stopScrollSelect
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1198
    ].
3220
246c5a3bfefa oops - leftover prints
Claus Gittinger <cg@exept.de>
parents: 3219
diff changeset
  1199
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1200
    self extendSelectionToX:x y:y.
1619
f600c27c2c47 ignore motion event if not for left button.
Claus Gittinger <cg@exept.de>
parents: 1584
diff changeset
  1201
4160
a9c329c2784d changed: buttonMotion:x:y:
Claus Gittinger <cg@exept.de>
parents: 4156
diff changeset
  1202
    "Modified: / 08-08-2010 / 11:20:54 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1203
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1204
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1205
buttonMultiPress:button x:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1206
    "multi-mouse-click - select word under pointer"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1207
3914
ceb85ec53629 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3909
diff changeset
  1208
    (button == 1) ifTrue:[
3219
e8c7679a8a94 buttonrelease behavior, when released in another view
Claus Gittinger <cg@exept.de>
parents: 3214
diff changeset
  1209
        clickPos := x @ y.
4063
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  1210
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  1211
        "/ The searchAction is mantained until a cut/replace or a search with a user selection is done
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  1212
"/        self clearSearchAction.
2814
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1213
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1214
        clickCount notNil ifTrue:[
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1215
            clickCount := clickCount + 1.
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1216
            (clickCount == 2) ifTrue:[
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1217
                self doubleClickX:x y:y
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1218
            ] ifFalse:[
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1219
                (clickCount == 3) ifTrue:[
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1220
                    self tripleClickX:x y:y
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1221
                ] ifFalse:[
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1222
                    (clickCount == 4) ifTrue:[
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1223
                        self quadClickX:x y:y
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1224
                    ]
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1225
                ]
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1226
            ]
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1227
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1228
    ] ifFalse:[
2814
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  1229
        super buttonMultiPress:button x:x y:y
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1230
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1231
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1232
    "Modified: 11.9.1997 / 04:15:35 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1233
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1234
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1235
buttonPress:button x:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1236
    "mouse-click - prepare for selection change"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1237
1308
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
  1238
    |sensor clickVisibleLine|
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1303
diff changeset
  1239
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1240
    dragIsActive := false.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1241
    sensor       := self sensor.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1242
3914
ceb85ec53629 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3909
diff changeset
  1243
    (button == 1) ifTrue:[
2992
da91dbfd5676 shiftPress only relevant with button-1
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  1244
        sensor shiftDown ifTrue:[
da91dbfd5676 shiftPress only relevant with button-1
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  1245
            "mouse-click with shift - adding to selection"
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1246
            self extendSelectionToX:x y:y.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1247
            ^ self
2992
da91dbfd5676 shiftPress only relevant with button-1
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  1248
        ].
da91dbfd5676 shiftPress only relevant with button-1
Claus Gittinger <cg@exept.de>
parents: 2945
diff changeset
  1249
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1250
        clickVisibleLine := self visibleLineOfY:y.
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1251
        clickPos := x @ y.
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1252
        clickCol := self colOfX:x inVisibleLine:clickVisibleLine.
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1253
        clickLine := self visibleLineToAbsoluteLine:clickVisibleLine.
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1254
        clickStartLine := clickLine.
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1255
        clickStartCol := clickCol.
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1256
2593
6f1cdd5dafaa textDrag start with CTRL (optional)
Claus Gittinger <cg@exept.de>
parents: 2588
diff changeset
  1257
        (self canDrag 
6f1cdd5dafaa textDrag start with CTRL (optional)
Claus Gittinger <cg@exept.de>
parents: 2588
diff changeset
  1258
        and:[(self isInSelection:clickLine col:clickCol)
6f1cdd5dafaa textDrag start with CTRL (optional)
Claus Gittinger <cg@exept.de>
parents: 2588
diff changeset
  1259
        and:[UserPreferences current startTextDragWithControl not
6f1cdd5dafaa textDrag start with CTRL (optional)
Claus Gittinger <cg@exept.de>
parents: 2588
diff changeset
  1260
             or:[sensor ctrlDown]]]) ifTrue:[
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1261
            dragIsActive := true
96256221e3af support drag
ca
parents: 2581
diff changeset
  1262
        ] ifFalse:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  1263
            self unselect.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1264
        ].
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1265
        clickCount := 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1266
    ] ifFalse:[
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1267
        super buttonPress:button x:x y:y
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1268
    ]
813
7168eda47e3b Display no longer sends buttonShiftPress messages
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
  1269
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1270
    "Modified: / 20.5.1999 / 17:02:45 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1271
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1272
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1273
buttonRelease:button x:x y:y
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1274
    "mouse- button release - turn off autoScroll if any"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1275
3914
ceb85ec53629 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3909
diff changeset
  1276
    (button == 1) ifTrue:[
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1277
        autoScrollBlock notNil ifTrue:[
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1278
            self stopScrollSelect
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1279
        ].
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1280
        dragIsActive ifTrue:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  1281
            self unselect
96256221e3af support drag
ca
parents: 2581
diff changeset
  1282
        ].
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1283
        clickPos := nil.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1284
    ] ifFalse:[
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1285
        super buttonRelease:button x:x y:y
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1286
    ].
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1287
    dragIsActive := false.
96256221e3af support drag
ca
parents: 2581
diff changeset
  1288
1909
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1289
    "/ clickPos := clickLine := clickCol := nil.
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1290
27778cfa4bda checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
  1291
    "Modified: / 20.5.1999 / 17:14:23 / cg"
824
f62922fcfa5d Send #getListFromModel when setting #model:
Stefan Vogel <sv@exept.de>
parents: 813
diff changeset
  1292
!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1293
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1294
doubleClickX:x y:y
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1295
    "double-click - select word under pointer"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1296
3588
a70267e5b501 st80 behavior: also scan for matching single quote
Claus Gittinger <cg@exept.de>
parents: 3587
diff changeset
  1297
    |sel ch scanCh matchCol scanCol fwdScan fwdSelect|
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1298
3587
8685721a709f doubleClickX:y: + ctrl: st80 behavior
Claus Gittinger <cg@exept.de>
parents: 3581
diff changeset
  1299
    (self st80SelectMode or:[ self sensor ctrlDown]) ifTrue:[
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1300
        "/ st80 selects:
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1301
        "/   if clicked right after a parenthesis -> select to matching parenthesis
3588
a70267e5b501 st80 behavior: also scan for matching single quote
Claus Gittinger <cg@exept.de>
parents: 3587
diff changeset
  1302
        "/   if clicked right after a quote -> select to matching quote (unless escaped ;-)
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1303
        "/   if clicked at beginning of the line  -> select that line
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1304
        "/   if clicked at the top of the text    -> select all
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1305
        "/
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1306
        clickCol == 1 ifTrue:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1307
            clickLine == 1 ifTrue:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1308
                self selectAll.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1309
                ^ self.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1310
            ].
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1311
            self selectLineAtY:y.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1312
            selectStyle := #line.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1313
            ^ self
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1314
        ].
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1315
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1316
        matchCol := nil.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1317
        "/ see what is to the left of that character ...
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1318
        clickCol > 1 ifTrue:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1319
            ch := self characterAtLine:clickLine col:clickCol-1.
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1320
            (self isOpeningParenthesis:ch) ifTrue:[
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1321
                matchCol := clickCol - 1
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1322
            ] ifFalse:[
3589
2d6c6b29935d st80 behavior: also scan for matching vertical bar
Claus Gittinger <cg@exept.de>
parents: 3588
diff changeset
  1323
                ('"''|' includes:ch) ifTrue:[
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1324
                    scanCol := clickCol - 1.
3588
a70267e5b501 st80 behavior: also scan for matching single quote
Claus Gittinger <cg@exept.de>
parents: 3587
diff changeset
  1325
                    fwdScan := true.
a70267e5b501 st80 behavior: also scan for matching single quote
Claus Gittinger <cg@exept.de>
parents: 3587
diff changeset
  1326
                    scanCh := ch.    
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1327
                ]
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1328
            ]
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1329
        ].
3316
1ef036eee59f fixed st80 doubleclick behavior, when clicking beside a parenthesis.
Claus Gittinger <cg@exept.de>
parents: 3315
diff changeset
  1330
        fwdSelect := true.
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1331
        (matchCol isNil and:[scanCol isNil]) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1332
            clickCol < (self listAt:clickLine) size ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1333
                ch := self characterAtLine:clickLine col:clickCol+1.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1334
                (self isClosingParenthesis:ch) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1335
                    matchCol := clickCol + 1.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1336
                    fwdSelect := false.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1337
                ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1338
                    ('"''|' includes:ch) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1339
                        scanCol := clickCol + 1.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1340
                        fwdScan := false.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1341
                        scanCh := ch.    
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1342
                    ]
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1343
                ]
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1344
            ].
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1345
        ].
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1346
        matchCol notNil ifTrue:[
3316
1ef036eee59f fixed st80 doubleclick behavior, when clicking beside a parenthesis.
Claus Gittinger <cg@exept.de>
parents: 3315
diff changeset
  1347
            self 
1ef036eee59f fixed st80 doubleclick behavior, when clicking beside a parenthesis.
Claus Gittinger <cg@exept.de>
parents: 3315
diff changeset
  1348
                searchForMatchingParenthesisFromLine:clickLine col:matchCol
1ef036eee59f fixed st80 doubleclick behavior, when clicking beside a parenthesis.
Claus Gittinger <cg@exept.de>
parents: 3315
diff changeset
  1349
                ifFound:[:line :col | 
1ef036eee59f fixed st80 doubleclick behavior, when clicking beside a parenthesis.
Claus Gittinger <cg@exept.de>
parents: 3315
diff changeset
  1350
                          self selectFromLine:clickLine col:matchCol+(fwdSelect ifTrue:1 ifFalse:-1)
1ef036eee59f fixed st80 doubleclick behavior, when clicking beside a parenthesis.
Claus Gittinger <cg@exept.de>
parents: 3315
diff changeset
  1351
                                       toLine:line col:col-(fwdSelect ifTrue:1 ifFalse:-1)]
1ef036eee59f fixed st80 doubleclick behavior, when clicking beside a parenthesis.
Claus Gittinger <cg@exept.de>
parents: 3315
diff changeset
  1352
                ifNotFound:[self showNotFound]
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1353
                onError:[self beep]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1354
                openingCharacters:((parenthesisSpecification at:#open) , '([{')
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1355
                closingCharacters:((parenthesisSpecification at:#close) , ')]}').
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1356
            ^ self
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1357
        ].
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1358
        scanCol notNil ifTrue:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1359
            "/ if its an EOL comment, do it differently
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1360
            ch := self characterAtLine:clickLine col:clickCol.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1361
            ch == $/ ifTrue:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1362
                self selectFromLine:clickLine col:clickCol+1 toLine:clickLine+1 col:0.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1363
                ^ self
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1364
            ].
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1365
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1366
            self 
3588
a70267e5b501 st80 behavior: also scan for matching single quote
Claus Gittinger <cg@exept.de>
parents: 3587
diff changeset
  1367
                scanFor:scanCh fromLine:clickLine col:scanCol forward:fwdScan
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1368
                ifFound:[:line :col |
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1369
                            |selStart selEnd|
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1370
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1371
                            fwdScan ifTrue:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1372
                                selStart := scanCol+1.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1373
                                selEnd := col-1.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1374
                            ] ifFalse:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1375
                                selStart := scanCol-1.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1376
                                selEnd := col+1.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1377
                            ].
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1378
                            self selectFromLine:clickLine col:selStart
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1379
                                 toLine:line col:selEnd.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1380
                            ^ self
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1381
                           ]
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1382
                ifNotFound:[self showNotFound].
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1383
            ^ self
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1384
        ]
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1385
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1386
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1387
    self selectWordAtX:x y:y.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1388
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1389
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1390
     special - if clicked on a parenthesis, select to matching
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1391
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1392
    ((sel := self selection) size == 1 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1393
    and:[(sel := sel at:1) size == 1]) ifTrue:[
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1394
        ch := sel at:1.
2324
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  1395
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1396
        ((self isOpeningParenthesis:ch)
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1397
        or:[ (self isClosingParenthesis:ch) ]) ifTrue:[
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1398
            self 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1399
                searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1400
                ifFound:[:line :col | 
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1401
                              |prevLine prevCol moveBack pos1|
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1402
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1403
                              prevLine := firstLineShown.
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  1404
                              prevCol := viewOrigin x.
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1405
                              self selectFromLine:selectionStartLine col:selectionStartCol
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1406
                                           toLine:line col:col.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1407
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1408
                              self sensor ctrlDown ifFalse:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1409
                                  "/ undo scroll operation ...
2191
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1410
                                  self withCursor:Cursor eye do:[
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1411
                                      |delayCount|
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1412
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1413
                                      moveBack := false.
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1414
                                      (self isClosingParenthesis:ch) ifTrue:[
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  1415
                                           (firstLineShown ~~ prevLine or:[prevCol ~~ viewOrigin x]) ifTrue:[
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1416
                                               moveBack := true
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1417
                                           ] 
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1418
                                      ] ifFalse:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1419
                                           selectionEndLine > (firstLineShown + nFullLinesShown) ifTrue:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1420
                                               self makeLineVisible:selectionEndLine.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1421
                                               moveBack := true
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1422
                                           ]
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1423
                                      ].
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1424
                                      moveBack ifTrue:[
2191
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1425
                                           delayCount  := 0.
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1426
                                           pos1 := x@y. 
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1427
                                           self invalidateRepairNow:true.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1428
                                           Delay waitForSeconds:MatchDelayTime. 
2191
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1429
                                           delayCount := delayCount + MatchDelayTime. 
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1430
                                           [self sensor hasUserEventFor:self] whileFalse:[
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1431
                                                Delay waitForSeconds:MatchDelayTime / 2.
2191
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1432
                                                delayCount := delayCount + (MatchDelayTime / 2). 
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1433
                                                delayCount > 2 ifTrue:[
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1434
                                                    self cursor:Cursor eyeClosed.
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1435
                                                ].
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1436
                                                delayCount >= 2.3 ifTrue:[
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1437
                                                    self cursor:Cursor eye.
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1438
                                                    delayCount := 0.
373219bb2e9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1439
                                                ]
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1440
                                           ].
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1441
                                           self scrollToLine:prevLine; scrollToCol:prevCol.
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1442
                                      ].
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1443
                                  ]
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1444
                              ]
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1445
                          ]
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1446
                ifNotFound:[self showNotFound]
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1447
                onError:[self beep]
4255
9bf0cc2595a9 changed: #doubleClickX:y:
Claus Gittinger <cg@exept.de>
parents: 4254
diff changeset
  1448
                openingCharacters:((parenthesisSpecification at:#open) ", '([{'")
9bf0cc2595a9 changed: #doubleClickX:y:
Claus Gittinger <cg@exept.de>
parents: 4254
diff changeset
  1449
                closingCharacters:((parenthesisSpecification at:#close) ", ')]}'").
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1450
            selectStyle := nil
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1451
        ]
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1452
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1453
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1454
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1455
     remember words position in case of a drag following
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1456
    "
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1457
    wordStartLine := selectionStartLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1458
    wordEndLine := selectionEndLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1459
    selectStyle == #wordLeft ifTrue:[
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1460
        wordStartCol := selectionStartCol + 1
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1461
    ] ifFalse:[
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1462
        wordStartCol := selectionStartCol.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1463
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1464
    selectStyle == #wordRight ifTrue:[
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1465
        wordEndCol := selectionEndCol - 1
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1466
    ] ifFalse:[
1851
edec458ccfb4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1841
diff changeset
  1467
        wordEndCol := selectionEndCol
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1468
    ]
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1469
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  1470
    "Created: / 11-09-1997 / 04:12:55 / cg"
4255
9bf0cc2595a9 changed: #doubleClickX:y:
Claus Gittinger <cg@exept.de>
parents: 4254
diff changeset
  1471
    "Modified: / 14-06-2011 / 14:04:59 / cg"
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1472
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1473
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1474
extendSelectionToX:x y:y
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1475
    "mouse-move while button was pressed - handle selection changes"
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1476
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1477
    |movedVisibleLine movedLine movedCol 
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1478
     movedUp 
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1479
     oldStartLine oldEndLine oldStartCol oldEndCol|
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1480
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1481
    movedVisibleLine := self visibleLineOfY:y.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1482
    movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1483
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1484
    (x < leftMargin) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1485
        movedCol := 0
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1486
    ] ifFalse:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1487
        movedCol := self colOfX:x inVisibleLine:movedVisibleLine
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1488
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1489
    y < 0 ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1490
        movedCol := 0
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1491
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1492
    ((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1493
        selectionStartLine notNil ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1494
            ^ self
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1495
        ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1496
        (clickPos isNil 
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1497
        or:[(clickPos x - x) abs < 3 
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1498
            and:[(clickPos y - y) abs < 3]]) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1499
            ^ self
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1500
        ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1501
        selectionStartLine := clickLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1502
        selectionStartCol := clickCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1503
        selectionEndLine := selectionStartLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1504
        selectionEndCol := selectionStartCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1505
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1506
        oldStartLine := selectionStartLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1507
        oldEndLine := selectionEndLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1508
        oldStartCol := selectionStartCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1509
        oldEndCol := selectionEndCol-1.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1510
    ] ifFalse:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1511
        selectionStartLine isNil ifTrue:[
3692
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1512
            selectionStartLine := selectionEndLine := clickLine.
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1513
            selectionStartCol := selectionEndCol := clickCol.
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1514
        ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1515
        oldStartLine := selectionStartLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1516
        oldEndLine := selectionEndLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1517
        oldStartCol := selectionStartCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1518
        oldEndCol := selectionEndCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1519
    ].
3692
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1520
    oldEndLine isNil ifTrue:[
4234
65f202270d2c changed: #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 4178
diff changeset
  1521
        oldEndLine := selectionEndLine ? clickLine ? movedLine.
3692
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1522
    ].
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1523
    oldEndCol isNil ifTrue:[
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1524
        oldEndCol := selectionEndCol ? clickCol.
6527b20d26b5 extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1525
    ].
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1526
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1527
    "find out if we are before or after initial click"
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1528
    movedUp := false.
3443
09a7671630a9 changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3438
diff changeset
  1529
    clickStartLine isNil ifTrue:[
09a7671630a9 changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3438
diff changeset
  1530
        clickStartLine := movedLine.
09a7671630a9 changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3438
diff changeset
  1531
    ].
3505
cdb364dede3e extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3496
diff changeset
  1532
    clickStartCol isNil ifTrue:[
cdb364dede3e extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3496
diff changeset
  1533
        clickStartCol := movedCol.
cdb364dede3e extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3496
diff changeset
  1534
    ].
3443
09a7671630a9 changed #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 3438
diff changeset
  1535
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1536
    (movedLine < clickStartLine) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1537
        movedUp := true
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1538
    ] ifFalse:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1539
        (movedLine == clickStartLine) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1540
            (movedCol < clickStartCol) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1541
                movedUp := true
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1542
            ]
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1543
        ]
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1544
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1545
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1546
    movedUp ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1547
        "change selectionStart"
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1548
        selectionStartCol := movedCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1549
        selectionStartLine := movedLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1550
        selectionEndCol := clickStartCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1551
        selectionEndLine := clickStartLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1552
        selectStyle notNil ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1553
            selectionEndCol := wordEndCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1554
            selectionEndLine := wordEndLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1555
        ]
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1556
    ] ifFalse:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1557
        "change selectionEnd"
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1558
        selectionEndCol := movedCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1559
        selectionEndLine := movedLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1560
        selectionStartCol := clickStartCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1561
        selectionStartLine := clickStartLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1562
        selectStyle notNil ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1563
            selectionStartCol := wordStartCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1564
            selectionStartLine := wordStartLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1565
        ]
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1566
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1567
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1568
    selectionStartLine isNil ifTrue:[^ self].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1569
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1570
    (selectionStartCol == 0) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1571
        selectionStartCol := 1
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1572
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1573
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1574
    "
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1575
     if in word-select, just catch the rest of the word
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1576
    "
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1577
    (selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1578
        movedUp ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1579
            selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1580
        ] ifFalse:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1581
            selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1582
            selectionEndCol == 0 ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1583
                selectionEndLine := selectionEndLine + 1
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1584
            ]
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1585
        ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1586
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1587
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1588
    selectStyle == #line ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1589
        movedUp ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1590
            selectionStartCol := 1.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1591
        ] ifFalse:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1592
            selectionEndCol := 0.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1593
            selectionEndLine := selectionEndLine + 1
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1594
        ]
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1595
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1596
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1597
    self validateNewSelection.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  1598
    self selectionChanged.
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1599
4063
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  1600
    "/ The searchAction is mantained until a cut/replace or a search with a user selection is done
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  1601
"/    self clearSearchAction.
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1602
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1603
    (oldStartLine == selectionStartLine) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1604
        (oldStartCol ~~ selectionStartCol) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1605
            self redrawLine:oldStartLine 
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1606
                       from:((selectionStartCol min:oldStartCol) max:1)
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1607
                         to:((selectionStartCol max:oldStartCol) max:1)
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1608
        ]
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1609
    ] ifFalse:[
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1610
        self redrawFromLine:(oldStartLine?selectionStartLine min:selectionStartLine)
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  1611
                         to:(oldStartLine?selectionStartLine max:selectionStartLine)
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1612
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1613
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1614
    (oldEndLine == selectionEndLine) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1615
        (oldEndCol ~~ selectionEndCol) ifTrue:[
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1616
            self redrawLine:oldEndLine 
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1617
                       from:((selectionEndCol min:oldEndCol) max:1)
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1618
                         to:((selectionEndCol max:oldEndCol) max:1)
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1619
        ]
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1620
    ] ifFalse:[
3292
bbd4dd695f8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
  1621
        selectionEndLine isNil ifTrue:[
bbd4dd695f8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
  1622
            selectionStartLine := nil.
bbd4dd695f8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
  1623
            self redraw.
bbd4dd695f8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
  1624
        ] ifFalse:[
bbd4dd695f8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
  1625
            (selectionStartLine notNil) ifTrue:[
bbd4dd695f8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
  1626
                self redrawFromLine:(oldEndLine min:selectionEndLine)
bbd4dd695f8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
  1627
                                 to:(oldEndLine max:selectionEndLine)
bbd4dd695f8f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3280
diff changeset
  1628
            ]
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1629
        ]
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1630
    ].
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1631
    clickLine := movedLine.
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1632
    clickCol := movedCol
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1633
4234
65f202270d2c changed: #extendSelectionToX:y:
Claus Gittinger <cg@exept.de>
parents: 4178
diff changeset
  1634
    "Modified: / 05-04-2011 / 17:13:35 / cg"
3251
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1635
!
156d3ee6a6c1 fix: selection extension via shift-click
Claus Gittinger <cg@exept.de>
parents: 3245
diff changeset
  1636
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1637
keyPress:key x:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1638
    "handle some keyboard input (there is not much to be done here)"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1639
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1640
    <resource: #keyboard (#Find #Copy #FindNext #FindPrev #FindAgain
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1641
                          #GotoLine #SelectAll #SaveAs #Print
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1642
                          #'F*' #'f*' )>
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1643
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1644
    (key == #Find) ifTrue:[self search. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1645
    (key == #Copy) ifTrue:[self copySelection. ^self].
447
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1646
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1647
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1648
    (key == #FindNext) ifTrue:[self searchFwd. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1649
    (key == #FindPrev) ifTrue:[self searchBwd. ^self].
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1650
    (key == #FindAgain) ifTrue:[self searchAgainInSameDirection. ^self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1651
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1652
    (key == #SelectAll) ifTrue:[self selectAll. ^self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1653
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1654
    (key == #SaveAs)    ifTrue:[self save.    ^self].
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1655
    (key == #Print)     ifTrue:[self doPrint. ^self].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1656
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1657
    "
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1658
     shift-Fn defines a key-sequence 
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1659
     Fn       pastes that sequence
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1660
     cmd-Fn   performs a 'doIt' on the sequence (Workspaces only)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1661
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1662
     (see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1663
    "
1193
811135bbd017 Do not crash when typing simple keys.
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
  1664
    (key size > 1 and:[(key at:1) asLowercase == $f]) ifTrue:[
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1665
        (('[fF][0-9]' match:key)
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1666
        or:['[fF][0-9][0-9]' match:key]) ifTrue:[
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1667
            self sensor shiftDown ifTrue:[
1967
273caf76b2ea ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents: 1926
diff changeset
  1668
                UserPreferences current functionKeySequences
273caf76b2ea ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents: 1926
diff changeset
  1669
                    at:key put:(self selection)
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1670
            ].
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1671
            ^ self
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1672
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1673
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1674
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1675
    super keyPress:key x:x y:y
326
f04c328526c4 use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1676
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1677
    "Modified: / 18.4.1997 / 12:12:27 / stefan"
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  1678
    "Modified: / 3.5.1999 / 15:03:16 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1679
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1680
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1681
mapped 
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1682
    super mapped.
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1683
    selectionFgColor := selectionFgColor onDevice:device.
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1684
    selectionBgColor := selectionBgColor onDevice:device.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1685
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1686
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1687
quadClickX:x y:y
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1688
    "quadrupleClick-click - select all"
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1689
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1690
    self selectAll
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1691
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1692
    "Created: / 11.9.1997 / 04:15:24 / cg"
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1475
diff changeset
  1693
    "Modified: / 31.3.1998 / 14:21:13 / cg"
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1694
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1695
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1696
tripleClickX:x y:y
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1697
    "triple-click - select line under pointer"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1698
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1699
    self selectLineAtY:y.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1700
    selectStyle := #line
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1701
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1702
    "Created: 11.9.1997 / 04:13:37 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1703
! !
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1704
2120
1054ce5c8fe7 category change
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
  1705
!TextView methodsFor:'initialization & release'!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1706
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1707
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1708
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1709
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1710
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1711
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1712
    selectionFgColor notNil ifTrue:[selectionFgColor := selectionFgColor onDevice:device].
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1713
    selectionBgColor notNil ifTrue:[selectionBgColor := selectionBgColor onDevice:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1714
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1715
    "Created: 14.1.1997 / 00:14:33 / cg"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1716
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  1717
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1718
initStyle
966
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1719
    "setup viewStyle specifics"
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1720
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1721
    super initStyle.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1722
392
81343306d796 eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
  1723
"/    DefaultFont notNil ifTrue:[font := DefaultFont on:device].
81343306d796 eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
  1724
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1725
    viewBackground := DefaultViewBackground.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1726
    selectionFgColor := DefaultSelectionForegroundColor.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1727
    selectionFgColor isNil ifTrue:[selectionFgColor := bgColor].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1728
    selectionBgColor := DefaultSelectionBackgroundColor.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1729
    selectionBgColor isNil ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1730
        device hasColors ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1731
            DefaultSelectionForegroundColor isNil ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1732
                selectionFgColor := fgColor
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1733
            ].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1734
            selectionBgColor := Color green
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1735
        ] ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1736
            device hasGrayscales ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1737
                DefaultSelectionForegroundColor isNil ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1738
                    selectionFgColor := fgColor
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1739
                ].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1740
                selectionBgColor := Color grey
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1741
            ] ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1742
                selectionBgColor := fgColor
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1743
            ]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  1744
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1745
    ].
708
e8eb52699f90 grey vs. gray
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  1746
966
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1747
    "Modified: 22.1.1997 / 11:57:53 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1748
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1749
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1750
initialize
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1751
    super initialize.
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1752
    self initializeSaveAction.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1753
    contentsWasSaved := false.
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1754
    dragIsActive     := false.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1755
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1756
    parenthesisSpecification isNil ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1757
        parenthesisSpecification := DefaultParenthesisSpecification.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1758
    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  1759
911
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1760
    "I handle menus myself"
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1761
    menuHolder := menuPerformer := self.
22a930d19a9b menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents: 910
diff changeset
  1762
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  1763
    "/ on default allow drag
96256221e3af support drag
ca
parents: 2581
diff changeset
  1764
    self allowDrag:true.
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1765
!
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1766
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1767
initializeSaveAction
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1768
    saveAction := [ self openSaveDialog ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1769
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1770
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1771
!TextView methodsFor:'menu actions'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1772
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1773
appendTo:aFileName
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1774
    "append contents to a file named fileName"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1775
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1776
    |aStream msg filename|
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1777
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1778
    filename := aFileName asFilename.
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1779
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1780
    (FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1781
        msg := resources string:'Refused to append to file ''%1'' !!' with:filename name.
2036
83ac940a9fc6 allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents: 2027
diff changeset
  1782
        self warn:(msg , '\\(ST/X internal permission check)' ) withCRs.
83ac940a9fc6 allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents: 2027
diff changeset
  1783
        ^ self
83ac940a9fc6 allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents: 2027
diff changeset
  1784
    ].
83ac940a9fc6 allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents: 2027
diff changeset
  1785
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1786
    [
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1787
        aStream := filename appendingWriteStream.
2877
cdaea8ccd364 encoding
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
  1788
        self fileOutContentsOn:aStream compressTabs:true encoding:externalEncoding.
2036
83ac940a9fc6 allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents: 2027
diff changeset
  1789
        aStream close.
83ac940a9fc6 allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents: 2027
diff changeset
  1790
        contentsWasSaved := true
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1791
    ] on:FileStream openErrorSignal do:[:ex|
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1792
        msg := resources string:'cannot append to file %1 !!' with:filename name.
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1793
        self warn:(msg , '\\(' , FileStream lastErrorString , ')' ) withCRs
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1794
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1795
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1796
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1797
changeFont
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1798
    "pop up a fontPanel to change font"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1799
411
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1800
    |newFont|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1801
411
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1802
    newFont := FontPanel fontFromUserInitial:font.
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1803
    newFont notNil ifTrue:[
2872
b2341046d996 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1804
        self font:newFont.
411
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1805
    ]
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1806
c1d26677134b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1807
    "Modified: 27.2.1996 / 00:53:51 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1808
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1809
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1810
copySelection
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1811
    "copy contents into smalltalk copybuffer"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1812
863
ed4282df00a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 860
diff changeset
  1813
    |text|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1814
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1815
    text := self selection.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1816
    text notNil ifTrue:[
3045
9145edfc4116 Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 3040
diff changeset
  1817
        self unselect.
9145edfc4116 Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 3040
diff changeset
  1818
9145edfc4116 Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 3040
diff changeset
  1819
        "/ forget any emphasis ...
9145edfc4116 Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 3040
diff changeset
  1820
        text := text collect:[:l | l isNil ifTrue:[l] ifFalse:[l string]].
9145edfc4116 Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents: 3040
diff changeset
  1821
        self setClipboardText:text.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1822
    ]
649
097c69ce9599 forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1823
097c69ce9599 forget emphasis in copySelection
Claus Gittinger <cg@exept.de>
parents: 633
diff changeset
  1824
    "Modified: 17.5.1996 / 08:57:54 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1825
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1826
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1827
defaultForGotoLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1828
    "return a default value to show in the gotoLine box"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1829
447
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1830
    ^ selectionStartLine
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1831
ed41e1bbd9a1 also support goto-default (use selection if any)
Claus Gittinger <cg@exept.de>
parents: 441
diff changeset
  1832
    "Modified: 1.3.1996 / 18:44:36 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1833
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1834
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1835
doPrint
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1836
    "print the contents on the printer"
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1837
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1838
    |printStream|
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1839
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1840
    list isNil ifTrue:[^ self].
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1841
829
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1842
    self withWaitCursorDo:[
2729
9e78bde459f2 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 2723
diff changeset
  1843
        printStream := Printer new.
3491
d965db0d2d7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3478
diff changeset
  1844
        Printer writeErrorSignal handle:[:ex |
d965db0d2d7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3478
diff changeset
  1845
            self warn:('error while printing:\\' 
d965db0d2d7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3478
diff changeset
  1846
                        , ex description 
d965db0d2d7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3478
diff changeset
  1847
                        , '\\(printing with: ' , (Printer printCommand) , ')') withCRs
d965db0d2d7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3478
diff changeset
  1848
        ] do:[
d965db0d2d7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3478
diff changeset
  1849
            self fileOutContentsOn:printStream.
d965db0d2d7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3478
diff changeset
  1850
        ].
d965db0d2d7f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3478
diff changeset
  1851
        printStream close
829
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1852
    ].
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1853
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1854
    "Created: 6.5.1996 / 16:11:26 / cg"
829
fd15ef9c598a show wait cursor while printing
Claus Gittinger <cg@exept.de>
parents: 824
diff changeset
  1855
    "Modified: 5.9.1996 / 19:18:30 / cg"
614
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1856
!
564049dc75d5 renamed #print to #doPrint
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
  1857
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1858
editMenu
1109
83d8c0143ef9 commentary
Claus Gittinger <cg@exept.de>
parents: 1100
diff changeset
  1859
    "return my popUpMenu"
83d8c0143ef9 commentary
Claus Gittinger <cg@exept.de>
parents: 1100
diff changeset
  1860
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1861
    <resource: #keyboard (#Copy #Find #GotoLine #SaveAs #Print)>
1262
d69149b5be1f resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1255
diff changeset
  1862
    <resource: #programMenu>
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1863
1545
1812c587358f use new popupMenu creation
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  1864
    |items m|
1812c587358f use new popupMenu creation
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  1865
1812c587358f use new popupMenu creation
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  1866
    items := #(
2944
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  1867
                        ('Copy'          copySelection  Copy)
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  1868
                        ('-'             nil            )
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  1869
                        ('Search...'     search         Find)
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  1870
                        ('Goto Line...'  gotoLine       GotoLine)
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  1871
                        ('-'             nil            )
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  1872
                        ('Font...'       changeFont     )
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  1873
                        ('-'             nil            )
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  1874
                        ('Save As...'    save           SaveAs)
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  1875
                        ('Print'         doPrint        Print)
2458
4a61ac0ba64c menu order
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  1876
                ).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1877
1545
1812c587358f use new popupMenu creation
Claus Gittinger <cg@exept.de>
parents: 1524
diff changeset
  1878
    m := PopUpMenu itemList:items resources:resources.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1879
2350
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  1880
    self hasSelectionForCopy ifFalse:[
2458
4a61ac0ba64c menu order
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  1881
        m disable:#copySelection.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1882
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1883
    ^ m
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 411
diff changeset
  1884
2458
4a61ac0ba64c menu order
Claus Gittinger <cg@exept.de>
parents: 2455
diff changeset
  1885
    "Modified: / 12.11.2001 / 13:43:56 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1886
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1887
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1888
find
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1889
    "same as search - for VW compatibility"
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1890
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1891
    self search
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1892
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1893
    "Created: 31.7.1997 / 19:13:58 / cg"
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1894
!
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1895
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1896
gotoLine
1524
60582bfee9ce allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents: 1496
diff changeset
  1897
    "show a box to enter lineNumber for positioning;
1926
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1898
     The entered number may be prefixed by a + or -; 
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1899
     in this case, the linenumber is taken relative to the current position."
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1900
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1901
    |l lineNumberBox input lineToGo relative|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1902
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1903
    lineNumberBox :=
1926
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1904
        EnterBox
2415
188fc1577a8d uppercase labels
Claus Gittinger <cg@exept.de>
parents: 2414
diff changeset
  1905
           title:(resources string:'Line number (or +/- relativeNr):')
188fc1577a8d uppercase labels
Claus Gittinger <cg@exept.de>
parents: 2414
diff changeset
  1906
           okText:(resources string:'Goto')
188fc1577a8d uppercase labels
Claus Gittinger <cg@exept.de>
parents: 2414
diff changeset
  1907
           abortText:(resources string:'Cancel')
1926
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1908
           action:[:l | input := l].
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  1909
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1910
    l := self defaultForGotoLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1911
    l notNil ifTrue:[
1926
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1912
        l := l printString
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1913
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1914
    lineNumberBox initialText:l .
3394
39086a24097b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
  1915
    lineNumberBox label:(resources string:'Goto Line').
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  1916
    lineNumberBox showAtPointer.
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  1917
1524
60582bfee9ce allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents: 1496
diff changeset
  1918
    input size > 0 ifTrue:[
1926
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1919
        input := input withoutSpaces.
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1920
        input size > 0 ifTrue:[
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1921
            (input startsWith:$+) ifTrue:[
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1922
                relative := 1.
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1923
            ] ifFalse:[
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1924
                (input startsWith:$-) ifTrue:[
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1925
                    relative := -1.
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1926
                ].
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1927
            ].
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1928
            relative notNil ifTrue:[
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1929
                input := input copyFrom:2.
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1930
            ].
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1931
            lineToGo := Integer readFromString:input onError:nil.
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1932
            lineToGo notNil ifTrue:[
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1933
                relative notNil ifTrue:[
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1934
                    lineToGo := self currentLine + (lineToGo * relative)
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1935
                ].
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1936
                self gotoLine:lineToGo
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1937
            ]
de514188eaf2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
  1938
        ]
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  1939
    ].
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  1940
1524
60582bfee9ce allow relative gotos (+delta / -delta) in goto-line dialog.
Claus Gittinger <cg@exept.de>
parents: 1496
diff changeset
  1941
    "Modified: / 17.5.1998 / 20:07:59 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1942
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1943
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1944
openSaveDialog
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1945
    "Ask user for filename using a fileSelectionBox
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1946
     and save contents into that file."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1947
2695
7e13db2802df better save file dialog (use new dialog vs. use old dialog)
Claus Gittinger <cg@exept.de>
parents: 2693
diff changeset
  1948
    Dialog
7e13db2802df better save file dialog (use new dialog vs. use old dialog)
Claus Gittinger <cg@exept.de>
parents: 2693
diff changeset
  1949
        requestSaveFileName:(resources string:'Save contents in:') 
7e13db2802df better save file dialog (use new dialog vs. use old dialog)
Claus Gittinger <cg@exept.de>
parents: 2693
diff changeset
  1950
        default:defaultFileNameForFileDialog 
7e13db2802df better save file dialog (use new dialog vs. use old dialog)
Claus Gittinger <cg@exept.de>
parents: 2693
diff changeset
  1951
        fromDirectory:directoryForFileDialog 
7e13db2802df better save file dialog (use new dialog vs. use old dialog)
Claus Gittinger <cg@exept.de>
parents: 2693
diff changeset
  1952
        action:[:fileName | self saveAs:fileName] 
7e13db2802df better save file dialog (use new dialog vs. use old dialog)
Claus Gittinger <cg@exept.de>
parents: 2693
diff changeset
  1953
        appendAction:[:fileName | self appendTo:fileName]
2836
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1954
!
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1955
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1956
save
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1957
    "save contents into a file 
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1958
     - ask user for filename using a fileSelectionBox."
de07d386cfe8 allow save-action to be configured
Claus Gittinger <cg@exept.de>
parents: 2835
diff changeset
  1959
3201
ce84e272c6bb code cleanup
Claus Gittinger <cg@exept.de>
parents: 3189
diff changeset
  1960
    saveAction value
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1961
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1962
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1963
saveAs:fileName
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1964
    "save the contents into a file named fileName"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1965
 
2488
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  1966
    ^ self saveAs:fileName doAppend:false
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  1967
!
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  1968
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1969
saveAs:aFilename doAppend:doAppend
2488
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  1970
    "save the contents into a file named fileName;
3e1ee2bbab6b added saveAs:doAppend:
Claus Gittinger <cg@exept.de>
parents: 2458
diff changeset
  1971
     if doAppend is true, the views contents is appended to the existing
2834
be970a6f9333 return true for successful save
penk
parents: 2822
diff changeset
  1972
     contents - otherwise, it overwrites any previous file contents.
be970a6f9333 return true for successful save
penk
parents: 2822
diff changeset
  1973
     on error return false otherwise return true"
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1974
3426
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1975
    |filename msg|
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1976
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1977
    filename := aFilename asFilename.
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1978
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  1979
    self withCursor:Cursor write do:[
3426
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1980
        |aStream|
2036
83ac940a9fc6 allow for interception of fileSave/fileAppend
Claus Gittinger <cg@exept.de>
parents: 2027
diff changeset
  1981
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  1982
        (FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[
3426
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1983
            msg := resources stringWithCRs:'Refused to write file ''%1'' !!\(ST/X internal permission check)' 
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1984
                                with:filename name.
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1985
        ] ifTrue:[
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1986
            [
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1987
                doAppend ifTrue:[
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1988
                    aStream := filename appendingWriteStream.
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1989
                ] ifFalse:[
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1990
                    aStream := filename newReadWriteStream.
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1991
                ].
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1992
                self fileOutContentsOn:aStream compressTabs:true encoding:externalEncoding.
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1993
                aStream close.
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1994
                contentsWasSaved := true.
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1995
                defaultFileNameForFileDialog := filename.
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1996
            ] on:FileStream openErrorSignal do:[:ex|
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1997
                msg := resources stringWithCRs:'Cannot write file ''%1'' !!\(%2)' 
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1998
                                with:filename name
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  1999
                                with:FileStream lastErrorString.
2701
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  2000
            ].
b77cc7cf3818 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 2695
diff changeset
  2001
        ].
2834
be970a6f9333 return true for successful save
penk
parents: 2822
diff changeset
  2002
    ].
3426
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2003
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2004
    msg notNil ifTrue:[
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2005
        Dialog warn:msg.
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2006
        ^ false
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2007
    ].
2834
be970a6f9333 return true for successful save
penk
parents: 2822
diff changeset
  2008
    ^ true
916
4201c9c2a4f0 show a wait-cursor while saving
Claus Gittinger <cg@exept.de>
parents: 911
diff changeset
  2009
3426
bbcad86d26a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3417
diff changeset
  2010
    "Modified: / 15-11-2006 / 15:29:21 / cg"
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2011
!
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2012
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2013
search
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2014
    "search for a string - show a box to enter searchpattern 
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2015
     - currently no regular expressions are handled."
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2016
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2017
    "
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2018
     Q: is it a good idea to preserve the last searchstring between views ?
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2019
    "
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2020
    |searchBox patternHolder caseHolder matchHolder fwd ign match initialString
2809
d2a07ff6170d forget autoSearch action when a pattern is entered via dialog.
Claus Gittinger <cg@exept.de>
parents: 2808
diff changeset
  2021
     bindings bldr search modal|
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2022
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  2023
    searchBarActionBlock notNil ifTrue:[
4009
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2024
        self resetVariablesBeforeNewSearch.
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  2025
        searchBarActionBlock value:#search value:self.
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  2026
        ^ self
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  2027
    ].
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  2028
2723
8c910a099160 comment
Claus Gittinger <cg@exept.de>
parents: 2722
diff changeset
  2029
    modal := (UserPreferences current searchDialogIsModal).   "/ thats experimental
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2030
3225
b213aa3a487d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
  2031
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
3984
e3870ec952ef \"Ignore Case\" -> \"Case Sensitive\"
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
  2032
    caseHolder := ign not asValue.
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2033
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2034
    match := lastSearchWasMatch ? LastSearchWasMatch ? false.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2035
    matchHolder := match asValue.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2036
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2037
    patternHolder := '' asValue.
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2038
3970
0f4980ca24a5 No longer force the current selection to be the initialString
fm
parents: 3964
diff changeset
  2039
    self setSearchPatternWithMatchEscapes: match.
0f4980ca24a5 No longer force the current selection to be the initialString
fm
parents: 3964
diff changeset
  2040
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2041
    lastSearchPattern notNil ifTrue:[
3708
78d2d5f43914 changed #search - convert the selection to a string
Stefan Vogel <sv@exept.de>
parents: 3692
diff changeset
  2042
        initialString := lastSearchPattern.
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2043
    ].
3970
0f4980ca24a5 No longer force the current selection to be the initialString
fm
parents: 3964
diff changeset
  2044
"/  No longer force the current selection to be the initialString
0f4980ca24a5 No longer force the current selection to be the initialString
fm
parents: 3964
diff changeset
  2045
"/    self hasSelectionWithinSingleLine ifTrue:[
0f4980ca24a5 No longer force the current selection to be the initialString
fm
parents: 3964
diff changeset
  2046
"/        initialString := self selection asString.
0f4980ca24a5 No longer force the current selection to be the initialString
fm
parents: 3964
diff changeset
  2047
"/    ].
2109
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
  2048
    initialString isNil ifTrue:[
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
  2049
        LastSearchPatterns size > 0 ifTrue:[
3708
78d2d5f43914 changed #search - convert the selection to a string
Stefan Vogel <sv@exept.de>
parents: 3692
diff changeset
  2050
            initialString := LastSearchPatterns first.
2109
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
  2051
        ]
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
  2052
    ].
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
  2053
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
  2054
    initialString notNil ifTrue:[
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2055
        patternHolder value:initialString.
2109
ccad6daad477 selectionStopIndex, if there is no selection (for RB)
Claus Gittinger <cg@exept.de>
parents: 2100
diff changeset
  2056
    ].
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2057
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2058
    fwd := true. 
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2059
2809
d2a07ff6170d forget autoSearch action when a pattern is entered via dialog.
Claus Gittinger <cg@exept.de>
parents: 2808
diff changeset
  2060
    search := [:fwd |
4009
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2061
        self resetVariablesBeforeNewSearch.
3984
e3870ec952ef \"Ignore Case\" -> \"Case Sensitive\"
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
  2062
        self search:patternHolder value ignoreCase:(caseHolder value not) match: matchHolder value forward:fwd.
1288
19eee9e48131 added #find (same as #search) to allow VW menus to function.
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2063
    ].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2064
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2065
    bindings := IdentityDictionary new.
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2066
    bindings at:#searchPattern put:patternHolder.
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2067
    modal ifTrue:[
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2068
        bindings at:#nextAction put:[searchBox doAccept.].
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2069
        bindings at:#prevAction put:[fwd := false. searchBox doAccept.].
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2070
    ] ifFalse:[
2809
d2a07ff6170d forget autoSearch action when a pattern is entered via dialog.
Claus Gittinger <cg@exept.de>
parents: 2808
diff changeset
  2071
        bindings at:#nextAction put:[search value:true.  "searchBox doAccept."].
d2a07ff6170d forget autoSearch action when a pattern is entered via dialog.
Claus Gittinger <cg@exept.de>
parents: 2808
diff changeset
  2072
        bindings at:#prevAction put:[search value:false. "fwd := false. searchBox doAccept."].
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2073
    ].
3984
e3870ec952ef \"Ignore Case\" -> \"Case Sensitive\"
Claus Gittinger <cg@exept.de>
parents: 3981
diff changeset
  2074
    bindings at:#caseSensitive put:caseHolder.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2075
    bindings at:#match put:matchHolder.
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2076
    bindings at:#patternList put:LastSearchPatterns.
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2077
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2078
    modal ifTrue:[
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2079
        searchBox := SimpleDialog new.
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2080
    ] ifFalse:[
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2081
        searchBox := ApplicationModel new.
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2082
        searchBox createBuilder.
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2083
    ].
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2084
    searchBox resources:(self resources).
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2085
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2086
    bldr := searchBox builder.
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2087
    bldr addBindings:bindings.
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2088
    searchBox allButOpenFrom:(self class searchDialogSpec).
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2089
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2090
    (bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2091
    (bldr componentAt:#prevButton) cursor:(Cursor thumbsUp).
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2092
    (bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2093
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2094
    modal ifTrue:[
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2095
        searchBox openDialog.
2809
d2a07ff6170d forget autoSearch action when a pattern is entered via dialog.
Claus Gittinger <cg@exept.de>
parents: 2808
diff changeset
  2096
        searchBox accepted ifTrue:[ search value:fwd ].
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2097
    ] ifFalse:[
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2098
        (bldr componentAt:#nextButton) isReturnButton:false.
2722
57c08cdf3c6a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2721
diff changeset
  2099
        (bldr componentAt:#cancelButton) 
57c08cdf3c6a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2721
diff changeset
  2100
                label:(resources string:'Close');
57c08cdf3c6a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2721
diff changeset
  2101
                action:[searchBox closeRequest].
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2102
        "/ searchBox masterApplication:self application.
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2103
        self topView beMaster.
2722
57c08cdf3c6a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2721
diff changeset
  2104
        searchBox window 
57c08cdf3c6a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2721
diff changeset
  2105
                beSlave;
57c08cdf3c6a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2721
diff changeset
  2106
                openInGroup:(self windowGroup).
2723
8c910a099160 comment
Claus Gittinger <cg@exept.de>
parents: 2722
diff changeset
  2107
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2108
        "/ searchBox window open.
2723
8c910a099160 comment
Claus Gittinger <cg@exept.de>
parents: 2722
diff changeset
  2109
        searchBox window assignKeyboardFocusToFirstInputField.
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  2110
    ]
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2111
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2112
    "Modified: / 11-07-2006 / 11:18:38 / fm"
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2113
!
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2114
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2115
search:patternArg ignoreCase:ign forward:fwd 
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2116
    "search for a string without matching"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2117
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2118
    self search:patternArg ignoreCase:ign match: false forward:fwd 
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2119
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2120
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2121
search:patternArg ignoreCase:ign match: match forward:fwd 
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2122
    |pattern|
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2123
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2124
    pattern := patternArg string.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2125
    pattern notEmpty ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2126
        self rememberSearchPattern:pattern.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2127
        LastSearchIgnoredCase := ign.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2128
        LastSearchWasMatch := match.
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2129
        fwd ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2130
            lastSearchDirection := #backward.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2131
            self searchBwd:pattern ignoreCase:ign match: match.          "    backward search with match is not yet available  " 
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2132
        ] ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2133
            lastSearchDirection := #forward.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2134
            self searchFwd:pattern ignoreCase:ign match: match.
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2135
        ]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2136
    ]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2137
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2138
    "Created: / 11-07-2006 / 11:18:04 / fm"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2139
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2140
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2141
!TextView methodsFor:'private'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2142
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2143
currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2144
    ^  selectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2145
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2146
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2147
currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2148
    ^ selectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2149
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2150
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2151
fileOutContentsOn:aStream
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2152
    "save contents on a stream, replacing leading spaces by tab-characters."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2153
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2154
    self 
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2155
        fileOutContentsOn:aStream 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2156
        compressTabs:true
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2157
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2158
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2159
fileOutContentsOn:aStream compressTabs:compressTabs
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2160
    "save contents on a stream. If compressTabs is true,
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2161
     leading spaces will be replaced by tab-characters in the output."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2162
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2163
    self 
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2164
        fileOutContentsOn:aStream 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2165
        compressTabs:compressTabs 
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2166
        encoding:nil
1255
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2167
!
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2168
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2169
fileOutContentsOn:aStream compressTabs:compressTabs encoding:encodingSymOrNil
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2170
    "save contents on a stream. If compressTabs is true,
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2171
     leading spaces will be replaced by tab-characters in the output."
c1bf6a3dbb78 allow the encoding for save/saveAs to be specified.
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
  2172
2877
cdaea8ccd364 encoding
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
  2173
    |startNr nLines string encoder|
cdaea8ccd364 encoding
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
  2174
2945
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2175
    self removeTrailingWhitespace.
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2176
2877
cdaea8ccd364 encoding
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
  2177
    encoder := CharacterEncoder encoderToEncodeFrom:characterEncoding into:encodingSymOrNil.
2916
7f1e089959a3 characterEncoding stuff
Claus Gittinger <cg@exept.de>
parents: 2913
diff changeset
  2178
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  2179
    aStream isFileStream ifTrue:[
2000
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2180
        "on some systems, writing linewise is very slow (via NFS)
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2181
         therefore we convert to a string and write it in big chunks.
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2182
         To avoid creating huge strings, we do it in blocks of 1000 lines,
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2183
         limiting temporary string creation to about 50-80k.
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2184
        "
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2185
        startNr := 1.
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2186
        nLines := list size.
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2187
        [startNr <= nLines] whileTrue:[
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2188
            string := list asStringWithCRsFrom:startNr 
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2189
                                            to:((startNr + 1000) min:nLines)
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2190
                                  compressTabs:compressTabs.
2884
101120a2c8b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2881
diff changeset
  2191
            aStream nextPutAll:(encoder encodeString:string string).
2000
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2192
            startNr := startNr + 1000 + 1.
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2193
        ].
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  2194
    ] ifFalse:[
2000
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2195
        list do:[:aLine |
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2196
            aLine notNil ifTrue:[
2877
cdaea8ccd364 encoding
Claus Gittinger <cg@exept.de>
parents: 2876
diff changeset
  2197
                aStream nextPutLine:(encoder encodeString:aLine).
2000
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2198
            ] ifFalse:[
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2199
                aStream cr.
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2200
            ]
efdedcb4ee33 oops - printing was wrong
Claus Gittinger <cg@exept.de>
parents: 1987
diff changeset
  2201
        ]
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  2202
    ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2203
758
e3b4e6a65a26 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 734
diff changeset
  2204
    "Modified: 8.6.1996 / 11:50:46 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2205
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2206
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2207
getFontParameters
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2208
    "get some info of the used font. They are cached since we use them often ..
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2209
     This is redefined here, to use the fonts maxHeight/maxAscent for
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2210
     line separation. This is required, to allow for proper handling of
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2211
     national characters, such as A-dieresis ..."
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2212
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2213
    |italicFont boldFont|
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2214
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  2215
    font := font onDevice:device.
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2216
    italicFont := font asItalic onDevice:device.
3304
bd0991615b04 When computing font parameters, now consider the bold font, too.
Stefan Vogel <sv@exept.de>
parents: 3298
diff changeset
  2217
    boldFont := font asBold onDevice:device.
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2218
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2219
    includesNonStrings == true ifTrue:[
1987
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  2220
        "/ for now, we do not support variable height entries ...
599825bed176 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  2221
        fontHeight := list first heightOn:self
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2222
    ] ifFalse:[
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2223
        fontHeight := font maxHeight max:(italicFont maxHeight max:(boldFont maxHeight)).
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2224
    ].
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2225
    fontHeight := fontHeight + lineSpacing.
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2226
    fontAscent := font maxAscent max:(italicFont maxAscent max:(boldFont maxAscent)).
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2227
    fontWidth := font width.
3258
0a07b6fdd85d fix: must care for the case where the italic font is higher than
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
  2228
    fontIsFixedWidth := font isFixedWidth and:[ italicFont isFixedWidth and:[ boldFont isFixedWidth ]].
668
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2229
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2230
    "Modified: 22.5.1996 / 12:02:47 / cg"
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2231
    "Created: 22.5.1996 / 12:18:34 / cg"
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2232
!
729295eb37fc use fonts averageHeight for line-grid; redefine in TextView to use maxHeight
Claus Gittinger <cg@exept.de>
parents: 651
diff changeset
  2233
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2234
isClosingParenthesis:ch
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2235
    ((parenthesisSpecification at:#close) includes:ch) ifTrue:[^ true].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2236
    (')]}' includes:ch ) ifTrue:[^ true].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2237
    ^ false
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2238
!
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2239
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2240
isOpeningParenthesis:ch
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2241
    ((parenthesisSpecification at:#open) includes:ch) ifTrue:[^ true].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2242
    ('([{' includes:ch ) ifTrue:[^ true].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2243
    ^ false
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2244
!
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  2245
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2246
rememberSearchPattern:pattern
2691
2c4350e0bcf8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  2247
    |nRemembered patternString|
2c4350e0bcf8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  2248
2814
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  2249
    self clearSearchAction.
2813
ec8e83691849 forget searchAction, when a new pattern-search is done
Claus Gittinger <cg@exept.de>
parents: 2811
diff changeset
  2250
2691
2c4350e0bcf8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  2251
    patternString := pattern string.
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2252
3270
e3ed37e15f9d oops - last-searchpatterns handling removed the wrong one.
Claus Gittinger <cg@exept.de>
parents: 3258
diff changeset
  2253
    nRemembered := NumRememberedSearchPatterns ? 20.
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2254
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2255
    LastSearchPatterns isNil ifTrue:[
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2256
        LastSearchPatterns := OrderedCollection new.
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2257
    ].
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2258
    "/ move to top or addFirst
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2259
    (LastSearchPatterns includes:pattern) ifTrue:[
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2260
        LastSearchPatterns remove:pattern.
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2261
    ] ifFalse:[
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2262
        LastSearchPatterns size > nRemembered ifTrue:[
3270
e3ed37e15f9d oops - last-searchpatterns handling removed the wrong one.
Claus Gittinger <cg@exept.de>
parents: 3258
diff changeset
  2263
            LastSearchPatterns removeLast
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2264
        ]
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2265
    ].
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2266
    LastSearchPatterns addFirst:pattern.
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2267
!
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2268
2945
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2269
removeTrailingWhitespace
3001
d9877eeb59f5 *** empty log message ***
ca
parents: 2992
diff changeset
  2270
    list isNil ifTrue:[^self].
2945
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2271
    list keysAndValuesDo:[:lineNR :line |
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2272
        |l|
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2273
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2274
        line notNil ifTrue:[
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2275
            l := line withoutTrailingSeparators.
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2276
            list at:lineNR put:l.
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2277
        ]
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2278
    ].
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2279
!
5c4f000c7f17 remvoe trailing whiteSpace when saving
Claus Gittinger <cg@exept.de>
parents: 2944
diff changeset
  2280
4009
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2281
resetVariablesBeforeNewSearch
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2282
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2283
    "clear the autosearch action, when the first pattern is searched for"
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2284
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2285
    searchAction := nil.
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2286
!
6c421dbb325e added: #resetVariablesBeforeNewSearch
fm
parents: 4008
diff changeset
  2287
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2288
scrollSelectDown
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2289
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2290
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2291
    |prevEndLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2292
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2293
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2294
    selectionEndLine isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2295
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2296
    self scrollDown.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2297
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2298
    "make new selection immediately visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2299
    prevEndLine := selectionEndLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2300
    selectionEndLine := firstLineShown + nFullLinesShown.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2301
    selectionEndCol := 0.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2302
    prevEndLine to:selectionEndLine do:[:lineNr |
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2303
        self redrawLine:lineNr
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2304
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2305
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  2306
    self selectionChanged.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2307
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2308
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2309
scrollSelectLeft
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2310
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2311
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2312
    |prevStartLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2313
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2314
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2315
    selectionStartLine isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2316
    selectionStartCol isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2317
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2318
    "make new selection immediately visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2319
    prevStartLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2320
    selectionStartCol := selectionStartCol - 1 max:1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2321
    self scrollLeft.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2322
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2323
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  2324
    self selectionChanged.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2325
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2326
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2327
scrollSelectRight
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2328
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2329
4156
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2330
    |prevEndCol firstVisibleCol endLine|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2331
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2332
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2333
    selectionEndCol isNil ifTrue:[^ self].
4169
11d3b7a3e713 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4160
diff changeset
  2334
    selectionEndLine isNil ifTrue:[^ self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2335
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2336
    prevEndCol := selectionEndCol.
4156
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2337
    selectionEndCol := (selectionEndCol + 1) min:(self listAt:selectionEndLine) size.
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2338
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2339
    endLine := self listLineToVisibleLine:selectionEndLine.
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2340
    endLine notNil ifTrue:[
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2341
        firstVisibleCol := self colOfX:1 inVisibleLine:endLine.
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2342
        selectionEndCol < firstVisibleCol ifTrue:[
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2343
            "/ scrolling faster than selection advances...
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2344
            selectionEndCol := firstVisibleCol
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2345
        ].
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2346
    ].
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2347
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2348
    self selectionChanged.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2349
    self scrollRight.
4156
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2350
    "/ self repairDamage.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2351
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2352
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
4156
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2353
df8875264273 changed: #scrollSelectRight
Claus Gittinger <cg@exept.de>
parents: 4140
diff changeset
  2354
    "Modified: / 05-08-2010 / 21:25:56 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2355
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2356
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2357
scrollSelectUp
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2358
    "auto scroll action; scroll and reinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2359
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2360
    |prevStartLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2361
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2362
    "just to make certain ..."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2363
    selectionStartLine isNil ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2364
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2365
    self scrollUp.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2366
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2367
    "make new selection immediately visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2368
    prevStartLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2369
    selectionStartLine := firstLineShown.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2370
    selectionStartCol := 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2371
    selectionStartLine to:prevStartLine do:[:lineNr |
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2372
        self redrawLine:lineNr
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2373
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2374
    Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  2375
    self selectionChanged.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2376
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2377
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2378
stopScrollSelect
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2379
    "stop auto scroll; deinstall timed-block"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2380
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2381
    autoScrollBlock notNil ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2382
        Processor removeTimedBlock:autoScrollBlock.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2383
        self compressMotionEvents:true.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2384
        autoScrollBlock := nil.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2385
        autoScrollDeltaT := nil
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2386
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2387
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2388
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2389
widthForScrollBetween:firstLine and:lastLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2390
    "return the width in pixels for a scroll between firstLine and lastLine"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2391
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2392
    selectionStartLine notNil ifTrue:[
3851
b6c80d2350b7 comment
Claus Gittinger <cg@exept.de>
parents: 3835
diff changeset
  2393
        "/ if there is a selection which covers multiple lines,
b6c80d2350b7 comment
Claus Gittinger <cg@exept.de>
parents: 3835
diff changeset
  2394
        "/ we have to scroll the whole width (to include the selection-rectangle)
b6c80d2350b7 comment
Claus Gittinger <cg@exept.de>
parents: 3835
diff changeset
  2395
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2396
        (lastLine < selectionStartLine) ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2397
            (firstLine > selectionEndLine) ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2398
                ^ width
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2399
            ]
3851
b6c80d2350b7 comment
Claus Gittinger <cg@exept.de>
parents: 3835
diff changeset
  2400
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2401
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2402
    ^ super widthForScrollBetween:firstLine and:lastLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2403
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2404
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2405
!TextView methodsFor:'queries'!
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2406
4063
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2407
hasSearchActionSelection
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2408
    "Here we fake the use of typeOfSelection which is really in EditTextView"
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2409
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2410
    ^ false
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2411
!
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2412
2455
750760093931 viewBackground setting;
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  2413
isTextView
750760093931 viewBackground setting;
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  2414
    "I am showing text"
750760093931 viewBackground setting;
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  2415
750760093931 viewBackground setting;
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  2416
    ^ true
750760093931 viewBackground setting;
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  2417
!
750760093931 viewBackground setting;
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
  2418
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2419
specClass
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2420
    "redefined, since the name of my specClass is nonStandard (i.e. not TextViewSpec)"
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2421
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2422
    self class == TextView ifTrue:[^ TextEditorSpec].
1046
10da5b6bd390 specClass query
ca
parents: 1028
diff changeset
  2423
    ^ super specClass
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2424
1380
1794c90633f9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  2425
    "Modified: / 31.10.1997 / 19:48:35 / cg"
997
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2426
! !
615a5a19c5bf specClass
ca
parents: 966
diff changeset
  2427
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2428
!TextView methodsFor:'redrawing'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2429
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2430
clearMarginOfVisibleLine:visLine with:color
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2431
    "if there is a margin, clear it - a helper for selection drawing"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2432
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2433
    (leftMargin ~~ 0) ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2434
        self paint:color.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2435
        self fillRectangleX:margin
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2436
                          y:(self yOfVisibleLine:visLine)
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2437
                      width:leftMargin
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  2438
                     height:fontHeight
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2439
    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2440
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2441
    "Created: 6.3.1996 / 14:22:55 / cg"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2442
!
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2443
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2444
drawSelectedFromVisibleLine:startVisLineNr to:endVisLineNr
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2445
    startVisLineNr to:endVisLineNr do:[:visLine |
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2446
        self drawVisibleLineSelected:visLine 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2447
    ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2448
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2449
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2450
drawVisibleLineSelected:visLineNr 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2451
    self 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2452
        drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr))
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2453
        inVisible:visLineNr 
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2454
        with:self currentSelectionFgColor and:self currentSelectionBgColor
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2455
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2456
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2457
drawVisibleLineSelected:visLineNr col:col
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2458
    self
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2459
        drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr))
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2460
        inVisible:visLineNr 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2461
        col:col 
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2462
        with:self currentSelectionFgColor and:self currentSelectionBgColor
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2463
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2464
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2465
drawVisibleLineSelected:visLineNr from:selectionStartCol
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2466
    self 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2467
        drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr))
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2468
        inVisible:visLineNr 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2469
        from:selectionStartCol
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2470
        with:self currentSelectionFgColor and:self currentSelectionBgColor.
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2471
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2472
2558
4c10bec1117d more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents: 2557
diff changeset
  2473
drawVisibleLineSelected:visLineNr from:startCol to:endCol
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2474
    self 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2475
        drawLine:(self withoutAnyColorEmphasis:(self visibleAt:visLineNr))
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2476
        inVisible:visLineNr 
2558
4c10bec1117d more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents: 2557
diff changeset
  2477
        from:startCol to:endCol
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2478
        with:self currentSelectionFgColor and:self currentSelectionBgColor.
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2479
!
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2480
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2481
redrawFromVisibleLine:startVisLineNr to:endVisLineNr
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2482
    "redraw a visible line range"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2483
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2484
    |startLine endLine specialCare end selVisStart line1 line2|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2485
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2486
    shown ifFalse:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2487
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2488
    end := endVisLineNr.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2489
    (end > nLinesShown) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2490
        end := nLinesShown
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2491
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2492
2740
892dfb6b0da1 kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents: 2735
diff changeset
  2493
    selectionEndLine isNil ifTrue:[
892dfb6b0da1 kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents: 2735
diff changeset
  2494
        selectionStartLine := nil
892dfb6b0da1 kludge workaround selectionEndLine bug
Claus Gittinger <cg@exept.de>
parents: 2735
diff changeset
  2495
    ].
2735
5ba2010aefa4 *** empty log message ***
penk
parents: 2730
diff changeset
  2496
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2497
    selectionStartLine isNil ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2498
        specialCare := false
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2499
    ] ifFalse:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2500
        startLine := self visibleLineToAbsoluteLine:startVisLineNr.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2501
        (startLine > selectionEndLine) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2502
            specialCare := false
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2503
        ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2504
            endLine := self visibleLineToAbsoluteLine:end.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2505
            (endLine < selectionStartLine) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2506
                specialCare := false
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2507
            ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2508
                specialCare := true
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2509
            ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2510
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2511
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2512
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2513
    "easy: nothing is selected"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2514
    specialCare ifFalse:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2515
        super redrawFromVisibleLine:startVisLineNr to:end.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2516
        ^ self
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2517
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2518
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2519
    "easy: all is selected"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2520
    ((selectionStartLine < startLine) and:[selectionEndLine > endLine]) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2521
        self drawSelectedFromVisibleLine:startVisLineNr to:end.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2522
        ^ self
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2523
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2524
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2525
    (selectionStartLine >= firstLineShown) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2526
        "draw unselected top part"
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2527
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2528
        selVisStart := self listLineToVisibleLine:selectionStartLine.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2529
        super redrawFromVisibleLine:startVisLineNr to:(selVisStart - 1).
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2530
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2531
        "and first partial selected line"
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2532
        self redrawVisibleLine:selVisStart.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2533
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2534
        "rest starts after this one"
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2535
        line1 := selVisStart + 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2536
    ] ifFalse:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2537
        line1 := 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2538
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2539
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2540
    (line1 > end) ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2541
    (line1 < startVisLineNr) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2542
        line1 := startVisLineNr
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2543
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2544
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2545
    "draw middle part of selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2546
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2547
    (selectionEndLine >= (firstLineShown + nLinesShown)) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2548
        line2 := nLinesShown
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2549
    ] ifFalse:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2550
        line2 := (self listLineToVisibleLine:selectionEndLine) - 1
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2551
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2552
    (line2 > end) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2553
        line2 := end
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2554
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2555
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2556
    self drawSelectedFromVisibleLine:line1 to:line2.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2557
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2558
    (line2 >= end) ifTrue:[^ self].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2559
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2560
    "last line of selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2561
    self redrawVisibleLine:(line2 + 1).
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2562
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2563
    ((line2 + 2) <= end) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2564
        super redrawFromVisibleLine:(line2 + 2) to:end
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2565
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2566
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2567
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2568
redrawMarginOfVisibleLine:visLine
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2569
    "draw margin - a helper for selection drawing"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2570
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2571
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2572
    (leftMargin ~~ 0) ifTrue:[
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2573
    ]
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2574
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2575
    "Created: 6.3.1996 / 14:21:48 / cg"
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2576
!
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2577
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2578
redrawVisibleLine:visLineNr
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2579
    "redraw visible line lineNr"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2580
2558
4c10bec1117d more selection fixes (with non-string/non-text lines)
Michael Beyl <mb@exept.de>
parents: 2557
diff changeset
  2581
    |line|
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2582
2778
223915a2d6a4 kludge workaround selectionEndLine is sometimes nil
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  2583
    (selectionStartLine notNil and:[selectionEndLine notNil]) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2584
        line := self visibleLineToAbsoluteLine:visLineNr.
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2585
        (line between:selectionStartLine and:selectionEndLine) ifTrue:[
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2586
            (line == selectionStartLine) ifTrue:[
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2587
                (line == selectionEndLine) ifTrue:[
4099
46aba06de32f comment/format in: #redrawVisibleLine:
Claus Gittinger <cg@exept.de>
parents: 4063
diff changeset
  2588
                    "it's part-of-single-line selection"
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2589
                    self clearMarginOfVisibleLine:visLineNr with:bgColor.
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2590
                    (selectionStartCol > 1) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2591
                        super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1)
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2592
                    ].
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2593
                    self drawVisibleLineSelected:visLineNr from:selectionStartCol to:selectionEndCol.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2594
                    super redrawVisibleLine:visLineNr from:(selectionEndCol + 1).
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2595
                    ^ self
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2596
                ].
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2597
4099
46aba06de32f comment/format in: #redrawVisibleLine:
Claus Gittinger <cg@exept.de>
parents: 4063
diff changeset
  2598
                "it's the first line of a multi-line selection"
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2599
                (selectionStartCol ~~ 1) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2600
                    self clearMarginOfVisibleLine:visLineNr with:bgColor.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2601
                    super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1)
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2602
                ] ifFalse:[
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2603
                    viewOrigin x == 0 ifTrue:[
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2604
                        self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2605
                    ]
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2606
                ].
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2607
                self drawVisibleLineSelected:visLineNr from:selectionStartCol.
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2608
                ^ self
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2609
            ].
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2610
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2611
            (line == selectionEndLine) ifTrue:[
4099
46aba06de32f comment/format in: #redrawVisibleLine:
Claus Gittinger <cg@exept.de>
parents: 4063
diff changeset
  2612
                "it's the last line of a multi-line selection"
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2613
                (selectionEndCol == 0) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2614
                    ^ super redrawVisibleLine:visLineNr
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2615
                ].
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2616
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2617
                self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2618
                self drawVisibleLineSelected:visLineNr from:1 to:selectionEndCol.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2619
                super redrawVisibleLine:visLineNr from:(selectionEndCol + 1).
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2620
                ^ self
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2621
            ].
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2622
4099
46aba06de32f comment/format in: #redrawVisibleLine:
Claus Gittinger <cg@exept.de>
parents: 4063
diff changeset
  2623
            "it's a full line in a multi-line selection"
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2624
            self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2625
            self drawVisibleLineSelected:visLineNr.
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2626
            ^ self
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2421
diff changeset
  2627
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2628
    ].
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2629
    super redrawVisibleLine:visLineNr
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2630
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2631
    "Modified: 6.3.1996 / 14:22:19 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2632
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2633
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2634
redrawVisibleLine:visLine col:col
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2635
    "redraw single character at col in visible line lineNr."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2636
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2637
    |line|
633
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2638
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2639
    "/
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2640
    "/ care for selection
ea1c2ad6f2ff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 614
diff changeset
  2641
    "/
2778
223915a2d6a4 kludge workaround selectionEndLine is sometimes nil
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  2642
    (selectionStartLine notNil and:[selectionEndLine notNil]) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2643
        line := self visibleLineToAbsoluteLine:visLine.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2644
        (line between:selectionStartLine and:selectionEndLine) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2645
            ((line == selectionStartLine)
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2646
            and: [col < selectionStartCol]) ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2647
                ((line == selectionEndLine)
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2648
                and: [col > selectionEndCol]) ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2649
                    "its in the selection"
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2650
                    self drawVisibleLineSelected:visLine col:col.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2651
                    ^ self.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2652
                ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2653
            ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2654
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2655
    ].
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2656
    self drawVisibleLine:visLine col:col with:fgColor and:bgColor
1496
95a24d9211df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  2657
95a24d9211df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  2658
    "Modified: / 22.4.1998 / 08:53:05 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2659
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2660
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2661
redrawVisibleLine:visLine from:startCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2662
    "redraw visible line lineNr from startCol to end of line"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2663
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2664
    |col line|
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2665
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2666
    col := startCol.
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2667
    col == 0 ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2668
        col := 1.
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2669
    ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2670
2778
223915a2d6a4 kludge workaround selectionEndLine is sometimes nil
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  2671
    (selectionStartLine notNil and:[selectionEndLine notNil]) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2672
        line := self visibleLineToAbsoluteLine:visLine.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2673
        (line between:selectionStartLine and:selectionEndLine) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2674
            ((line == selectionStartLine) 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2675
             or:[line == selectionEndLine]) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2676
                "since I'm lazy, redraw full line"
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2677
                self redrawVisibleLine:visLine.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2678
                ^ self
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2679
            ].
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2680
            "the line is fully within the selection"
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2681
            self drawVisibleLineSelected:visLine from:col. 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2682
            ^ self
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2683
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2684
    ].
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2685
    super redrawVisibleLine:visLine from:col
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2686
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2687
    "Modified: 6.3.1996 / 14:19:38 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2688
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2689
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2690
redrawVisibleLine:visLine from:startCol to:endCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2691
    "redraw visible line lineNr from startCol to endCol"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2692
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2693
    |line allOut allIn leftCol rightCol|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2694
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2695
    line := self visibleLineToAbsoluteLine:visLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2696
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2697
    allIn := false.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2698
    allOut := false.
2778
223915a2d6a4 kludge workaround selectionEndLine is sometimes nil
Claus Gittinger <cg@exept.de>
parents: 2772
diff changeset
  2699
    (selectionStartLine isNil or:[selectionEndLine isNil]) ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2700
        allOut := true
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2701
    ] ifFalse:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2702
        (line between:selectionStartLine and:selectionEndLine) ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2703
            allOut := true
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2704
        ] ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2705
            (selectionStartLine == selectionEndLine) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2706
                ((endCol < selectionStartCol) 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2707
                or:[startCol > selectionEndCol]) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2708
                    allOut := true
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2709
                ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2710
                    ((startCol >= selectionStartCol) 
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2711
                    and:[endCol <= selectionEndCol]) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2712
                        allIn := true
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2713
                    ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2714
                ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2715
            ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2716
                (line == selectionStartLine) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2717
                    (endCol < selectionStartCol) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2718
                        allOut := true
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2719
                    ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2720
                        (startCol >= selectionStartCol) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2721
                            allIn := true
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2722
                        ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2723
                    ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2724
                ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2725
                    (line == selectionEndLine) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2726
                        (startCol > selectionEndCol) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2727
                            allOut := true
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2728
                        ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2729
                            (endCol <= selectionEndCol) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2730
                                allIn := true
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2731
                            ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2732
                        ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2733
                    ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2734
                        allIn := true
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2735
                    ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2736
                ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2737
            ]
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2738
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2739
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2740
    allOut ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2741
        super redrawVisibleLine:visLine from:startCol to:endCol.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2742
        ^ self
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2743
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2744
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2745
    allIn ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2746
        self drawVisibleLineSelected:visLine from:startCol to:endCol
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2747
    ] ifFalse:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2748
        "redraw part before selection"
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2749
        ((line == selectionStartLine)
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2750
         and:[startCol <= selectionStartCol]) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2751
            super redrawVisibleLine:visLine from:startCol
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2752
                                              to:(selectionStartCol - 1).
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2753
            leftCol := selectionStartCol
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2754
        ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2755
            leftCol := startCol
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2756
        ].
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2757
        "redraw selected part"
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2758
        (selectionEndLine > line) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2759
            rightCol := endCol
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2760
        ] ifFalse:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2761
            rightCol := selectionEndCol min:endCol
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2762
        ].
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2763
        self drawVisibleLineSelected:visLine from:leftCol to:rightCol.
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2764
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2765
        "redraw part after selection"
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2766
        (rightCol < endCol) ifTrue:[
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2767
            super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2768
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2769
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2770
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2771
    "special care for first and last line of selection:
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2772
     must handle margin also"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2773
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2774
    ((line == selectionEndLine)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2775
    and:[(startCol == 1)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2776
    and:[selectionStartLine < selectionEndLine]])
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2777
    ifTrue:[
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2593
diff changeset
  2778
        self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2779
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2780
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2781
    ((line == selectionStartLine)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2782
    and:[(startCol == 1)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2783
    and:[selectionStartLine < selectionEndLine]])
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2784
    ifTrue:[
2557
dabeb8404df8 selecting colored Text: draw correctly in selection-colors
Claus Gittinger <cg@exept.de>
parents: 2553
diff changeset
  2785
        self clearMarginOfVisibleLine:visLine with:bgColor.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2786
    ]
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2787
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  2788
    "Modified: 6.3.1996 / 14:23:26 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2789
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2790
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2791
!TextView methodsFor:'searching'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2792
2814
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  2793
clearSearchAction
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  2794
    searchAction := nil.
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  2795
!
881a1a20eace clear searchAction whenever the selection is changed.
Claus Gittinger <cg@exept.de>
parents: 2813
diff changeset
  2796
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2797
scanFor:aCharacter fromLine:startLine col:startCol forward:forward
2693
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2798
                     ifFound:foundBlock 
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2799
                  ifNotFound:notFoundBlock
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2800
    "search for a character in the direction given by forward. 
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2801
     Performs foundBlock with line/col as argument if found, notFoundBlock if not."
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2802
2693
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2803
    |lineString 
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2804
     line   "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2805
     col    "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2806
     delta  "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2807
     endCol "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2808
     cc     
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2809
     maxLine "{ Class: SmallInteger }"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2810
      |
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2811
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2812
    col := startCol.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2813
    line := startLine.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2814
    forward ifTrue:[
2693
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2815
        delta := 1.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2816
    ] ifFalse:[
2693
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2817
        delta := -1.
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2818
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2819
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2820
    lineString := list at:line.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2821
    maxLine := list size.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2822
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2823
    col := col + delta.
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2824
    [true] whileTrue:[
2693
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2825
        lineString notNil ifTrue:[
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2826
            forward ifTrue:[
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2827
                endCol := lineString size.
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2828
            ] ifFalse:[
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2829
                endCol := 1
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2830
            ].
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2831
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2832
            col to:endCol by:delta do:[:rCol |
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2833
                cc := lineString at:rCol.
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2834
                cc == aCharacter ifTrue:[
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2835
                    ^ foundBlock value:line value:rCol.
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2836
                ]
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2837
            ].
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2838
        ].
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2839
        line := line + delta.
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2840
        (line < 1 or:[line > maxLine]) ifTrue:[
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2841
            ^ notFoundBlock value
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2842
        ].
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2843
        lineString := list at:line.
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2844
        forward ifTrue:[
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2845
            col := 1
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2846
        ] ifFalse:[
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2847
            col := lineString size
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  2848
        ]
1322
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2849
    ].
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2850
    "not reached"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2851
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2852
    "Modified: 15.10.1996 / 12:22:30 / cg"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2853
    "Created: 11.9.1997 / 04:36:29 / cg"
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2854
!
b4ffcad003a7 support ST-80 style doubleClicking (enable in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2855
3802
sr
parents: 3792
diff changeset
  2856
searchAction
sr
parents: 3792
diff changeset
  2857
    ^ searchAction
sr
parents: 3792
diff changeset
  2858
!
sr
parents: 3792
diff changeset
  2859
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  2860
searchAction:aSearcherOrSearchBlock
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  2861
    searchAction := aSearcherOrSearchBlock
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  2862
!
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  2863
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2864
searchAgainInSameDirection
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2865
    "search again in the same direction and -if found- position cursor"
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2866
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2867
    |ign match|
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2868
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  2869
    searchBarActionBlock notNil ifTrue:[
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  2870
        searchBarActionBlock value:#forward value:self.
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  2871
        ^ self
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  2872
    ].
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  2873
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  2874
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2875
    match := lastSearchWasMatch ? LastSearchWasMatch ? false.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2876
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2877
    self setSearchPatternWithMatchEscapes: match.
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2878
    lastSearchPattern notNil ifTrue:[
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2879
        lastSearchDirection == #backward ifTrue:[
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2880
            self 
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2881
                searchBwd:lastSearchPattern 
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2882
                ignoreCase:ign
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2883
        ] ifFalse:[
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2884
            self 
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2885
                searchFwd:lastSearchPattern 
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2886
                ignoreCase:ign
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2887
                match: match
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2888
        ]
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2889
    ]
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2890
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  2891
    "Created: / 03-05-1999 / 15:02:16 / cg"
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  2892
    "Modified: / 21-09-2006 / 16:47:57 / cg"
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2893
!
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2894
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2895
searchBwd
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2896
    "search backward and -if found- position cursor"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2897
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2898
    |ign|
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2899
2811
3a7aed97fd76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2809
diff changeset
  2900
    searchAction notNil ifTrue:[
4063
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2901
        "/autosearch is cleared whenever there is search with user selection 
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  2902
        (self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction].
4178
db73b9c9a3f4 changed: #searchBwd
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
  2903
    ].
db73b9c9a3f4 changed: #searchBwd
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
  2904
db73b9c9a3f4 changed: #searchBwd
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
  2905
    searchAction notNil ifTrue:[
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  2906
        "/confusing: this is for autosearch of variables (browse variable uses, for example)
2811
3a7aed97fd76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2809
diff changeset
  2907
        self searchUsingSearchAction:#backward.
3a7aed97fd76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2809
diff changeset
  2908
        ^ self.
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  2909
    ].
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  2910
    searchBarActionBlock notNil ifTrue:[
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  2911
        searchBarActionBlock value:#backward value:self.
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  2912
        ^ self
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  2913
    ].
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  2914
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  2915
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2916
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  2917
    self setSearchPatternWithMatchEscapes: false.
2414
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  2918
    lastSearchPattern isNil ifTrue:[
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  2919
        LastSearchPatterns size > 0 ifTrue:[
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  2920
            lastSearchPattern := LastSearchPatterns first
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  2921
        ]
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  2922
    ].
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  2923
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2924
    lastSearchPattern notNil ifTrue:[
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2925
        lastSearchDirection := #backward.
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  2926
        self rememberSearchPattern:lastSearchPattern.
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2927
        self 
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2928
            searchBwd:lastSearchPattern 
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  2929
            ignoreCase:ign
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2930
    ]
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2931
4178
db73b9c9a3f4 changed: #searchBwd
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
  2932
    "Modified: / 22-10-2010 / 11:52:19 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2933
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2934
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2935
searchBwd:pattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2936
    "do a backward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2937
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2938
    self searchBwd:pattern ifAbsent:[self showNotFound].
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  2939
"/    lastSearchIgnoredCase := false.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  2940
    lastSearchPattern := pattern string
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  2941
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  2942
    "Modified: / 21-09-2006 / 16:48:29 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2943
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2944
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2945
searchBwd:pattern ifAbsent:aBlock
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2946
    "do a backward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2947
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2948
    |pos startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2949
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2950
    pos :=  self startPositionForSearchBackward.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2951
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2952
    startCol := pos x.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2953
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2954
    self 
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2955
        searchBackwardFor:pattern 
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2956
        startingAtLine:startLine col:startCol
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2957
        ifFound:[:line :col | 
4120
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  2958
            self showMatch:pattern isMatch:false atLine:line col:col] 
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2959
        ifAbsent:aBlock
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2960
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2961
    "Modified: 13.9.1997 / 01:05:49 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2962
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2963
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2964
searchBwd:pattern ignoreCase:ign
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2965
    "do a backward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2966
2372
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2967
    self searchBwd:pattern 
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2968
         ignoreCase:ign 
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2969
         ifAbsent:[
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  2970
                    self sensor compressKeyPressEventsWithKey:#FindPrev.
2372
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2971
                    self showNotFound
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2972
                  ].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2973
    lastSearchIgnoredCase := ign.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  2974
    lastSearchPattern := pattern string
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  2975
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  2976
    "Created: / 13.9.1997 / 06:18:00 / cg"
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  2977
    "Modified: / 6.3.1999 / 23:46:47 / cg"
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2978
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2979
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2980
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2981
    "do a backward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2982
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2983
    |pos startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2984
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2985
    pos :=  self startPositionForSearchBackward.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2986
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2987
    startCol := pos x.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2988
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2989
    self 
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2990
        searchBackwardFor:pattern 
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2991
        ignoreCase:ign
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2992
        startingAtLine:startLine col:startCol
4120
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  2993
        ifFound:[:line :col | self showMatch:pattern isMatch:false atLine:line col:col] 
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  2994
        ifAbsent:aBlock
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2995
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2996
    "Modified: 13.9.1997 / 01:05:49 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2997
    "Created: 13.9.1997 / 06:18:41 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2998
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  2999
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3000
searchBwd:pattern ignoreCase:ign match: match
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3001
    "do a backward search.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3002
    match pattern functionality is not yet available for backward search"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3003
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3004
    lastSearchWasMatch := match.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3005
    self searchBwd:pattern ignoreCase:ign.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3006
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3007
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3008
searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3009
    "select characters enclosed by matching parenthesis if one is under startLine/Col"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3010
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3011
    self 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3012
        searchForMatchingParenthesisFromLine:startLine col:startCol
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3013
        ifFound:[:line :col | 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3014
                  self selectFromLine:startLine col:startCol
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3015
                               toLine:line col:col]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3016
        ifNotFound:[self showNotFound]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3017
        onError:[self beep]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3018
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3019
    "Modified: 9.10.1997 / 12:57:34 / cg"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3020
!
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3021
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3022
searchForMatchingParenthesisFromLine:startLine col:startCol
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3023
                     ifFound:foundBlock 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3024
                  ifNotFound:notFoundBlock
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3025
                     onError:failBlock
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3026
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3027
    "search for a matching parenthesis; start search with character at startLine/startCol.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3028
     Search for the corresponding character is done forward if its an opening,
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3029
     backwards if its a closing parenthesis.
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3030
     Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3031
     If there is a nesting error, evaluate failBlock."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3032
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3033
    ^ self
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3034
        searchForMatchingParenthesisFromLine:startLine col:startCol
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3035
        ifFound:foundBlock 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3036
        ifNotFound:notFoundBlock
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3037
        onError:failBlock
3478
13c5be5a11fe match without ignore
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
  3038
        ignoring:(parenthesisSpecification at:#ignore ifAbsent:#()) "/ #( $' $" '$[' '$]' '${' '$)' )
13c5be5a11fe match without ignore
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
  3039
13c5be5a11fe match without ignore
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
  3040
    "Modified: / 12-04-2007 / 11:24:24 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3041
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3042
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3043
searchForMatchingParenthesisFromLine:startLine col:startCol
2324
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3044
                     ifFound:foundBlock 
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3045
                  ifNotFound:notFoundBlock
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3046
                     onError:failBlock
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3047
                    ignoring:ignoreSet
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3048
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3049
    "search for a matching parenthesis; start search with character at startLine/startCol.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3050
     Search for the corresponding character is done forward if its an opening,
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3051
     backwards if its a closing parenthesis.
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3052
     Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3053
     If there is a nesting error, evaluate failBlock."
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3054
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3055
    ^ self
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3056
        searchForMatchingParenthesisFromLine:startLine col:startCol
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3057
        ifFound:foundBlock 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3058
        ifNotFound:notFoundBlock
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3059
        onError:failBlock
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3060
        openingCharacters: (parenthesisSpecification at:#open)  "/ #( $( $[ ${ "$> $<") 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3061
        closingCharacters: (parenthesisSpecification at:#close) "/ #( $) $] $} "$> $<")
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3062
        ignoredCharacters: ignoreSet
3478
13c5be5a11fe match without ignore
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
  3063
        specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()) "/
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3064
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3065
"/    |i direction lineString 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3066
"/     parChar charSet  closingChar 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3067
"/     ignoring 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3068
"/     line   "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3069
"/     col    "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3070
"/     delta  "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3071
"/     endCol "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3072
"/     runCol "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3073
"/     cc prevCC nextCC incSet decSet 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3074
"/     nesting "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3075
"/     maxLine "{ Class: SmallInteger }"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3076
"/     ign skip anySet|
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3077
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3078
"/    charSet := #( $( $) $[ $] ${ $} " $< $> " ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3079
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3080
"/    parChar := self characterAtLine:startLine col:startCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3081
"/    i := charSet indexOf:parChar.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3082
"/    i == 0 ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3083
"/        ^ failBlock value   "not a parenthesis"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3084
"/    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3085
"/    direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3086
"/    closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3087
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3088
"/    col := startCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3089
"/    line := startLine.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3090
"/    direction == #fwd ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3091
"/        delta := 1.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3092
"/        incSet := #( $( $[ ${ "$<" ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3093
"/        decSet := #( $) $] $} "$>" ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3094
"/    ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3095
"/        delta := -1.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3096
"/        incSet := #( $) $] $} "$>" ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3097
"/        decSet := #( $( $[ ${ "$<" ).
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3098
"/    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3099
"/    anySet := Set new.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3100
"/    anySet addAll:incSet; addAll:decSet; addAll:ignoreSet.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3101
"/    anySet := (anySet select:[:c | c isCharacter]) asString.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3102
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3103
"/    nesting := 1.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3104
"/    ignoring := false.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3105
"/    lineString := list at:line.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3106
"/    maxLine := list size.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3107
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3108
"/    col := col + delta.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3109
"/    [nesting ~~ 0] whileTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3110
"/        (lineString notNil
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3111
"/        and:[lineString includesAny:anySet]) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3112
"/            direction == #fwd ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3113
"/                endCol := lineString size.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3114
"/            ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3115
"/                endCol := 1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3116
"/            ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3117
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3118
"/            col to:endCol by:delta do:[:rCol |
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3119
"/                runCol := rCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3120
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3121
"/                cc := lineString at:runCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3122
"/                runCol < lineString size ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3123
"/                    nextCC := lineString at:runCol+1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3124
"/                ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3125
"/                    nextCC := nil
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3126
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3127
"/                runCol > 1 ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3128
"/                    prevCC := lineString at:runCol-1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3129
"/                ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3130
"/                    prevCC := nil
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3131
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3132
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3133
"/                ign := skip := false.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3134
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3135
"/                "/ check for comments.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3136
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3137
"/                ((cc == $" and:[nextCC == $/])
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3138
"/                or:[prevCC == $$ ]) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3139
"/                    "/ do nothing
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3140
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3141
"/                    skip := true.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3142
"/                ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3143
"/                    ignoreSet do:[:ignore |
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3144
"/                        ignore == cc ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3145
"/                            ign := true
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3146
"/                        ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3147
"/                            ignore isString ifTrue:[ 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3148
"/                                cc == (ignore at:2) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3149
"/                                    runCol > 1 ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3150
"/                                        (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3151
"/                                            skip := true
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3152
"/                                        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3153
"/                                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3154
"/                                ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3155
"/                                    cc == (ignore at:1) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3156
"/                                        runCol < lineString size ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3157
"/                                            (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3158
"/                                                skip := true
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3159
"/                                            ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3160
"/                                        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3161
"/                                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3162
"/                                ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3163
"/                            ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3164
"/                        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3165
"/                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3166
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3167
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3168
"/                ign ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3169
"/                    ignoring := ignoring not
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3170
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3171
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3172
"/                ignoring ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3173
"/                    skip ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3174
"/                        (incSet includes:cc) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3175
"/                            nesting := nesting + 1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3176
"/                        ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3177
"/                            (decSet includes:cc) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3178
"/                                nesting := nesting - 1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3179
"/                            ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3180
"/                        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3181
"/                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3182
"/                ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3183
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3184
"/                nesting == 0 ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3185
"/                    "check if legal"
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3186
"/
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3187
"/                    skip ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3188
"/                        cc == closingChar ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3189
"/                            ^ failBlock value
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3190
"/                        ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3191
"/                        ^ foundBlock value:line value:runCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3192
"/                    ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3193
"/                ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3194
"/            ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3195
"/        ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3196
"/        line := line + delta.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3197
"/        (line < 1 or:[line > maxLine]) ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3198
"/            ^ failBlock value
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3199
"/        ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3200
"/        lineString := list at:line.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3201
"/        direction == #fwd ifTrue:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3202
"/            col := 1
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3203
"/        ] ifFalse:[
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3204
"/            col := lineString size
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3205
"/        ]
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3206
"/    ].
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3207
"/    ^ notFoundBlock value
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3208
3478
13c5be5a11fe match without ignore
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
  3209
    "Modified: / 12-04-2007 / 11:25:36 / cg"
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3210
!
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3211
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3212
searchForMatchingParenthesisFromLine:startLine col:startCol
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3213
                     ifFound:foundBlock 
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3214
                  ifNotFound:notFoundBlock
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3215
                     onError:failBlock
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3216
           openingCharacters:openingCharacters
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3217
           closingCharacters:closingCharacters
3605
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3218
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3219
    "search for a matching parenthesis; start search with character at startLine/startCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3220
     Search for the corresponding character is done forward if its an opening,
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3221
     backwards if its a closing parenthesis.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3222
     Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3223
     If there is a nesting error, evaluate failBlock."
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3224
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3225
    ^ self
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3226
        searchForMatchingParenthesisFromLine:startLine col:startCol
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3227
        ifFound:foundBlock 
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3228
        ifNotFound:notFoundBlock
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3229
        onError:failBlock
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3230
        openingCharacters: openingCharacters 
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3231
        closingCharacters: closingCharacters
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3232
        ignoredCharacters: (parenthesisSpecification at:#ignore ifAbsent:#())
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3233
        specialEOLComment: (parenthesisSpecification at:#eolComment ifAbsent:#()) "/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3234
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3235
"/    |i direction lineString 
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3236
"/     parChar charSet  closingChar 
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3237
"/     ignoring 
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3238
"/     line   "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3239
"/     col    "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3240
"/     delta  "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3241
"/     endCol "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3242
"/     runCol "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3243
"/     cc prevCC nextCC incSet decSet 
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3244
"/     nesting "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3245
"/     maxLine "{ Class: SmallInteger }"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3246
"/     ign skip anySet|
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3247
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3248
"/    charSet := #( $( $) $[ $] ${ $} " $< $> " ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3249
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3250
"/    parChar := self characterAtLine:startLine col:startCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3251
"/    i := charSet indexOf:parChar.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3252
"/    i == 0 ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3253
"/        ^ failBlock value   "not a parenthesis"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3254
"/    ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3255
"/    direction := #( fwd bwd fwd bwd fwd bwd fwd bwd) at:i.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3256
"/    closingChar := #( $) $( $] $[ $} ${ "$> $<") at:i.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3257
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3258
"/    col := startCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3259
"/    line := startLine.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3260
"/    direction == #fwd ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3261
"/        delta := 1.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3262
"/        incSet := #( $( $[ ${ "$<" ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3263
"/        decSet := #( $) $] $} "$>" ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3264
"/    ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3265
"/        delta := -1.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3266
"/        incSet := #( $) $] $} "$>" ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3267
"/        decSet := #( $( $[ ${ "$<" ).
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3268
"/    ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3269
"/    anySet := Set new.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3270
"/    anySet addAll:incSet; addAll:decSet; addAll:ignoreSet.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3271
"/    anySet := (anySet select:[:c | c isCharacter]) asString.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3272
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3273
"/    nesting := 1.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3274
"/    ignoring := false.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3275
"/    lineString := list at:line.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3276
"/    maxLine := list size.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3277
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3278
"/    col := col + delta.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3279
"/    [nesting ~~ 0] whileTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3280
"/        (lineString notNil
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3281
"/        and:[lineString includesAny:anySet]) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3282
"/            direction == #fwd ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3283
"/                endCol := lineString size.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3284
"/            ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3285
"/                endCol := 1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3286
"/            ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3287
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3288
"/            col to:endCol by:delta do:[:rCol |
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3289
"/                runCol := rCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3290
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3291
"/                cc := lineString at:runCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3292
"/                runCol < lineString size ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3293
"/                    nextCC := lineString at:runCol+1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3294
"/                ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3295
"/                    nextCC := nil
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3296
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3297
"/                runCol > 1 ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3298
"/                    prevCC := lineString at:runCol-1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3299
"/                ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3300
"/                    prevCC := nil
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3301
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3302
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3303
"/                ign := skip := false.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3304
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3305
"/                "/ check for comments.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3306
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3307
"/                ((cc == $" and:[nextCC == $/])
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3308
"/                or:[prevCC == $$ ]) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3309
"/                    "/ do nothing
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3310
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3311
"/                    skip := true.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3312
"/                ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3313
"/                    ignoreSet do:[:ignore |
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3314
"/                        ignore == cc ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3315
"/                            ign := true
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3316
"/                        ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3317
"/                            ignore isString ifTrue:[ 
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3318
"/                                cc == (ignore at:2) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3319
"/                                    runCol > 1 ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3320
"/                                        (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3321
"/                                            skip := true
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3322
"/                                        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3323
"/                                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3324
"/                                ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3325
"/                                    cc == (ignore at:1) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3326
"/                                        runCol < lineString size ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3327
"/                                            (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3328
"/                                                skip := true
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3329
"/                                            ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3330
"/                                        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3331
"/                                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3332
"/                                ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3333
"/                            ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3334
"/                        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3335
"/                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3336
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3337
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3338
"/                ign ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3339
"/                    ignoring := ignoring not
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3340
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3341
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3342
"/                ignoring ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3343
"/                    skip ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3344
"/                        (incSet includes:cc) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3345
"/                            nesting := nesting + 1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3346
"/                        ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3347
"/                            (decSet includes:cc) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3348
"/                                nesting := nesting - 1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3349
"/                            ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3350
"/                        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3351
"/                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3352
"/                ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3353
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3354
"/                nesting == 0 ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3355
"/                    "check if legal"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3356
"/
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3357
"/                    skip ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3358
"/                        cc == closingChar ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3359
"/                            ^ failBlock value
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3360
"/                        ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3361
"/                        ^ foundBlock value:line value:runCol.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3362
"/                    ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3363
"/                ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3364
"/            ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3365
"/        ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3366
"/        line := line + delta.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3367
"/        (line < 1 or:[line > maxLine]) ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3368
"/            ^ failBlock value
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3369
"/        ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3370
"/        lineString := list at:line.
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3371
"/        direction == #fwd ifTrue:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3372
"/            col := 1
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3373
"/        ] ifFalse:[
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3374
"/            col := lineString size
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3375
"/        ]
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3376
"/    ].
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3377
"/    ^ notFoundBlock value
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3378
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3379
    "Modified: / 12-04-2007 / 11:25:36 / cg"
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3380
!
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3381
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3382
searchForMatchingParenthesisFromLine:startLine col:startCol
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3383
                     ifFound:foundBlock 
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3384
                  ifNotFound:notFoundBlock
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3385
                     onError:failBlock
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3386
           openingCharacters:openingCharacters
08a1c0d36701 parenthesis search fixed
Claus Gittinger <cg@exept.de>
parents: 3589
diff changeset
  3387
           closingCharacters:closingCharacters
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3388
           ignoredCharacters:ignoreSet
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3389
          specialEOLComment:eolCommentSequence
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3390
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3391
    "search for a matching parenthesis; start search with character at startLine/startCol.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3392
     Search for the corresponding character is done forward if its an opening,
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3393
     backwards if its a closing parenthesis.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3394
     Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3395
     If there is a nesting error, evaluate failBlock."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3396
770
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3397
    |i direction lineString 
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3398
     parChar charSet  closingChar 
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3399
     ignoring 
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3400
     line   "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3401
     col    "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3402
     delta  "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3403
     endCol "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3404
     runCol "{ Class: SmallInteger }"
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  3405
     cc prevCC nextCC incSet decSet 
770
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3406
     nesting "{ Class: SmallInteger }"
a41466e3dfaa use integer typed variables for compact code
Claus Gittinger <cg@exept.de>
parents: 758
diff changeset
  3407
     maxLine "{ Class: SmallInteger }"
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3408
     ign skip anySet
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3409
     eol1 eol2|
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3410
2772
4e04a3bf399f check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  3411
    self assert:(openingCharacters size == closingCharacters size).
4e04a3bf399f check for a valid parenthsisSpec.
Claus Gittinger <cg@exept.de>
parents: 2756
diff changeset
  3412
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3413
    charSet := openingCharacters , closingCharacters.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3414
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3415
    parChar := self characterAtLine:startLine col:startCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3416
    i := charSet indexOf:parChar.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3417
    i == 0 ifTrue:[
2324
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3418
        ^ failBlock value   "not a parenthesis"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3419
    ].
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3420
3858
1fd3e63fb456 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3851
diff changeset
  3421
    direction := (i <= openingCharacters size) ifTrue:[#fwd] ifFalse:[#bwd].
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3422
    closingChar := (closingCharacters , openingCharacters) at:i.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3423
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3424
    eol1 := eolCommentSequence at:1 ifAbsent:nil.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3425
    eol2 := eolCommentSequence at:2 ifAbsent:nil.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3426
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3427
    col := startCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3428
    line := startLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3429
    direction == #fwd ifTrue:[
2324
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3430
        delta := 1.
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3431
        incSet := openingCharacters.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3432
        decSet := closingCharacters.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3433
    ] ifFalse:[
2324
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3434
        delta := -1.
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3435
        incSet := closingCharacters.
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3436
        decSet := openingCharacters.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3437
    ].
1454
ca768803f15d tuned searchForMatchingParen (with huge texts)
ca
parents: 1380
diff changeset
  3438
    anySet := Set new.
ca768803f15d tuned searchForMatchingParen (with huge texts)
ca
parents: 1380
diff changeset
  3439
    anySet addAll:incSet; addAll:decSet; addAll:ignoreSet.
ca768803f15d tuned searchForMatchingParen (with huge texts)
ca
parents: 1380
diff changeset
  3440
    anySet := (anySet select:[:c | c isCharacter]) asString.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3441
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3442
    nesting := 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3443
    ignoring := false.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3444
    lineString := list at:line.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3445
    maxLine := list size.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3446
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3447
    col := col + delta.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3448
    [nesting ~~ 0] whileTrue:[
2324
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3449
        (lineString notNil
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3450
        and:[lineString includesAny:anySet]) ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3451
            direction == #fwd ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3452
                endCol := lineString size.
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3453
            ] ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3454
                endCol := 1
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3455
            ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3456
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3457
            col to:endCol by:delta do:[:rCol |
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3458
                runCol := rCol.
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3459
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3460
                cc := lineString at:runCol.
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3461
                runCol < lineString size ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3462
                    nextCC := lineString at:runCol+1
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3463
                ] ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3464
                    nextCC := nil
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3465
                ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3466
                runCol > 1 ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3467
                    prevCC := lineString at:runCol-1
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3468
                ] ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3469
                    prevCC := nil
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3470
                ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3471
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3472
                ign := skip := false.
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3473
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3474
                "/ check for comments.
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3475
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  3476
                ((cc == eol1 and:[nextCC == eol2])
2324
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3477
                or:[prevCC == $$ ]) ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3478
                    "/ do nothing
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3479
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3480
                    skip := true.
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3481
                ] ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3482
                    ignoreSet do:[:ignore |
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3483
                        ignore == cc ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3484
                            ign := true
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3485
                        ] ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3486
                            ignore isString ifTrue:[ 
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3487
                                cc == (ignore at:2) ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3488
                                    runCol > 1 ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3489
                                        (lineString at:(runCol-1)) == (ignore at:1) ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3490
                                            skip := true
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3491
                                        ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3492
                                    ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3493
                                ] ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3494
                                    cc == (ignore at:1) ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3495
                                        runCol < lineString size ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3496
                                            (lineString at:(runCol+1)) == (ignore at:2) ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3497
                                                skip := true
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3498
                                            ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3499
                                        ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3500
                                    ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3501
                                ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3502
                            ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3503
                        ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3504
                    ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3505
                ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3506
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3507
                ign ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3508
                    ignoring := ignoring not
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3509
                ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3510
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3511
                ignoring ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3512
                    skip ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3513
                        (incSet includes:cc) ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3514
                            nesting := nesting + 1
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3515
                        ] ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3516
                            (decSet includes:cc) ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3517
                                nesting := nesting - 1
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3518
                            ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3519
                        ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3520
                    ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3521
                ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3522
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3523
                nesting == 0 ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3524
                    "check if legal"
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3525
                    skip ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3526
                        cc == closingChar ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3527
                            ^ failBlock value
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3528
                        ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3529
                        ^ foundBlock value:line value:runCol.
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3530
                    ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3531
                ]
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3532
            ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3533
        ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3534
        line := line + delta.
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3535
        (line < 1 or:[line > maxLine]) ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3536
            ^ failBlock value
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3537
        ].
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3538
        lineString := list at:line.
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3539
        direction == #fwd ifTrue:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3540
            col := 1
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3541
        ] ifFalse:[
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3542
            col := lineString size
98f7a9a4c50a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2306
diff changeset
  3543
        ]
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3544
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3545
    ^ notFoundBlock value
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3546
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  3547
    "Modified: 15.10.1996 / 12:22:30 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3548
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3549
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3550
searchFwd
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3551
    "search forward for pattern or selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3552
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3553
    |ign match|
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  3554
2811
3a7aed97fd76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2809
diff changeset
  3555
    searchAction notNil ifTrue:[
4177
0d89dbb77071 changed: #searchFwd
Claus Gittinger <cg@exept.de>
parents: 4169
diff changeset
  3556
        "/ autosearch is cleared whenever there is search with user selection 
4063
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  3557
        (self hasSelection and:[self hasSearchActionSelection not]) ifTrue: [self clearSearchAction].
4177
0d89dbb77071 changed: #searchFwd
Claus Gittinger <cg@exept.de>
parents: 4169
diff changeset
  3558
    ].
0d89dbb77071 changed: #searchFwd
Claus Gittinger <cg@exept.de>
parents: 4169
diff changeset
  3559
0d89dbb77071 changed: #searchFwd
Claus Gittinger <cg@exept.de>
parents: 4169
diff changeset
  3560
    searchAction notNil ifTrue:[
0d89dbb77071 changed: #searchFwd
Claus Gittinger <cg@exept.de>
parents: 4169
diff changeset
  3561
        "/ confusing: this is for autosearch of variables (browse variable uses, for example)
2811
3a7aed97fd76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2809
diff changeset
  3562
        self searchUsingSearchAction:#forward.
3a7aed97fd76 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2809
diff changeset
  3563
        ^ self.
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3564
    ].
3981
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  3565
    searchBarActionBlock notNil ifTrue:[
d45b096bb072 fixes in searchBar
fm
parents: 3970
diff changeset
  3566
        searchBarActionBlock value:#forward value:self.
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3567
        ^ self
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3568
    ].
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3569
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3570
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3571
    match := lastSearchWasMatch ? LastSearchWasMatch ? false.
1353
5dac6aa6ac96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  3572
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3573
    selectStyle == #wordLeft ifTrue:[
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3574
        "
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3575
         remove the space from the selection
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3576
        "
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3577
        selectionStartCol := selectionStartCol + 1.
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3578
        super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1.
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3579
        selectStyle := #word.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  3580
        self selectionChanged.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3581
    ].
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3582
    self setSearchPatternWithMatchEscapes: match.
2414
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3583
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3584
    lastSearchPattern isNil ifTrue:[
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3585
        LastSearchPatterns size > 0 ifTrue:[
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3586
            lastSearchPattern := LastSearchPatterns first
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3587
        ]
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3588
    ].
ec98bcbd4c61 if there is no lastSearchPattern, take from history (srchFwd / srchBwd)
Claus Gittinger <cg@exept.de>
parents: 2413
diff changeset
  3589
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3590
    lastSearchPattern notNil ifTrue:[
2201
ee684354d1d6 search-dialog is now done using a GUI-spec
Claus Gittinger <cg@exept.de>
parents: 2200
diff changeset
  3591
        self rememberSearchPattern:lastSearchPattern.
1893
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3592
        lastSearchDirection := #forward.
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3593
        self 
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3594
            searchFwd:lastSearchPattern
bce50b364466 added FindAgain function (F3 on win32)
Claus Gittinger <cg@exept.de>
parents: 1851
diff changeset
  3595
            ignoreCase:ign
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3596
            match: match
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3597
    ]
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3598
4177
0d89dbb77071 changed: #searchFwd
Claus Gittinger <cg@exept.de>
parents: 4169
diff changeset
  3599
    "Modified: / 22-10-2010 / 11:12:45 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3600
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3601
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3602
searchFwd:pattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3603
    "do a forward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3604
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3605
    self searchFwd:pattern ifAbsent:[self showNotFound].
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3606
"/    lastSearchIgnoredCase := false.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3607
    lastSearchPattern := pattern string
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3608
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3609
    "Modified: / 21-09-2006 / 16:52:04 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3610
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3611
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3612
searchFwd:pattern ifAbsent:aBlock
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3613
    "do a forward search"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3614
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3615
    |pos startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3616
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3617
    pos := self startPositionForSearchForward.
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3618
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3619
    startCol := pos x.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3620
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3621
    self 
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3622
        searchForwardFor:pattern 
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3623
        startingAtLine:startLine col:startCol
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3624
        ifFound:[:line :col | self showMatch:pattern atLine:line col:col]
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3625
        ifAbsent:aBlock
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3626
3399
c350a2e3efee dont loose the lastSearchIgnoredCase flag
Claus Gittinger <cg@exept.de>
parents: 3394
diff changeset
  3627
    "Modified: / 21-09-2006 / 16:51:28 / cg"
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3628
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3629
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3630
searchFwd:pattern ignoreCase:ign
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3631
    "do a forward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3632
2372
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3633
    self 
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3634
        searchFwd:pattern 
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3635
        ignoreCase:ign 
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3636
        ifAbsent:[
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2729
diff changeset
  3637
                    self sensor compressKeyPressEventsWithKey:#FindNext.
2372
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3638
                    self showNotFound
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3639
                 ].
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3640
    lastSearchIgnoredCase := ign.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3641
    lastSearchPattern := pattern string
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3642
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3643
    "Created: / 13.9.1997 / 06:18:13 / cg"
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3644
    "Modified: / 6.3.1999 / 23:46:58 / cg"
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3645
!
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3646
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3647
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3648
    "do a forward search"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3649
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3650
    |pos startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3651
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3652
    pos :=  self startPositionForSearchForward.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3653
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3654
    startCol := pos x.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3655
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3656
    self 
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3657
        searchForwardFor:pattern 
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3658
        ignoreCase:ign
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3659
        startingAtLine:startLine col:startCol
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3660
        ifFound:[:line :col | self showMatch:pattern atLine:line col:col]
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3661
        ifAbsent:aBlock
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3662
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3663
    "Modified: 13.9.1997 / 01:05:35 / cg"
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3664
    "Created: 13.9.1997 / 06:18:27 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3665
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3666
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3667
searchFwd:pattern ignoreCase:ign match: match
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3668
    "do a forward search"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3669
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3670
    self 
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3671
        searchFwd:pattern 
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3672
        ignoreCase:ign 
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3673
        match: match
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3674
        ifAbsent:[
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3675
                    self sensor compressKeyPressEventsWithKey:#FindNext.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3676
                    self showNotFound
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3677
                 ].
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3678
    lastSearchIgnoredCase := ign.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3679
    lastSearchWasMatch := match.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3680
    lastSearchPattern := pattern string
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3681
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3682
    "Created: / 13.9.1997 / 06:18:13 / cg"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3683
    "Modified: / 6.3.1999 / 23:46:58 / cg"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3684
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3685
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3686
searchFwd:pattern ignoreCase:ign match: match ifAbsent:aBlock
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3687
    "do a forward search"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3688
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3689
    |pos startLine startCol|
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3690
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3691
    pos :=  self startPositionForSearchForward.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3692
    startLine := pos y.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3693
    startCol := pos x.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3694
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3695
    self 
3581
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3696
        searchFwd:pattern 
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3697
        ignoreCase:ign
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3698
        match: match
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3699
        startingAtLine:startLine col:startCol
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3700
        ifAbsent:aBlock
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3701
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3702
    "Modified: 13.9.1997 / 01:05:35 / cg"
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3703
    "Created: 13.9.1997 / 06:18:27 / cg"
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3704
!
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3705
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3706
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3707
    "do a forward search"
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3708
950b9b6939ee StringSearchTool
fm
parents: 3577
diff changeset
  3709
    self 
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3710
        searchForwardFor:pattern 
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3711
        ignoreCase:ign
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3712
        match: match
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3713
        startingAtLine:startLine col:startCol
4120
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3714
        ifFound:[:line :col | self showMatch:pattern isMatch:match atLine:line col:col]
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3715
        ifAbsent:aBlock
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3716
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3717
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3718
searchPattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3719
    "return the last search pattern"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3720
1326
fbc08e9e2c55 allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  3721
    ^ lastSearchPattern
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3722
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3723
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3724
searchUsingSearchAction:direction
2816
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3725
    self 
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3726
        searchUsingSearchAction:direction
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3727
        ifAbsent:[
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3728
                    self sensor compressKeyPressEventsWithKey:#FindNext.
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3729
                    self showNotFound
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3730
                 ]
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3731
!
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3732
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3733
searchUsingSearchAction:direction ifAbsent:notFoundAction
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3734
    |pos startLine startCol|
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3735
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3736
    pos :=  direction == #backward 
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3737
                ifTrue:[self startPositionForSearchBackward] 
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3738
                ifFalse:[self startPositionForSearchForward].
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3739
    startLine := pos y.
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3740
    startCol := pos x.
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3741
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3742
    searchAction notNil ifTrue:[
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3743
        searchAction 
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3744
            value:direction 
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3745
            value:startLine 
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3746
            value:startCol 
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3747
            value:[:line :col | self selectFromLine:line toLine:line] 
2816
98eace39864f autosearch without beep
Claus Gittinger <cg@exept.de>
parents: 2814
diff changeset
  3748
            value:notFoundAction. 
4063
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  3749
        self hasSelection ifTrue: [
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  3750
            self changeTypeOfSelectionTo: #searchAction.
6d2caa13cb14 added: #hasSearchActionSelection
fm
parents: 4056
diff changeset
  3751
        ].
2807
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3752
    ].
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3753
!
499d355a3f53 pluggable searchAction
Claus Gittinger <cg@exept.de>
parents: 2806
diff changeset
  3754
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3755
setSearchPattern
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3756
    "set the searchpattern from the selection if there is one"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3757
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3758
    self setSearchPatternWithMatchEscapes: false.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3759
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3760
3904
dd4c2dace4f5 changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents: 3892
diff changeset
  3761
setSearchPattern:aStringOrNil
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3762
    "set the searchpattern for future searches"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3763
3904
dd4c2dace4f5 changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents: 3892
diff changeset
  3764
    aStringOrNil isEmptyOrNil ifTrue:[
dd4c2dace4f5 changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents: 3892
diff changeset
  3765
        lastSearchPattern := nil. 
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3766
    ] ifFalse:[
3904
dd4c2dace4f5 changed #setSearchPattern: comment
Stefan Vogel <sv@exept.de>
parents: 3892
diff changeset
  3767
        lastSearchPattern := aStringOrNil asString withoutSeparators string.
1769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3768
    ].
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3769
5e272292723b remove text-attributes in lastSearchPattern
Claus Gittinger <cg@exept.de>
parents: 1766
diff changeset
  3770
    "Modified: / 6.3.1999 / 23:47:36 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3771
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3772
2200
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  3773
setSearchPattern:aString ignoreCase:aBoolean
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  3774
    "set the searchpattern and caseIgnore for future searches"
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  3775
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  3776
    self setSearchPattern:aString.
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  3777
    lastSearchIgnoredCase := aBoolean.
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  3778
!
8dad27a92dbd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2191
diff changeset
  3779
3577
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3780
setSearchPatternWithMatchEscapes: match
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3781
    "set the searchpattern from the selection if there is one"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3782
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3783
    |sel searchPattern |
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3784
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3785
"/    clickPos isNil ifTrue:[^ self].
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3786
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3787
    sel := self selection.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3788
    sel notNil ifTrue:[
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3789
        searchPattern := sel asString.
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3790
        match ifTrue:[searchPattern := searchPattern withMatchEscapes].
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3791
        self setSearchPattern:searchPattern. 
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3792
    ]
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3793
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3794
    "Modified: / 6.3.1999 / 23:48:04 / cg"
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3795
!
092957d43987 searchForward with match argument
fm
parents: 3528
diff changeset
  3796
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3797
showMatch:pattern atLine:line col:col
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3798
    "after a search, highlight the matched pattern.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3799
     The code below needs a rewrite to take care of match-characters
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3800
     (for now, it only highlights simple patterns and '*string*' correctly)"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3801
4120
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3802
    self showMatch:pattern isMatch:true atLine:line col:col
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3803
!
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3804
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3805
showMatch:pattern isMatch:isMatch atLine:line col:col
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3806
    "after a search, highlight the matched pattern.
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3807
     The code below needs a rewrite to take care of match-characters
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3808
     (for now, it only highlights simple patterns and '*string*' correctly)"
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3809
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3810
    |realPattern|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3811
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3812
    realPattern := pattern.
4120
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3813
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3814
    isMatch ifTrue: [
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3815
        (realPattern startsWith:$*) ifTrue:[
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3816
            realPattern := realPattern copyFrom:2
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3817
        ].
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3818
        (realPattern endsWith:$*) ifTrue:[
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3819
            realPattern := realPattern copyWithoutLast:1
499451998d77 added: #showMatch:isMatch:atLine:col:
fm
parents: 4101
diff changeset
  3820
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3821
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3822
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3823
    self selectFromLine:line col:col
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  3824
                 toLine:line col:(col + realPattern size - 1).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3825
    self makeLineVisible:line
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3826
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3827
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3828
showNotFound
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3829
    "search not found - tell user by beeping and changing
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3830
     cursor for a while (sometimes I work with a headset :-)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3831
     (used to be: tell user by changing cursor for a while)"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3832
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3833
    |savedCursor|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3834
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3835
    savedCursor := cursor.
1028
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  3836
    [
2372
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3837
        self cursor:(Cursor cross).
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3838
        self beep.
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3839
        Processor activeProcess millisecondDelay:300.
2520
aed8069b4477 #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 2488
diff changeset
  3840
    ] ensure:[
2372
74102d251f55 avoid annoying beeps in search-fwd/bwd
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3841
        self cursor:savedCursor
1028
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  3842
    ]
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  3843
02048e7e493b showNotFound - unwinding
Claus Gittinger <cg@exept.de>
parents: 1016
diff changeset
  3844
    "Modified: 20.2.1997 / 12:49:27 / cg"
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3845
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3846
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3847
startPositionForSearchBackward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  3848
    ^ self startPositionForSearchBackwardBasedOnSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  3849
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  3850
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  3851
startPositionForSearchBackwardBasedOnSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3852
    |startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3853
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3854
    selectionStartLine notNil ifTrue:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3855
        startLine := selectionStartLine.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3856
        startCol := selectionStartCol
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3857
    ] ifFalse:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3858
        startLine := 1.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3859
        startCol := 1
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3860
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3861
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3862
    ^ startCol @ startLine
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3863
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3864
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3865
startPositionForSearchForward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  3866
    ^ self startPositionForSearchForwardBasedOnSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  3867
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  3868
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2821
diff changeset
  3869
startPositionForSearchForwardBasedOnSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3870
    |startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3871
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3872
    selectionStartLine notNil ifTrue:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3873
        startLine := selectionStartLine.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3874
        startCol := selectionStartCol
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3875
    ] ifFalse:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3876
        startLine := 1.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3877
        startCol := 1
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3878
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3879
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2752
diff changeset
  3880
    ^ startCol @ startLine
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3881
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3882
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3883
!TextView methodsFor:'selections'!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  3884
2604
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3885
changeTypeOfSelectionTo:newType
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3886
    "ignored here - but redefined in subclasses which
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3887
     differentiate between pasted- and user-selections"
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3888
!
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3889
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3890
expandSelectionDown
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3891
    |l t|
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3892
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3893
    selectionStartLine notNil ifTrue:[
2604
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3894
        expandingTop == true ifTrue:[
2442
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3895
            l := selectionStartLine.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3896
            selectionStartLine := selectionStartLine + 1.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3897
            (selectionStartLine > clickLine
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3898
            or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]])
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3899
            ifTrue:[
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3900
                t := selectionStartLine.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3901
                selectionStartLine := selectionEndLine.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3902
                selectionEndLine := t.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3903
                t := selectionStartCol.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3904
                selectionStartCol := selectionEndCol.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3905
                selectionEndCol := t.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3906
                expandingTop := false
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3907
            ].
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3908
        ] ifFalse:[
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3909
            l := selectionEndLine.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3910
            selectionEndLine := selectionEndLine + 1.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3911
        ].
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3912
"/        self redrawLine:l. 
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3913
"/        self redrawLine:l+1.
2660
1352e7b3ac67 always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents: 2630
diff changeset
  3914
        self validateNewSelection.
2442
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3915
        self redrawFromLine:l to:l+1.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3916
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3917
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3918
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3919
    "Created: 1.3.1996 / 23:35:08 / cg"
502
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  3920
    "Modified: 18.3.1996 / 17:18:15 / cg"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3921
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3922
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3923
expandSelectionLeft
502
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  3924
    |c l t c1 c2|
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3925
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3926
    selectionStartLine notNil ifTrue:[
2604
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3927
        expandingTop == true ifTrue:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3928
            selectionStartCol == 0 ifTrue:[^ self].
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3929
            l := selectionStartLine.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3930
            selectionStartCol := (selectionStartCol - 1) max:1.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3931
            c := selectionStartCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3932
        ] ifFalse:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3933
            l := selectionEndLine.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3934
            selectionEndCol := (selectionEndCol - 1) max:0.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3935
            c := selectionEndCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3936
            selectionEndLine == selectionStartLine ifTrue:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3937
                selectionEndCol <= selectionStartCol ifTrue:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3938
                    t := selectionStartCol. selectionStartCol := selectionEndCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3939
                    selectionEndCol := t.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3940
                    expandingTop := true.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3941
                    c := selectionStartCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3942
                ]
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3943
            ].
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3944
        ].
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3945
        c1 := c.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3946
        c2 := c1 + 1.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3947
        c1 == 0 ifTrue:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3948
            c1 := 1
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3949
        ].
2660
1352e7b3ac67 always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents: 2630
diff changeset
  3950
        self validateNewSelection.
2604
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3951
        self redrawLine:l from:c1 to:c2. 
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3952
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3953
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3954
502
6f3d0d7a782c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
  3955
    "Modified: 18.3.1996 / 17:05:46 / cg"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3956
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3957
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3958
expandSelectionRight
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3959
    |l c t|
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3960
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3961
    selectionStartLine notNil ifTrue:[
2604
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3962
        expandingTop == true ifTrue:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3963
            l := selectionStartLine.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3964
            c := selectionStartCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3965
            selectionStartCol := selectionStartCol + 1.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3966
            l == selectionEndLine ifTrue:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3967
                c >= selectionEndCol ifTrue:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3968
                    expandingTop := false.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3969
                    t := selectionStartCol. selectionStartCol := selectionEndCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3970
                    selectionEndCol := t.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3971
                    c := selectionStartCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3972
                ]
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3973
            ]
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3974
        ] ifFalse:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3975
            l := selectionEndLine.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3976
            c := selectionEndCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3977
            selectionEndCol := selectionEndCol + 1.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3978
        ].
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3979
2660
1352e7b3ac67 always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents: 2630
diff changeset
  3980
        self validateNewSelection.
2604
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3981
        self redrawLine:l from:c to:c+1.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3982
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3983
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3984
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3985
    "Created: 1.3.1996 / 23:33:17 / cg"
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3986
    "Modified: 6.3.1996 / 13:54:10 / cg"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3987
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3988
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3989
expandSelectionUp
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  3990
    |l t|
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3991
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  3992
    selectionStartLine notNil ifTrue:[
2604
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  3993
        expandingTop == true ifTrue:[
2442
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3994
            selectionStartLine := (selectionStartLine - 1) max:1.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3995
            l := selectionStartLine. 
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3996
        ] ifFalse:[
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3997
            selectionEndLine := (selectionEndLine - 1) max:0.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3998
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  3999
            l := selectionEndLine.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4000
            (selectionEndLine < clickLine
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4001
            or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])])
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4002
            ifTrue:[
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4003
                t := selectionStartLine.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4004
                selectionStartLine := selectionEndLine.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4005
                selectionEndLine := t.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4006
                t := selectionStartCol.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4007
                selectionStartCol := selectionEndCol.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4008
                selectionEndCol := t.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4009
                l := selectionStartLine.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4010
                expandingTop := true
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4011
            ].
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4012
        ].
2660
1352e7b3ac67 always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents: 2630
diff changeset
  4013
        self validateNewSelection.
2442
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4014
        "/ self redrawLine:l. 
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4015
        "/ self redrawLine:l+1. 
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4016
        self redrawFromLine:l to:l+1.
914a5ef62334 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4017
        self makeSelectionVisible.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4018
    ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4019
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4020
    "Modified: 6.3.1996 / 14:12:06 / cg"
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4021
!
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
  4022
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4023
hasSelection
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4024
    "return true, if there is a selection"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4025
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4026
    ^ selectionStartLine notNil
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4027
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4028
2350
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4029
hasSelectionForCopy
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4030
    "return true, if there is a selection which can be copyied
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4031
     (the same as #hasSelection, except for editfields in password-mode)"
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4032
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4033
    ^ self hasSelection
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4034
!
c09d3dd534e3 do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents: 2336
diff changeset
  4035
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4036
hasSelectionWithinSingleLine
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4037
    "return true, if there is a selection and it is within a line"
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4038
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4039
    ^ selectionStartLine notNil
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4040
      and:[ selectionStartLine == selectionEndLine ]
3315
1b42d2f8dcbc CRLF management
fm
parents: 3308
diff changeset
  4041
1b42d2f8dcbc CRLF management
fm
parents: 3308
diff changeset
  4042
    "Modified: / 04-07-2006 / 18:42:59 / fm"
2530
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4043
!
83e7b4b71496 searchDialog is optionally non-modal
Claus Gittinger <cg@exept.de>
parents: 2520
diff changeset
  4044
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  4045
isInSelection:line col:aColNr
96256221e3af support drag
ca
parents: 2581
diff changeset
  4046
    "returns true, if the line, and column is in the selection
96256221e3af support drag
ca
parents: 2581
diff changeset
  4047
    "
3438
d83030fd5005 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3426
diff changeset
  4048
    selectionStartLine isNil ifTrue:[^ false].
d83030fd5005 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3426
diff changeset
  4049
    selectionEndLine   isNil ifTrue:[^ false].
2588
96256221e3af support drag
ca
parents: 2581
diff changeset
  4050
96256221e3af support drag
ca
parents: 2581
diff changeset
  4051
    (line between:selectionStartLine and:selectionEndLine) ifFalse:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  4052
        ^ false
96256221e3af support drag
ca
parents: 2581
diff changeset
  4053
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  4054
96256221e3af support drag
ca
parents: 2581
diff changeset
  4055
    line == selectionStartLine ifTrue:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  4056
        aColNr < selectionStartCol ifTrue:[^ false]
96256221e3af support drag
ca
parents: 2581
diff changeset
  4057
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  4058
96256221e3af support drag
ca
parents: 2581
diff changeset
  4059
    line == selectionEndLine ifTrue:[
96256221e3af support drag
ca
parents: 2581
diff changeset
  4060
        (selectionEndCol ~~ 0 and:[selectionEndCol < aColNr]) ifTrue:[^ false]
96256221e3af support drag
ca
parents: 2581
diff changeset
  4061
    ].
96256221e3af support drag
ca
parents: 2581
diff changeset
  4062
    ^ true
96256221e3af support drag
ca
parents: 2581
diff changeset
  4063
!
96256221e3af support drag
ca
parents: 2581
diff changeset
  4064
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4065
makeSelectionVisible
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4066
    "scroll to make the selection visible"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4067
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4068
    |line col|
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4069
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4070
    selectionStartLine notNil ifTrue:[
2604
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4071
        expandingTop == true ifTrue:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4072
            line := selectionStartLine.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4073
            col := selectionStartCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4074
        ] ifFalse:[
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4075
            line := selectionEndLine.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4076
            col := selectionEndCol.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4077
        ].
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4078
        self makeLineVisible:line.
2031eca912aa selections changing the typeOfSelection
Claus Gittinger <cg@exept.de>
parents: 2600
diff changeset
  4079
        self makeColVisible:col inLine:line.        
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4080
    ]
478
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4081
180275291838 show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
  4082
    "Modified: 6.3.1996 / 13:53:45 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4083
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4084
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4085
selectAll
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4086
    "select the whole text"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4087
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4088
    self selectFromLine:1 col:1 toLine:(list size + 1) col:0
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4089
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4090
4140
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4091
selectFromCharacterPosition:pos1
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4092
    "compute line/col from the character position and select the text up to the end"
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4093
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4094
    |line1 col1 line2 col2|
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4095
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4096
    line1 := self lineOfCharacterPosition:pos1.
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4097
    col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1.
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4098
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4099
    line2 := (list size + 1).
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4100
    col2 := 0.
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4101
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4102
!
435dc4fec8fb added: #selectFromCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 4120
diff changeset
  4103
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4104
selectFromCharacterPosition:pos1 to:pos2
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4105
    "compute line/col from character positions and select the text"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4106
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4107
    |line1 col1 line2 col2|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4108
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4109
    line1 := self lineOfCharacterPosition:pos1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4110
    col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4111
    line2 := self lineOfCharacterPosition:pos2.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4112
    col2 := pos2 - (self characterPositionOfLine:line2 col:1) + 1.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4113
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4114
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4115
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4116
selectFromLine:startLine col:startCol toLine:endLine col:endCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4117
    "select a piece of text and redraw that area"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4118
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4119
    self unselect.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4120
    startLine notNil ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4121
        "new:"
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4122
        endLine < startLine ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4123
            ^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4124
        ].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4125
        (endLine == startLine and:[endCol < startCol]) ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4126
            endCol ~~ 0 ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4127
                self selectFromLine:endLine col:endCol toLine:startLine col:startCol.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4128
            ].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4129
            ^ self
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4130
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4131
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4132
" old:
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4133
        endLine < startLine ifTrue:[^ self].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4134
        (startLine == endLine and:[endCol < startCol]) ifTrue:[^ self].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4135
"
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4136
        selectionStartLine := startLine.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4137
        selectionStartCol := startCol.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4138
        selectionEndLine := endLine.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4139
        selectionEndCol := endCol.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4140
        self validateNewSelection.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4141
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4142
        (selectionStartLine == selectionEndLine) ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4143
            self redrawLine:selectionStartLine from:selectionStartCol to:selectionEndCol
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4144
        ] ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4145
            selectionStartLine to:selectionEndLine do:[:lineNr |
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4146
                self redrawLine:lineNr
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4147
            ]
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4148
        ].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4149
        selectStyle := nil.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4150
    ]
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4151
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4152
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4153
     |v|
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4154
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4155
     v := TextView extent:300@300.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4156
     v contents:('smalltalk.rc' asFilename contentsOfEntireFile).
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4157
     v openAndWait.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4158
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4159
     Delay waitForSeconds:1.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4160
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4161
     v selectFromLine:2 col:2 toLine:10 col:15
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4162
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4163
904
597bf5cfe653 care for changed selection from #validateNewSelection
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
  4164
    "Modified: 2.1.1997 / 13:32:25 / cg"
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4165
!
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4166
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4167
selectFromLine:startLine toLine:endLine
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4168
    "select a piece of text and redraw that area"
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4169
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4170
    self selectFromLine:startLine col:1 toLine:endLine+1 col:0
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4171
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4172
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4173
     |v|
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4174
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4175
     v := TextView extent:300@300.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4176
     v contents:('smalltalk.rc' asFilename contentsOfEntireFile).
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4177
     v openAndWait.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4178
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4179
     Delay waitForSeconds:1.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4180
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4181
     v selectFromLine:2 toLine:10
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4182
    "
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4183
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4184
    "Modified: 29.4.1996 / 12:23:46 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4185
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4186
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4187
selectLine:selectLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4188
    "select one line and redraw it"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4189
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4190
    self selectFromLine:selectLine col:1 toLine:(selectLine + 1) col:0.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4191
    wordStartCol := selectionStartCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4192
    wordEndCol := selectionEndCol.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4193
    wordStartLine := selectionStartLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4194
    wordEndLine := selectionEndLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4195
    selectStyle := #line
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4196
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4197
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4198
selectLineAtY:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4199
    "select the line at given y-(view-)coordinate"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4200
2413
2a72970c1da8 use #lineAtY:
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
  4201
    |selectLine|
2a72970c1da8 use #lineAtY:
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
  4202
2a72970c1da8 use #lineAtY:
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
  4203
    selectLine := self lineAtY:y. "/ self visibleLineToListLine:(self visibleLineOfY:y).
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4204
    selectLine notNil ifTrue:[
2413
2a72970c1da8 use #lineAtY:
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
  4205
        self selectLine:selectLine
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4206
    ]
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4207
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4208
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4209
selectLineWhereCharacterPosition:pos
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4210
    "select the line, where characterPosition pos is living.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4211
     The argument pos starts at 1 from the start of the text
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4212
     and counts characters (i.e. can be used to convert from 
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4213
     character position within a string to line-position in view)."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4214
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4215
    self selectLine:(self lineOfCharacterPosition:pos)
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4216
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4217
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4218
selectWordAtLine:line col:col
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4219
    "select the word at given line/col"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4220
3892
610a0ff65806 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3858
diff changeset
  4221
    self 
610a0ff65806 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3858
diff changeset
  4222
        wordAtLine:line col:col do:[
610a0ff65806 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3858
diff changeset
  4223
            :beginLine :beginCol :endLine :endCol :style |
610a0ff65806 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3858
diff changeset
  4224
610a0ff65806 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3858
diff changeset
  4225
            self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
610a0ff65806 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3858
diff changeset
  4226
            selectStyle := style
610a0ff65806 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3858
diff changeset
  4227
        ]
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  4228
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  4229
    "Modified: 18.3.1996 / 17:30:38 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4230
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4231
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4232
selectWordAtX:x y:y
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4233
    "select the word at given x/y-(view-)coordinate"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4234
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4235
    |selectVisibleLine selectLine selectCol|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4236
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4237
    selectStyle := nil.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4238
    selectVisibleLine := self visibleLineOfY:y.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4239
    selectLine := self visibleLineToListLine:selectVisibleLine.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4240
    selectLine notNil ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4241
        selectCol := self colOfX:x inVisibleLine:selectVisibleLine.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4242
        self selectWordAtLine:selectLine col:selectCol
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4243
    ]
1661
bf446f457d95 fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4244
bf446f457d95 fixed selectWordAtX:y for variable fonts.
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
  4245
    "Modified: / 8.9.1998 / 21:22:46 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4246
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4247
3528
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4248
selectedInterval
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4249
    "return the selection-boundaries as interval"
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4250
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4251
    ^ self selectionStartIndex to:(self selectionStopIndex - 1)
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4252
!
753b5270dc2a +selectedInterval
Claus Gittinger <cg@exept.de>
parents: 3505
diff changeset
  4253
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4254
selection
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4255
    "return the selection as a collection of (line-)strings.
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4256
     If the selection ends in a full line, the last entry in the returned
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4257
     collection will be an empty string."
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4258
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4259
    |sel|
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4260
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4261
    selectionStartLine isNil ifTrue:[^ nil].
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4262
    sel := self textFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol.
3298
cf51bd945909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3292
diff changeset
  4263
    sel notNil ifTrue:[
cf51bd945909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3292
diff changeset
  4264
        (characterEncoding ? #'unicode') ~~ #'unicode' ifTrue:[
cf51bd945909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3292
diff changeset
  4265
            sel := sel encodeFrom:characterEncoding into:#'unicode'
cf51bd945909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3292
diff changeset
  4266
        ].
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4267
    ].
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4268
    ^ sel
2158
1fbe3297506f generalized text-access fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents: 2120
diff changeset
  4269
1fbe3297506f generalized text-access fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents: 2120
diff changeset
  4270
    "Modified: / 22.2.2000 / 23:54:54 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4271
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4272
2217
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4273
selectionAsString
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4274
    "return the selection as a String (i.e. without emphasis)"
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4275
2693
9e7da8ff444d unused methodLocals removed
Claus Gittinger <cg@exept.de>
parents: 2691
diff changeset
  4276
    |sel|
2217
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4277
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4278
    (sel := self selection) isNil ifTrue:[^ nil].
2419
2ae3350454bc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2415
diff changeset
  4279
    sel := sel collect:[:each| each isNil ifTrue:[nil] ifFalse:[each string]].
2217
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4280
    ^ (sel asStringWithCRsFrom:1 to:(sel size) compressTabs:false withCR:false) string
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4281
!
08502466e36d added #selectionAsString
Claus Gittinger <cg@exept.de>
parents: 2206
diff changeset
  4282
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4283
selectionChanged
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4284
    "can be redefined for notification or special actions"
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4285
!
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4286
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4287
selectionEndCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4288
    ^ selectionEndCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4289
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4290
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4291
selectionEndLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4292
    ^ selectionEndLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4293
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4294
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4295
selectionStartCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4296
    ^ selectionStartCol
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4297
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4298
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4299
selectionStartLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4300
    ^ selectionStartLine
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4301
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4302
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4303
st80SelectMode
3459
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4304
    st80SelectMode notNil ifTrue:[^ st80SelectMode].
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4305
    ^ self class st80SelectMode
3308
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4306
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4307
    "Created: / 03-07-2006 / 16:30:59 / cg"
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4308
!
4c2c30b357c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3304
diff changeset
  4309
3459
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4310
st80SelectMode:aBoolean
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4311
    st80SelectMode := aBoolean
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4312
!
2767ddcf8bf0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3443
diff changeset
  4313
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4314
unselect
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4315
    "unselect - if there was a selection redraw that area"
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4316
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4317
    |startLine endLine startVisLine endVisLine|
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4318
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4319
    selectionStartLine notNil ifTrue:[
3318
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4320
        startLine := selectionStartLine.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4321
        endLine := selectionEndLine.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4322
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4323
        self unselectWithoutRedraw.
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4324
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4325
        "/ if the selection is not visible, we are done
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4326
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4327
        startLine >= (firstLineShown + nLinesShown) ifTrue:[^ self].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4328
        endLine < firstLineShown ifTrue:[^ self].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4329
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4330
        startLine < firstLineShown ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4331
            startVisLine := 1
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4332
        ] ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4333
            startVisLine := self listLineToVisibleLine:startLine
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4334
        ].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4335
        endLine >= (firstLineShown + nLinesShown) ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4336
            endVisLine := nLinesShown
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4337
        ] ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4338
            endVisLine := self listLineToVisibleLine:endLine
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4339
        ].
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4340
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4341
        "/ if its only part of a line, just redraw what has to be
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4342
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4343
        (startLine == endLine) ifTrue:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4344
            super redrawVisibleLine:startVisLine from:selectionStartCol to:selectionEndCol
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4345
        ] ifFalse:[
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4346
            self redrawFromVisibleLine:startVisLine to:endVisLine
ebd115677fd5 felix' search refactoring
fm
parents: 3316
diff changeset
  4347
        ].
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4348
    ].
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4349
    selectStyle := nil
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
  4350
715
a5856fcdbf0f fixed unselect-redraw
Claus Gittinger <cg@exept.de>
parents: 712
diff changeset
  4351
    "Modified: 29.5.1996 / 14:54:11 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4352
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4353
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4354
unselectWithoutRedraw
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4355
    "forget selection but do not redraw the selection area
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4356
     - can be done when the selected area is redrawn anyway or
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4357
     known to be invisible (however, redraw knows about that anyway)."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4358
2735
5ba2010aefa4 *** empty log message ***
penk
parents: 2730
diff changeset
  4359
    selectionStartLine := selectionEndLine := nil.
4101
af694bc33754 added: #selectionChanged
Claus Gittinger <cg@exept.de>
parents: 4099
diff changeset
  4360
    self selectionChanged.
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4361
!
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4362
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4363
validateNewSelection
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4364
     "make certain that the selection is valid.
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4365
      This is a dummy here, but subclasses (like single-line editFields)
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4366
      may redefine it to limit the selection to a single line, or whatever."
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4367
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4368
    ^ self
504
36599ce06054 spaceCatching optional
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
  4369
599
aae5e752e1cf characterAtLine:col: moved to super; added #selectFromLine:toLine: ; comments
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
  4370
    "Modified: 29.4.1996 / 12:32:08 / cg"
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4371
! !
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4372
844
03e45d817dce fixed matching-parenthesis search over eol-comments
Claus Gittinger <cg@exept.de>
parents: 830
diff changeset
  4373
!TextView class methodsFor:'documentation'!
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4374
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4375
version
4255
9bf0cc2595a9 changed: #doubleClickX:y:
Claus Gittinger <cg@exept.de>
parents: 4254
diff changeset
  4376
    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.324 2011-06-14 12:08:52 cg Exp $'
3964
f272bb5029f0 *** empty log message ***
fm
parents: 3914
diff changeset
  4377
!
f272bb5029f0 *** empty log message ***
fm
parents: 3914
diff changeset
  4378
f272bb5029f0 *** empty log message ***
fm
parents: 3914
diff changeset
  4379
version_CVS
4255
9bf0cc2595a9 changed: #doubleClickX:y:
Claus Gittinger <cg@exept.de>
parents: 4254
diff changeset
  4380
    ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.324 2011-06-14 12:08:52 cg Exp $'
248
c58fabf73c35 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  4381
! !
2630
f3c95e73f862 for now: do not use alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2604
diff changeset
  4382
2553
9838f1097a2f allow for parenthesis matcher to be configured
Claus Gittinger <cg@exept.de>
parents: 2547
diff changeset
  4383
TextView initialize!