summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2022-12-05 23:18:14 +0100
committerpgen <p.gen.progs@gmail.com>2022-12-05 23:18:14 +0100
commitef36fd89d89f1a5abd9e055dc4a0613924c9d539 (patch)
tree6a6df98d59566942aa15c9d94c942bb13a85eddf
parent7520d25695db34e967278bbfb134058a9fec3317 (diff)
Make multiple taggings more compliant with pinning
-rw-r--r--smenu.110
-rw-r--r--smenu.c51
2 files changed, 55 insertions, 6 deletions
diff --git a/smenu.1 b/smenu.1
index 99d8838..0187b84 100644
--- a/smenu.1
+++ b/smenu.1
@@ -540,10 +540,12 @@ Tags or pins the word under the cursor.
Untags or unpins the word under the cursor.
.TP
\fBc\fP
-Tags or pins all the selectable words in the current \fBcolumn\fP.
+Tags or pins all the selectable words in the current \fBcolumn\fP when
+no word is marked, otherwise acts like \fBC\fP.
.TP
\fBr\fP
-Tags or pins all the selectable words in the current \fBrow/line\fP.
+Tags or pins all the selectable words in the current \fBrow/line\fP
+when no word is marked, otherwise acts like \fBR\fP.
.TP
\fBm\fP
Marks the current word, the cursor aspect will change until the word
@@ -581,6 +583,10 @@ If a word is already marked, \fBR\fP tags/pins the words between the
current and the marked words if they are the \fBsame row/line\fP.
.br
The marked word will no longer be marked after tagging is complete.
+.PP
+Note when you use \fBT\fP, \fBc\fP/\fBC\fP or \fPr\fP/\fBR\fP with
+pinning enabled, the order of word selection depends on whether the
+marked word is before or after the current word.
.TP
\fBU\fP
Untags or unpins the last tagging action.
diff --git a/smenu.c b/smenu.c
index 11a2640..d9b6b11 100644
--- a/smenu.c
+++ b/smenu.c
@@ -11798,7 +11798,8 @@ main(int argc, char * argv[])
{
long col, cur_col, marked_col;
long first, last;
- int tagged;
+
+ int tagged;
if (!win.col_mode)
break;
@@ -11836,6 +11837,12 @@ main(int argc, char * argv[])
{
first = first_word_in_line_a[line_nb_of_word_a[current]];
last = marked;
+
+ /* Pre-increment tag_nb with is maximum mulue as */
+ /* it will be decremented in the following loop when */
+ /* marked > current */
+ /* ''''''''''''''''''''''''''''''''''''''''''''''''' */
+ tag_nb += marked - current + 1;
}
}
else
@@ -11857,7 +11864,12 @@ main(int argc, char * argv[])
tagged_words++;
if (toggles.pinable)
- word_a[wi].tag_order = tag_nb++;
+ {
+ if (marked <= current)
+ word_a[wi].tag_order = tag_nb++;
+ else
+ word_a[wi].tag_order = tag_nb--;
+ }
tagged = 1;
}
@@ -11871,6 +11883,9 @@ main(int argc, char * argv[])
if (tagged)
win.next_tag_id++;
+ if (marked > current)
+ tag_nb += marked - current + 1;
+
marked = -1;
nl = disp_lines(&win, &toggles, current, count, search_mode,
@@ -11934,6 +11949,12 @@ main(int argc, char * argv[])
{
first = current;
last = marked;
+
+ /* Pre-increment tag_nb with is maximum mulue as */
+ /* it will be decremented in the following loop when */
+ /* marked > current */
+ /* ''''''''''''''''''''''''''''''''''''''''''''''''' */
+ tag_nb += marked - current + 1;
}
}
else
@@ -11964,7 +11985,12 @@ main(int argc, char * argv[])
tagged_words++;
if (toggles.pinable)
- word_a[wi].tag_order = tag_nb++;
+ {
+ if (marked <= current)
+ word_a[wi].tag_order = tag_nb++;
+ else
+ word_a[wi].tag_order = tag_nb--;
+ }
tagged = 1;
}
@@ -11975,6 +12001,9 @@ main(int argc, char * argv[])
if (tagged)
win.next_tag_id++;
+ if (marked > current)
+ tag_nb += marked - current + 1;
+
marked = -1;
nl = disp_lines(&win, &toggles, current, count, search_mode,
@@ -12098,6 +12127,12 @@ main(int argc, char * argv[])
{
first = current;
last = marked;
+
+ /* Pre-increment tag_nb with is maximum mulue as */
+ /* it will be decremented in the following loop when */
+ /* marked > current */
+ /* ''''''''''''''''''''''''''''''''''''''''''''''''' */
+ tag_nb += marked - current + 1;
}
tagged = 0;
@@ -12113,7 +12148,12 @@ main(int argc, char * argv[])
tagged_words++;
if (toggles.pinable)
- word_a[wi].tag_order = tag_nb++;
+ {
+ if (marked <= current)
+ word_a[wi].tag_order = tag_nb++;
+ else
+ word_a[wi].tag_order = tag_nb--;
+ }
tagged = 1;
}
@@ -12122,6 +12162,9 @@ main(int argc, char * argv[])
if (tagged)
win.next_tag_id++;
+ if (marked > current)
+ tag_nb += marked - current + 1;
+
marked = -1;
}
}