чување fee9d1f648559c750ef5ac8f5813acc4b0d9e783
родитељ f7fe0ff854280d9812760e1675e19eb5140ef49b
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Sat, 14 Oct 2023 21:49:32 +0200
sled.c(get_selection): Fix case when sel_start.col < sel_end.col and
sel_start.row > sel_end.row
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
| M | sled.c | | | 43 | +++++++++++++++++++++++++++++-------------- |
измењених датотека: 1, додавања: 29(+), брисања: 14(-)
diff --git a/sled.c b/sled.c
@@ -219,27 +219,38 @@ void
get_selection(int* ssr, int* ssc, int* ser, int* sec,
const struct DrawState* state)
{
- if (state->sel_start.col <= state->sel_end.col)
+ if (state->sel_start.row == state->sel_end.row)
{
- if (ssc)
- *ssc = state->sel_start.col;
- if (sec)
- *sec = state->sel_end.col;
- }
- else /* Swap */
- {
- if (ssc)
- *ssc = state->sel_end.col;
- if (sec)
- *sec = state->sel_start.col;
- }
+ if (state->sel_start.col <= state->sel_end.col)
+ {
+ if (ssc)
+ *ssc = state->sel_start.col;
+ if (sec)
+ *sec = state->sel_end.col;
+ }
+ else /* Swap */
+ {
+ if (ssc)
+ *ssc = state->sel_end.col;
+ if (sec)
+ *sec = state->sel_start.col;
+ }
- if (state->sel_start.row <= state->sel_end.row)
+ if (ssr)
+ *ssr = state->sel_start.row;
+ if (ser)
+ *ser = state->sel_end.row;
+ }
+ else if (state->sel_start.row < state->sel_end.row)
{
if (ssr)
*ssr = state->sel_start.row;
if (ser)
*ser = state->sel_end.row;
+ if (ssc)
+ *ssc = state->sel_start.col;
+ if (sec)
+ *sec = state->sel_end.col;
}
else /* Swap */
{
@@ -247,6 +258,10 @@ get_selection(int* ssr, int* ssc, int* ser, int* sec,
*ssr = state->sel_end.row;
if (ser)
*ser = state->sel_start.row;
+ if (ssc)
+ *ssc = state->sel_end.col;
+ if (sec)
+ *sec = state->sel_start.col;
}
}