commit eccd7fac9e33189b8872f0b6b915d7555a99ca79
parent d1b9cca73c954702efcfdcbcfaff8f2bc109cbfb
Author: bakkeby <bakkeby@gmail.com>
Date: Mon, 26 Jul 2021 10:16:54 +0200
Adding columns patch ref. #34
Diffstat:
4 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog:
+2021-07-26 - Added columns patch
+
2021-07-07 - Added sixel scrollback and the openurlonclick patch
2021-06-09 - Added the hide terminal cursor patch
@@ -102,6 +104,10 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- by default st only sets PRIMARY on selection
- this patch makes st set CLIPBOARD on selection
+ - [columns](https://github.com/bakkeby/st-flexipatch/issues/34)
+ - allows st to be resized without cutting off text when the terminal window is made larger again
+ - text does not wrap when the terminal window is made smaller
+
- [copyurl](https://st.suckless.org/patches/copyurl/)
- this patch allows you to select and copy the last URL displayed with Mod+l
- multiple invocations cycle through the available URLs
diff --git a/patches.def.h b/patches.def.h
@@ -68,6 +68,15 @@
*/
#define CLIPBOARD_PATCH 0
+/* This patch allows st to be resized without cutting off text when the terminal window is
+ * made larger again. Text does not wrap when the terminal window is made smaller.
+ *
+ * The vim browse patch takes precedence over this patch.
+ *
+ * https://github.com/bakkeby/st-flexipatch/issues/34
+ */
+#define COLUMNS_PATCH 0
+
/* Select and copy the last URL displayed with Mod+l. Multiple invocations cycle through the
* available URLs.
* https://st.suckless.org/patches/copyurl/
diff --git a/st.c b/st.c
@@ -1654,6 +1654,9 @@ tclearregion(int x1, int y1, int x2, int y2)
#if VIM_BROWSE_PATCH
LIMIT(x1, 0, buffCols-1);
LIMIT(x2, 0, buffCols-1);
+ #elif COLUMNS_PATCH
+ LIMIT(x1, 0, term.maxcol-1);
+ LIMIT(x2, 0, term.maxcol-1);
#else
LIMIT(x1, 0, term.col-1);
LIMIT(x2, 0, term.col-1);
@@ -3165,6 +3168,15 @@ tresize(int col, int row)
col = MAX(col, buffCols);
row = MIN(row, buffSize);
int const minrow = MIN(row, term.row), mincol = MIN(col, buffCols);
+ #elif COLUMNS_PATCH
+ int tmp = col;
+ int minrow, mincol;
+
+ if (!term.maxcol)
+ term.maxcol = term.col;
+ col = MAX(col, term.maxcol);
+ minrow = MIN(row, term.row);
+ mincol = MIN(col, term.maxcol);
#else
int minrow = MIN(row, term.row);
int mincol = MIN(col, term.col);
@@ -3251,6 +3263,8 @@ tresize(int col, int row)
}
#if VIM_BROWSE_PATCH
if (col > buffCols)
+ #elif COLUMNS_PATCH
+ if (col > term.maxcol)
#else
if (col > term.col)
#endif // VIM_BROWSE_PATCH
@@ -3258,6 +3272,9 @@ tresize(int col, int row)
#if VIM_BROWSE_PATCH
bp = term.tabs + buffCols;
memset(bp, 0, sizeof(*term.tabs) * (col - buffCols));
+ #elif COLUMNS_PATCH
+ bp = term.tabs + term.maxcol;
+ memset(bp, 0, sizeof(*term.tabs) * (col - term.maxcol));
#else
bp = term.tabs + term.col;
memset(bp, 0, sizeof(*term.tabs) * (col - term.col));
@@ -3282,6 +3299,9 @@ tresize(int col, int row)
#if VIM_BROWSE_PATCH
term.col = colSet;
buffCols = col;
+ #elif COLUMNS_PATCH
+ term.col = tmp;
+ term.maxcol = col;
#else
term.col = col;
#endif // VIM_BROWSE_PATCH
diff --git a/st.h b/st.h
@@ -140,6 +140,9 @@ typedef struct {
typedef struct {
int row; /* nb row */
int col; /* nb col */
+ #if COLUMNS_PATCH && !VIM_BROWSE_PATCH
+ int maxcol;
+ #endif // COLUMNS_PATCH
Line *line; /* screen */
Line *alt; /* alternate screen */
#if SCROLLBACK_PATCH