Adding columns patch ref. #34

This commit is contained in:
bakkeby 2021-07-26 10:16:54 +02:00
parent d1b9cca73c
commit eccd7fac9e
4 changed files with 38 additions and 0 deletions

View File

@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog: ### Changelog:
2021-07-26 - Added columns patch
2021-07-07 - Added sixel scrollback and the openurlonclick patch 2021-07-07 - Added sixel scrollback and the openurlonclick patch
2021-06-09 - Added the hide terminal cursor 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 - by default st only sets PRIMARY on selection
- this patch makes st set CLIPBOARD 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/) - [copyurl](https://st.suckless.org/patches/copyurl/)
- this patch allows you to select and copy the last URL displayed with Mod+l - this patch allows you to select and copy the last URL displayed with Mod+l
- multiple invocations cycle through the available URLs - multiple invocations cycle through the available URLs

View File

@ -68,6 +68,15 @@
*/ */
#define CLIPBOARD_PATCH 0 #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 /* Select and copy the last URL displayed with Mod+l. Multiple invocations cycle through the
* available URLs. * available URLs.
* https://st.suckless.org/patches/copyurl/ * https://st.suckless.org/patches/copyurl/

20
st.c
View File

@ -1654,6 +1654,9 @@ tclearregion(int x1, int y1, int x2, int y2)
#if VIM_BROWSE_PATCH #if VIM_BROWSE_PATCH
LIMIT(x1, 0, buffCols-1); LIMIT(x1, 0, buffCols-1);
LIMIT(x2, 0, buffCols-1); LIMIT(x2, 0, buffCols-1);
#elif COLUMNS_PATCH
LIMIT(x1, 0, term.maxcol-1);
LIMIT(x2, 0, term.maxcol-1);
#else #else
LIMIT(x1, 0, term.col-1); LIMIT(x1, 0, term.col-1);
LIMIT(x2, 0, term.col-1); LIMIT(x2, 0, term.col-1);
@ -3165,6 +3168,15 @@ tresize(int col, int row)
col = MAX(col, buffCols); col = MAX(col, buffCols);
row = MIN(row, buffSize); row = MIN(row, buffSize);
int const minrow = MIN(row, term.row), mincol = MIN(col, buffCols); 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 #else
int minrow = MIN(row, term.row); int minrow = MIN(row, term.row);
int mincol = MIN(col, term.col); int mincol = MIN(col, term.col);
@ -3251,6 +3263,8 @@ tresize(int col, int row)
} }
#if VIM_BROWSE_PATCH #if VIM_BROWSE_PATCH
if (col > buffCols) if (col > buffCols)
#elif COLUMNS_PATCH
if (col > term.maxcol)
#else #else
if (col > term.col) if (col > term.col)
#endif // VIM_BROWSE_PATCH #endif // VIM_BROWSE_PATCH
@ -3258,6 +3272,9 @@ tresize(int col, int row)
#if VIM_BROWSE_PATCH #if VIM_BROWSE_PATCH
bp = term.tabs + buffCols; bp = term.tabs + buffCols;
memset(bp, 0, sizeof(*term.tabs) * (col - 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 #else
bp = term.tabs + term.col; bp = term.tabs + term.col;
memset(bp, 0, sizeof(*term.tabs) * (col - term.col)); memset(bp, 0, sizeof(*term.tabs) * (col - term.col));
@ -3282,6 +3299,9 @@ tresize(int col, int row)
#if VIM_BROWSE_PATCH #if VIM_BROWSE_PATCH
term.col = colSet; term.col = colSet;
buffCols = col; buffCols = col;
#elif COLUMNS_PATCH
term.col = tmp;
term.maxcol = col;
#else #else
term.col = col; term.col = col;
#endif // VIM_BROWSE_PATCH #endif // VIM_BROWSE_PATCH

3
st.h
View File

@ -140,6 +140,9 @@ typedef struct {
typedef struct { typedef struct {
int row; /* nb row */ int row; /* nb row */
int col; /* nb col */ int col; /* nb col */
#if COLUMNS_PATCH && !VIM_BROWSE_PATCH
int maxcol;
#endif // COLUMNS_PATCH
Line *line; /* screen */ Line *line; /* screen */
Line *alt; /* alternate screen */ Line *alt; /* alternate screen */
#if SCROLLBACK_PATCH #if SCROLLBACK_PATCH