revert parser stuff from enhenced patch
[nedit-bw.git] / extended-paragraph-any.patch
blob224f654094acb25da141c2ffd542780cb8798ac3
1 ---
3 doc/help.etx | 13 ++++++----
4 source/text.c | 75 ++++++++++++++++++++++++++++++++++++++++++++--------------
5 2 files changed, 67 insertions(+), 21 deletions(-)
7 diff --quilt old/source/text.c new/source/text.c
8 --- old/source/text.c
9 +++ new/source/text.c
10 @@ -3006,33 +3006,52 @@ static void forwardParagraphAP(Widget w,
11 textDisp *textD = ((TextWidget)w)->text.textD;
12 int pos, insertPos = TextDGetInsertPosition(textD);
13 textBuffer *buf = textD->buffer;
14 int silent = hasKey("nobell", args, nArgs);
15 int not_end = !hasKey("end", args, nArgs);
16 + int any = hasKey("any", args, nArgs);
18 cancelDrag(w);
20 + /* "end" and "any" are mutual exclusive */
21 + if (any && !not_end) {
22 + return;
23 + }
25 /* check if we are at the end of the file, than return */
26 if (insertPos == buf->length) {
27 ringIfNecessary(silent, w);
28 return;
31 - /* need to skip current paragraph? */
32 - if (not_end != lineIsBlank(buf, insertPos, &pos)) {
33 + if (any) {
34 + int stop = !lineIsBlank(buf, insertPos, &pos);
36 while (pos < buf->length) {
37 - if (not_end == nextLineIsBlank(buf, pos, &pos)) {
38 + if (stop == nextLineIsBlank(buf, pos, &pos)) {
39 break;
42 - }
44 - /* skip all blank lines */
45 - while (pos < buf->length) {
46 - if (not_end != nextLineIsBlank(buf, pos, &pos)) {
47 - break;
48 + } else {
50 + /* need to skip current paragraph? */
51 + if (not_end != lineIsBlank(buf, insertPos, &pos)) {
52 + while (pos < buf->length) {
53 + if (not_end == nextLineIsBlank(buf, pos, &pos)) {
54 + break;
55 + }
56 + }
59 + /* skip all blank lines */
60 + while (pos < buf->length) {
61 + if (not_end != nextLineIsBlank(buf, pos, &pos)) {
62 + break;
63 + }
64 + }
68 TextDSetInsertPosition(textD, min(pos, buf->length));
69 checkMoveSelectionChange(w, event, insertPos, args, nArgs);
70 checkAutoShowInsertPos(w);
71 @@ -3045,35 +3064,57 @@ static void backwardParagraphAP(Widget w
72 textDisp *textD = ((TextWidget)w)->text.textD;
73 int parStart, pos, insertPos = TextDGetInsertPosition(textD);
74 textBuffer *buf = textD->buffer;
75 int silent = hasKey("nobell", args, nArgs);
76 int not_end = !hasKey("end", args, nArgs);
77 + int any = hasKey("any", args, nArgs);
79 cancelDrag(w);
81 + /* "end" and "any" are mutual exclusive */
82 + if (any && !not_end) {
83 + return;
84 + }
86 /* check if we are at the beginning of the file, than return */
87 if (0 == insertPos) {
88 ringIfNecessary(silent, w);
89 return;
92 - if (not_end == lineIsBlank(buf, insertPos, &parStart)
93 - || (insertPos == parStart
94 - && not_end == prevLineIsBlank(buf, parStart, &parStart))) {
95 + if (any) {
96 + int stop = lineIsBlank(buf, insertPos, &parStart)
97 + || !(insertPos == parStart
98 + && prevLineIsBlank(buf, parStart, &parStart));
100 while (parStart > 0) {
101 - if (not_end != prevLineIsBlank(buf, parStart, &pos)) {
102 + if (stop == prevLineIsBlank(buf, parStart, &pos)) {
103 break;
105 parStart = pos;
109 - while (parStart > 0) {
110 - if (not_end == prevLineIsBlank(buf, parStart, &pos)) {
111 - break;
112 + } else {
114 + if (not_end == lineIsBlank(buf, insertPos, &parStart)
115 + || (insertPos == parStart
116 + && not_end == prevLineIsBlank(buf, parStart, &parStart))) {
117 + while (parStart > 0) {
118 + if (not_end != prevLineIsBlank(buf, parStart, &pos)) {
119 + break;
121 + parStart = pos;
124 - parStart = pos;
126 + while (parStart > 0) {
127 + if (not_end == prevLineIsBlank(buf, parStart, &pos)) {
128 + break;
130 + parStart = pos;
135 TextDSetInsertPosition(textD, parStart);
136 checkMoveSelectionChange(w, event, insertPos, args, nArgs);
137 checkAutoShowInsertPos(w);
138 diff --quilt old/doc/help.etx new/doc/help.etx
139 --- old/doc/help.etx
140 +++ new/doc/help.etx
141 @@ -3413,17 +3413,20 @@ Action Routines
142 is supplied.
144 **backward_character( ["nobell"] )**
145 Moves the cursor one character to the left.
147 -**backward_paragraph( ["end"] ["nobell"] )**
148 +**backward_paragraph( ["end" | "any"] ["nobell"] )**
149 Moves the cursor to the beginning of the paragraph, or
150 if the cursor is already at the beginning of a paragraph, moves the cursor to
151 the beginning of the previous paragraph. Paragraphs are defined as regions
152 of text delimited by one or more blank lines. If the "end" option is given
153 the cursor is moved to the end of previous paragraph. The end of a paragraph
154 - is the first blank line after the paragraph, if any.
155 + is the first blank line after the paragraph, if any. If the "any" option is
156 + given, which is mutual exclusive to the "end" option, the cursor is moved to
157 + either the previous beginning or to the previous end of a paragraph,
158 + whichever comes first.
160 **backward_word( ["tail"] ["nobell"] )**
161 Moves the cursor to the beginning of a word, or, if the
162 cursor is already at the beginning of a word, moves the cursor to the
163 beginning of the previous word. Word delimiters are user-settable, and
164 @@ -3540,17 +3543,19 @@ Action Routines
165 negative-index (numbers less than 0, -1 is the same as "last").
167 **forward_character()**
168 Moves the cursor one character to the right.
170 -**forward_paragraph( ["end"] ["nobell"] )**
171 +**forward_paragraph( ["end" | "any"] ["nobell"] )**
172 Moves the cursor to the beginning of the next paragraph.
173 Paragraphs are defined as regions of text delimited by one or more blank
174 lines. If the "end" optione is given, the cursor is moved to the end of the
175 current paragraph, or to the end of the next paragraph if the current line
176 is a blank line. The end of a paragraph is the first blank line after the
177 - paragraph, if any.
178 + paragraph, if any. If the "any" option is given, which is mutual exclusive to
179 + the "end" option, the cursor is moved to either the next beginning or to the
180 + next end of a paragraph, whichever comes first.
182 **forward_word( ["tail"] ["nobell"] )**
183 Moves the cursor to the beginning of the next word. Word
184 delimiters are user-settable, and defined by the X resource wordDelimiters.
185 If the "tail" argument is supplied the cursor will be moved to