ajbj patch round-up
[nedit-bw.git] / extended-paragraph-any.patch
blob9f2c8b553bc64af471eef81c030f1fb26a9af107
1 Subject: "any" option for paragraph jumping
3 With the "any" option paragraph jumping stops on start and end of paragraph.
6 ---
8 doc/help.etx | 13 ++++++----
9 source/text.c | 75 ++++++++++++++++++++++++++++++++++++++++++++--------------
10 2 files changed, 67 insertions(+), 21 deletions(-)
12 diff --quilt old/source/text.c new/source/text.c
13 --- old/source/text.c
14 +++ new/source/text.c
15 @@ -2772,33 +2772,52 @@ static void forwardParagraphAP(Widget w,
16 textDisp *textD = ((TextWidget)w)->text.textD;
17 int pos, insertPos = TextDGetInsertPosition(textD);
18 textBuffer *buf = textD->buffer;
19 int silent = hasKey("nobell", args, nArgs);
20 int not_end = !hasKey("end", args, nArgs);
21 + int any = hasKey("any", args, nArgs);
23 cancelDrag(w);
25 + /* "end" and "any" are mutual exclusive */
26 + if (any && !not_end) {
27 + return;
28 + }
30 /* check if we are at the end of the file, than return */
31 if (insertPos == buf->length) {
32 ringIfNecessary(silent, w);
33 return;
36 - /* need to skip current paragraph? */
37 - if (not_end != lineIsBlank(buf, insertPos, &pos)) {
38 + if (any) {
39 + int stop = !lineIsBlank(buf, insertPos, &pos);
41 while (pos < buf->length) {
42 - if (not_end == nextLineIsBlank(buf, pos, &pos)) {
43 + if (stop == nextLineIsBlank(buf, pos, &pos)) {
44 break;
47 - }
49 - /* skip all blank lines */
50 - while (pos < buf->length) {
51 - if (not_end != nextLineIsBlank(buf, pos, &pos)) {
52 - break;
53 + } else {
55 + /* need to skip current paragraph? */
56 + if (not_end != lineIsBlank(buf, insertPos, &pos)) {
57 + while (pos < buf->length) {
58 + if (not_end == nextLineIsBlank(buf, pos, &pos)) {
59 + break;
60 + }
61 + }
64 + /* skip all blank lines */
65 + while (pos < buf->length) {
66 + if (not_end != nextLineIsBlank(buf, pos, &pos)) {
67 + break;
68 + }
69 + }
73 TextDSetInsertPosition(textD, min(pos, buf->length));
74 checkMoveSelectionChange(w, event, insertPos, args, nArgs);
75 checkAutoShowInsertPos(w);
76 @@ -2811,35 +2830,57 @@ static void backwardParagraphAP(Widget w
77 textDisp *textD = ((TextWidget)w)->text.textD;
78 int parStart, pos, insertPos = TextDGetInsertPosition(textD);
79 textBuffer *buf = textD->buffer;
80 int silent = hasKey("nobell", args, nArgs);
81 int not_end = !hasKey("end", args, nArgs);
82 + int any = hasKey("any", args, nArgs);
84 cancelDrag(w);
86 + /* "end" and "any" are mutual exclusive */
87 + if (any && !not_end) {
88 + return;
89 + }
91 /* check if we are at the beginning of the file, than return */
92 if (0 == insertPos) {
93 ringIfNecessary(silent, w);
94 return;
97 - if (not_end == lineIsBlank(buf, insertPos, &parStart)
98 - || (insertPos == parStart
99 - && not_end == prevLineIsBlank(buf, parStart, &parStart))) {
100 + if (any) {
101 + int stop = lineIsBlank(buf, insertPos, &parStart)
102 + || !(insertPos == parStart
103 + && prevLineIsBlank(buf, parStart, &parStart));
105 while (parStart > 0) {
106 - if (not_end != prevLineIsBlank(buf, parStart, &pos)) {
107 + if (stop == prevLineIsBlank(buf, parStart, &pos)) {
108 break;
110 parStart = pos;
114 - while (parStart > 0) {
115 - if (not_end == prevLineIsBlank(buf, parStart, &pos)) {
116 - break;
117 + } else {
119 + if (not_end == lineIsBlank(buf, insertPos, &parStart)
120 + || (insertPos == parStart
121 + && not_end == prevLineIsBlank(buf, parStart, &parStart))) {
122 + while (parStart > 0) {
123 + if (not_end != prevLineIsBlank(buf, parStart, &pos)) {
124 + break;
126 + parStart = pos;
129 - parStart = pos;
131 + while (parStart > 0) {
132 + if (not_end == prevLineIsBlank(buf, parStart, &pos)) {
133 + break;
135 + parStart = pos;
140 TextDSetInsertPosition(textD, parStart);
141 checkMoveSelectionChange(w, event, insertPos, args, nArgs);
142 checkAutoShowInsertPos(w);
143 diff --quilt old/doc/help.etx new/doc/help.etx
144 --- old/doc/help.etx
145 +++ new/doc/help.etx
146 @@ -3304,17 +3304,20 @@ Action Routines
147 is supplied.
149 **backward_character( ["nobell"] )**
150 Moves the cursor one character to the left.
152 -**backward_paragraph( ["end"] ["nobell"] )**
153 +**backward_paragraph( ["end" | "any"] ["nobell"] )**
154 Moves the cursor to the beginning of the paragraph, or
155 if the cursor is already at the beginning of a paragraph, moves the cursor to
156 the beginning of the previous paragraph. Paragraphs are defined as regions
157 of text delimited by one or more blank lines. If the "end" option is given
158 the cursor is moved to the end of previous paragraph. The end of a paragraph
159 - is the first blank line after the paragraph, if any.
160 + is the first blank line after the paragraph, if any. If the "any" option is
161 + given, which is mutual exclusive to the "end" option, the cursor is moved to
162 + either the previous beginning or to the previous end of a paragraph,
163 + whichever comes first.
165 **backward_word( ["tail"] ["nobell"] )**
166 Moves the cursor to the beginning of a word, or, if the
167 cursor is already at the beginning of a word, moves the cursor to the
168 beginning of the previous word. Word delimiters are user-settable, and
169 @@ -3431,17 +3434,19 @@ Action Routines
170 negative-index (numbers less than 0, -1 is the same as "last").
172 **forward_character()**
173 Moves the cursor one character to the right.
175 -**forward_paragraph( ["end"] ["nobell"] )**
176 +**forward_paragraph( ["end" | "any"] ["nobell"] )**
177 Moves the cursor to the beginning of the next paragraph.
178 Paragraphs are defined as regions of text delimited by one or more blank
179 lines. If the "end" optione is given, the cursor is moved to the end of the
180 current paragraph, or to the end of the next paragraph if the current line
181 is a blank line. The end of a paragraph is the first blank line after the
182 - paragraph, if any.
183 + paragraph, if any. If the "any" option is given, which is mutual exclusive to
184 + the "end" option, the cursor is moved to either the next beginning or to the
185 + next end of a paragraph, whichever comes first.
187 **forward_word( ["tail"] ["nobell"] )**
188 Moves the cursor to the beginning of the next word. Word
189 delimiters are user-settable, and defined by the X resource wordDelimiters.
190 If the "tail" argument is supplied the cursor will be moved to