Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where's the column_patch? #18

Closed
siduck opened this issue Jun 10, 2021 · 15 comments
Closed

Where's the column_patch? #18

siduck opened this issue Jun 10, 2021 · 15 comments

Comments

@siduck
Copy link

siduck commented Jun 10, 2021

I didnt find the column_patch in the releases or your st repo

@siduck siduck changed the title Where's the column patch? Where's the column_patch? Jun 10, 2021
@juliusHuelsmann
Copy link
Owner

Hi! :)
I don't release that patch separately, you can extract it by cloning this repo and executing

./release.sh 1 1

which generates all patches (including the column patch) from the current state of the repo.

Note:

  • Note that this patch is based on my history implementation.
  • Please be aware that a SEGFAULT might occur in your st when you apply the column patch, I'll have to sort that one out sometimes later (Issue column patch #16). For me this issue is not a big deal, because since using my st setup for a year st only crashed on me twice, but things might be different if you are on a more sophisticated tiling WM than I am operating on which supports manually resizing windows.

There is also a patch which does what you'ld like to achive without the history patch pre-applied which I released, but it has got the same issue (discussed here, patch linked in the ticket).

I hope that helps!

@siduck
Copy link
Author

siduck commented Jun 10, 2021

@juliusHuelsmann Does column_patch remove the functionality of mouse scroll? Ive tried vim-browse , it was great but I needed the mouse scroll support somehow :(

Also whats the difference between these two?

image

All I want is text not being cut when I resize my terminal :

simplescreenrecorder-2021-06-10_17.56.15.mp4

@juliusHuelsmann
Copy link
Owner

Scrolling via mouse
Sorry, the mouse scroll functionality is only available with the scrollback patch, vim browse and the column patch use the history patch which is a part of this repo which does not support scrolling via mouse. If you've worked with C you could port the mouse scroll scrollback patch to this history patch, but I think this would only be worth the effort if you plan to use both vim patch and scrolling via mouse.

Difference between patches

What is the difference [..]

The first one is the column patch, the second one only the history patch built to be applied on top of commit 43a3..

What you should apply for your use-case
I think then what you want is to apply the patch I release here.
However, note the following things:

  1. The snipplet I linked above was only ment for show-casing how one would implement this feature.
  2. Note that this patch might cause trouble because the terminal might crash as reported here. The person who reported this also mentioned that they have a fix for it in their repo, maybe it'ld be worth checking that out (link in the issue).

I'll have a look at the cause of the error sometimes this year, but I don't know when (It's likely not too hard to track down, but I'm currently rather busy). If you want I can notify you once I fixed that, I'll just keep this issue open then

@siduck
Copy link
Author

siduck commented Jun 10, 2021

Oh idk C and I have the scrollback patch already applied but it doesnt function at all once I patch vim-browse patch :((

@juliusHuelsmann
Copy link
Owner

juliusHuelsmann commented Jun 10, 2021

Ok looking at the patch again I think I mid've found the root of the bug, maybe this works, didn't test though and I'm currently unsure what the semantics were for clearing the region (meaning of var pmc). If you try this out please come back and say if it is buggy or not, I'll have a look at this later either way.

From d07e686a604eba95f8ef84f2efce946427771f67 Mon Sep 17 00:00:00 2001
From: Julius Huelsmann <juliusHuelsmann@gmail.com>
Date: Thu, 24 Dec 2020 00:34:38 +0100
Subject: [PATCH] feat: create column patch equivalent for unpatched st

Equivalent to history-column patch in https://github.com/juliusHuelsmann/st-history-vim only without ability to inspect if terminal size is smaller.
---
 st.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/st.c b/st.c
index abbbe4b..11c768e 100644
--- a/st.c
+++ b/st.c
@@ -113,6 +113,7 @@ typedef struct {
 typedef struct {
 	int row;      /* nb row */
 	int col;      /* nb col */
+	int maxCol;
 	Line *line;   /* screen */
 	Line *alt;    /* alternate screen */
 	int *dirty;   /* dirtyness of lines */
@@ -1236,6 +1237,7 @@ tclearregion(int x1, int y1, int x2, int y2)
 	LIMIT(x2, 0, term.col-1);
 	LIMIT(y1, 0, term.row-1);
 	LIMIT(y2, 0, term.row-1);
+	if (!(term.mode &= MODE_ALTSCREEN) && x2 == term.col - 1) { x2 = term.maxCol -1; }
 
 	for (y = y1; y <= y2; y++) {
 		term.dirty[y] = 1;
@@ -2472,9 +2474,10 @@ twrite(const char *buf, int buflen, int show_ctrl)
 void
 tresize(int col, int row)
 {
-	int i;
+	int i;
+	int pmc = term.maxCol;
 	int minrow = MIN(row, term.row);
 	int mincol = MIN(col, term.col);
+	term.maxCol = MAX(col, pmc);
 	int *bp;
 	TCursor c;
 
@@ -2511,14 +2514,14 @@ tresize(int col, int row)
 
 	/* resize each row to new width, zero-pad if needed */
 	for (i = 0; i < minrow; i++) {
-		term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph));
-		term.alt[i]  = xrealloc(term.alt[i],  col * sizeof(Glyph));
+		term.line[i] = xrealloc(term.line[i], term.maxCol * sizeof(Glyph));
+		term.alt[i]  = xrealloc(term.alt[i],  term.maxCol * sizeof(Glyph));
 	}
 
 	/* allocate any new rows */
 	for (/* i = minrow */; i < row; i++) {
-		term.line[i] = xmalloc(col * sizeof(Glyph));
-		term.alt[i] = xmalloc(col * sizeof(Glyph));
+		term.line[i] = xmalloc(term.maxCol * sizeof(Glyph));
+		term.alt[i] = xmalloc(term.maxCol * sizeof(Glyph));
 	}
 	if (col > term.col) {
 		bp = term.tabs + term.col;
@@ -2540,7 +2543,7 @@ tresize(int col, int row)
 	c = term.c;
 	for (i = 0; i < 2; i++) {
 		if (mincol < col && 0 < minrow) {
-			tclearregion(mincol, 0, col - 1, minrow - 1);
+			tclearregion(pmc, 0, col - 1, minrow - 1);
 		}
 		if (0 < col && minrow < row) {
 			tclearregion(0, minrow, col - 1, row - 1);
-- 
2.29.2

@siduck
Copy link
Author

siduck commented Jun 10, 2021

This patch doesnt depend on other patches right?

@juliusHuelsmann
Copy link
Owner

Oh , I have the scrollback patch already applied but it doesnt function at all once I patch vim-browse patch :((

No sorry, the vim-browse patch is not compatible with the scrollback patch

@juliusHuelsmann
Copy link
Owner

This patch doesnt depend on other patches right?

Right, this shouldn't depend on other patches, however I created it on an old revision of st, there might therefore be some merge conflicts

@siduck
Copy link
Author

siduck commented Jun 10, 2021

Oh , I have the scrollback patch already applied but it doesnt function at all once I patch vim-browse patch :((

No sorry, the vim-browse patch is not compatible with the scrollback patch

Is column_patch compatible with scrollback ? I get this error while patching :

image

@juliusHuelsmann
Copy link
Owner

juliusHuelsmann commented Jun 10, 2021

Hi! Hope this helps:
put it on this branch but unsure if this version is bugfree (as mentioned above)

git pull
git checkout test-persistent-col
make clean && make
./st # < try if it works
git diff fa253f0 > diff
# wherever you'ld like to apply it: patch -p1 < [path-to-diff]/diff 

Is column_patch compatible with scrollback ? I get this error while patching

The column-patch is not compatible with scrollback.
However, the patch on the branch above is. Note that it might be buggy, it might also work fine, but I recommend to test it first

@siduck
Copy link
Author

siduck commented Jun 10, 2021

@juliusHuelsmann this works but all glyphs like icons look very weird and st force exits itself frequently
image

@juliusHuelsmann
Copy link
Owner

ok sorry then there is still something wrong with that patch, I'll notify you in this issue when there is an update!

@siduck
Copy link
Author

siduck commented Jun 10, 2021

no worries! I will try these diffs from here and try patching it.
image

@siduck
Copy link
Author

siduck commented Jun 10, 2021

I patched it now , it works but

  • whenever I open the terminal and try "scroll forward" first, the terminal force exits itself (segmentation fault)
  • but if I try "scroll backward" + "scroll forward" then the terminal doesnt exit itself

changes made

If you want to test this build

git clone https://github.com/siduck76/st --branch test

@juliusHuelsmann
Copy link
Owner

juliusHuelsmann commented Jun 10, 2021

cool :) that looks good I'll have a look at the segfault that when I find the time :) And I'll keep the issue open for those who are interested!

I think the segfault might be because some areas are uninitialized and interpreted incorrectly, but thats just a hunch

@siduck siduck closed this as completed Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants