You need to reset the scroll region before you write line feeds or it'll
not scroll if the scroll region is set.
Also I don't like so much text, you can't get this without setting
remain-on-exit and what you can do with the pane after than can be found
by looking in the manpage.
How about just this?
Index: server-fn.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/server-fn.c,v
retrieving revision 1.50
diff -u -p -r1.50 server-fn.c
--- server-fn.c 23 Jan 2011 11:03:43 -0000 1.50
+++ server-fn.c 31 Aug 2011 07:12:01 -0000
@@ -329,16 +329,32 @@ server_unlink_window(struct session *s,
void
server_destroy_pane(struct window_pane *wp)
{
- struct window *w = wp->window;
+ struct window *w = wp->window;
+ int old_fd;
+ struct screen_write_ctx ctx;
+ struct grid_cell gc;
+ old_fd = wp->fd;
if (wp->fd != -1) {
close(wp->fd);
bufferevent_free(wp->event);
wp->fd = -1;
}
- if (options_get_number(&w->options, "remain-on-exit"))
+ if (options_get_number(&w->options, "remain-on-exit")) {
+ if (old_fd == -1)
+ return;
+ screen_write_start(&ctx, wp, &wp->base);
+ screen_write_scrollregion(&ctx, 0, screen_size_y(ctx.s) - 1);
+ screen_write_cursormove(&ctx, 0, screen_size_y(ctx.s) - 1);
+ screen_write_linefeed(&ctx, 1);
+ memcpy(&gc, &grid_default_cell, sizeof gc);
+ gc.attr |= GRID_ATTR_BRIGHT;
+ screen_write_puts(&ctx, &gc, "Pane is dead");
+ screen_write_stop(&ctx);
+ wp->flags |= PANE_REDRAW;
return;
+ }
layout_close_pane(wp);
window_remove_pane(w, wp);
On Tue, Aug 30, 2011 at 09:39:34PM -0700, Randy Stauner wrote:
> Sweet, thanks!
> I think it works to append lines to the end of the scroll buffer both for
> regular shells and for full-screen commands.
> ('split-window "info make"' is what I used for a full-screen example).
> What do you think about this patch (goes on top of yours):
> diff --git a/trunk/server-fn.c b/trunk/server-fn.c
> index 07c56ab..999f9ac 100644
> --- a/trunk/server-fn.c
> +++ b/trunk/server-fn.c
> @@ -345,13 +345,21 @@ server_destroy_pane(struct window_pane *wp)
> ** if (old_fd == -1)
> ** return;
> ** screen_write_start(&ctx, wp, &wp->base);
> + /* move to bottom */
> + screen_write_cursormove(&ctx, 0, screen_size_y(ctx.s) -
> 1);
> + /* draw blank lines below the last line on screen */
> + screen_write_linefeed(&ctx, 1);
> + screen_write_linefeed(&ctx, 1);
> + screen_write_linefeed(&ctx, 1);
> + /* scroll up to preserve last screen */
> ** screen_write_scrollregion(&ctx, 0, screen_size_y(ctx.s) -
> 1);
> - screen_write_cursormove(&ctx, 0, 0);
> - screen_write_insertline(&ctx, 2);
> - screen_write_cursormove(&ctx, 0, 0);
> + /* move to middle line to write message */
> + screen_write_cursormove(&ctx, 0, screen_size_y(ctx.s) -
> 2);
> ** memcpy(&gc, &grid_default_cell, sizeof gc);
> ** gc.attr |= GRID_ATTR_BRIGHT;
> - screen_write_nputs(&ctx, -1, &gc, 0, "Pane is dead");
> + screen_write_nputs(&ctx, -1, &gc, 0, "Pane is dead. **"
> + ** **"Use 'respawn-pane' to reactivate "
> + ** **"or 'kill-pane' to remove.");
> ** screen_write_stop(&ctx);
> ** wp->flags |= PANE_REDRAW;
> ** return;
> feel free to clean it up as necessary ;-)
> On Tue, Aug 30, 2011 at 8:38 AM, Nicholas Marriott
> <[1][email protected]> wrote:
>
> Move cursor to the very bottom (screen_size_y(s) - 1) and call
> screen_write_linefeed to scroll, it will move the top line into the
> history.
>
> On Tue, Aug 30, 2011 at 08:29:20AM -0700, Randy Stauner wrote:
> > ** **Ah, yes, those are good points.
> > ** **I did realize that I need to disconnect from tmux in order to
> stop the
> > ** **server... that's why my changes had no effect.
> > ** **I'm sure I've been bitten by that before.
> > ** **Perhaps I'll toy with it a little more.
> > ** **Is there a way to add lines to the bottom of the scroll buffer?
> > ** **I see that scrollregion and cursormove functions won't let you
> scroll past
> > ** **the last line (which makes sense)...
> > ** **so is there a way to add lines to what is in the scrollback
> buffer so that
> > ** **it could scroll farther
> > ** **(for example add 2 blank lines to the end so that i can scroll
> down past
> > ** **whatever was previously on the screen)?
> > ** **It would be great to not overwrite what's already on the screen.
> > ** **Commenting out the scrollregion and cursormove commands makes it
> write at
> > ** **the cursor position
> > ** **(which might be after (or in the middle of)) any command I had
> typed but
> > ** **not entered at the command prompt).
> > ** **This doesn't seem too bad to me, but does make it seem
> "unpolished" and
> > ** **I'm sure some wouldn't like it.
> > ** **On Tue, Aug 30, 2011 at 8:14 AM, Nicholas Marriott
> > ** **<[1][2][email protected]> wrote:
> >
> > ** ** **Putting it at the bottom is harder, because where is the
> bottom? If
> > ** ** **you're running a full screen program the bottom is the very
> bottom. But
> > ** ** **if you have a clear screen with just eg 1 shell prompt on then
> the
> > ** ** **bottom needs to be line 2 or so.
> >
> > ** ** **We can always put it at the very bottom of the screen but then
> if you
> > ** ** **only have a few lines on screen you will lose them.
> > ** ** **On Tue, Aug 30, 2011 at 08:01:08AM -0700, Randy Stauner wrote:
> > ** ** **> ** **-- (sorry, didn't mean to send this directly instead of
> to the
> > ** ** **list) --
> > ** ** **> ** **I don't use automatic rename in that session because of
> the large
> > ** ** **layout
> > ** ** **> ** **with many windows and ssh connections.
> > ** ** **> ** **This patch works nicely for me, thanks.
> > ** ** **> ** **While this does serve the purpose,
> > ** ** **> ** **I think it might be nicer/more intuitive to have the
> message at
> > ** ** **the bottom
> > ** ** **> ** **(since that is where you typically expect the next
> thing).
> > ** ** **> ** **The way that it scrolls backward confuses me a bit
> since i lose
> > ** ** **the last
> > ** ** **> ** **line or two from the last command output.
> > ** ** **> ** **Would it be difficult to print at the bottom instead of
> the top
> > ** ** **(without
> > ** ** **> ** **scrolling backward (scrolling forward would be ok))?
> > ** ** **> ** **I tried toying with it myself for a bit,**but when
> changing the
> > ** ** **numbers
> > ** ** **> ** **passed to screen_write_scrollregion and
> screen_write_cursormove
> > ** ** **seemed to
> > ** ** **> ** **have no effect I accepted that I was far out of my
> element and I
> > ** ** **should
> > ** ** **> ** **defer to the master (plus I gotta get back to work).
> > ** ** **> ** **But thanks for the quick response thus far! **I will
> use this.
> > ** ** **>
> > ** ** **> ** **On Tue, Aug 30, 2011 at 2:55 AM, Nicholas Marriott
> > ** ** **> ** **<[1][2][3][email protected]> wrote:
> > ** ** **>
> > ** ** **> ** ** **In fact, try this:
> > ** ** **>
> > ** ** **> ** ** **Index: server-fn.c
> > ** ** **> ** **
> > ** **
> ****===================================================================
> > ** ** **> ** ** **RCS file: /cvs/src/usr.bin/tmux/server-fn.c,v
> > ** ** **> ** ** **retrieving revision 1.50
> > ** ** **> ** ** **diff -u -p -r1.50 server-fn.c
> > ** ** **> ** ** **--- server-fn.c 23 Jan 2011 11:03:43 -0000 ** **
> **1.50
> > ** ** **> ** ** **+++ server-fn.c 30 Aug 2011 09:54:49 -0000
> > ** ** **> ** ** **@@ -329,16 +329,33 @@ server_unlink_window(struct
> session *s,
> > ** ** **> ** ** ****void
> > ** ** **> ** ** ****server_destroy_pane(struct window_pane *wp)
> > ** ** **> ** ** ****{
> > ** ** **> ** ** **- ** ** ** struct window ** *w = wp->window;
> > ** ** **> ** ** **+ ** ** ** struct window ** ** ** ** ** *w =
> wp->window;
> > ** ** **> ** ** **+ ** ** ** int ** ** ** ** ** ** ** ** ** **
> **old_fd;
> > ** ** **> ** ** **+ ** ** ** struct screen_write_ctx **ctx;
> > ** ** **> ** ** **+ ** ** ** struct grid_cell ** ** ** ** gc;
> > ** ** **>
> > ** ** **> ** ** **+ ** ** ** old_fd = wp->fd;
> > ** ** **> ** ** **** ** ** **if (wp->fd != -1) {
> > ** ** **> ** ** **** ** ** ** ** ** ** **close(wp->fd);
> > ** ** **> ** ** **** ** ** ** ** ** ** **bufferevent_free(wp->event);
> > ** ** **> ** ** **** ** ** ** ** ** ** **wp->fd = -1;
> > ** ** **> ** ** **** ** ** **}
> > ** ** **>
> > ** ** **> ** ** **- ** ** ** if (options_get_number(&w->options,
> > ** ** **"remain-on-exit"))
> > ** ** **> ** ** **+ ** ** ** if (options_get_number(&w->options,
> > ** ** **"remain-on-exit")) {
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** if (old_fd == -1)
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** ** ** ** ** return;
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** screen_write_start(&ctx, wp,
> > ** ** **&wp->base);
> > ** ** **> ** ** **+ ** ** ** ** ** ** **
> screen_write_scrollregion(&ctx, 0,
> > ** ** **> ** ** **screen_size_y(ctx.s) - 1);
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** screen_write_cursormove(&ctx,
> 0, 0);
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** screen_write_insertline(&ctx,
> 2);
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** screen_write_cursormove(&ctx,
> 0, 0);
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** memcpy(&gc,
> &grid_default_cell, sizeof
> > ** ** **gc);
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** gc.attr |= GRID_ATTR_BRIGHT;
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** screen_write_nputs(&ctx, -1,
> &gc, 0,
> > ** ** **"Pane is
> > ** ** **> ** ** **dead");
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** screen_write_stop(&ctx);
> > ** ** **> ** ** **+ ** ** ** ** ** ** ** wp->flags |= PANE_REDRAW;
> > ** ** **> ** ** **** ** ** ** ** ** ** **return;
> > ** ** **> ** ** **+ ** ** ** }
> > ** ** **>
> > ** ** **> ** ** **** ** ** **layout_close_pane(wp);
> > ** ** **> ** ** **** ** ** **window_remove_pane(w, wp);
> > ** ** **>
> > ** ** **> ** ** **On Tue, Aug 30, 2011 at 10:22:46AM +0100, Nicholas
> Marriott
> > ** ** **wrote:
> > ** ** **> ** ** **> Hi
> > ** ** **> ** ** **>
> > ** ** **> ** ** **> If you have automatic rename on it will rename the
> window to
> > ** ** **add
> > ** ** **> ** ** **[dead]
> > ** ** **> ** ** **> but yes printing that in the pane wouldn't do any
> harm, I'll
> > ** ** **add it to
> > ** ** **> ** ** **> the todo list.
> > ** ** **> ** ** **>
> > ** ** **> ** ** **>
> > ** ** **> ** ** **> On Mon, Aug 29, 2011 at 10:15:12AM -0700, Randy
> Stauner
> > ** ** **wrote:
> > ** ** **> ** ** **> > ** **My ssh connection died and it looked to me
> like the
> > ** ** **process
> > ** ** **> ** ** **hung.
> > ** ** **> ** ** **> > ** **Turns out I had remain-on-exit set but I
> did that so
> > ** ** **long ago I
> > ** ** **> ** ** **forgot
> > ** ** **> ** ** **> > ** **about it.
> > ** ** **> ** ** **> > ** **It would be nice to have some sort of
> notification
> > ** ** **that this
> > ** ** **> ** ** **pane is dead
> > ** ** **> ** ** **> > ** **and you likely either want to kill it or
> respawn it.
> > ** ** **> ** ** **> > ** **A window flag might be nice, though a
> message in the
> > ** ** **pane would
> > ** ** **> ** ** **be a lot
> > ** ** **> ** ** **> > ** **more visible.
> > ** ** **> ** ** **> > ** **I try not to offend by comparing tmux to
> screen,
> > ** ** **> ** ** **> > ** **but screen used to show a message like
> "This window
> > ** ** **is dead,
> > ** ** **> ** ** **press 1 to
> > ** ** **> ** ** **> > ** **respawn or 0 to kill"
> > ** ** **> ** ** **> > ** **or something like that.
> > ** ** **> ** ** **> > ** **Thankfully I've been happily using tmux for
> so long i
> > ** ** **don't
> > ** ** **> ** ** **remember
> > ** ** **> ** ** **> > ** **exactly how screen used to do it.
> > ** ** **> ** ** **> > ** **I tried looking at a few of the .c files
> but I wasn't
> > ** ** **really
> > ** ** **> ** ** **sure where to
> > ** ** **> ** ** **> > ** **begin trying to put something like that,
> > ** ** **> ** ** **> > ** **so I thought I'd just mention it as a
> feature
> > ** ** **request.
> > ** ** **> ** ** **> > ** **I think a nice message at the end of the
> pane would
> > ** ** **be very
> > ** ** **> ** ** **helpful to
> > ** ** **> ** ** **> > ** **remind me why my terminal is now stuck.
> > ** ** **> ** ** **> > ** **The only reason i use remain-on-exit is to
> keep my
> > ** ** **window
> > ** ** **> ** ** **layout (numbers,
> > ** ** **> ** ** **> > ** **names, ssh connections, etc).
> > ** ** **> ** ** **> > ** **Now having taken the time to write this
> perhaps I'll
> > ** ** **remember
> > ** ** **> ** ** **next time i
> > ** ** **> ** ** **> > ** **see it.
> > ** ** **> ** ** **> > ** **Thanks for tmux, it sure is nice.
> > ** ** **> ** ** **> > ** **- Randy
> > ** ** **> ** ** **>
> > ** ** **> ** ** **> >
> > ** ** **> ** **
> > ** **
>
> ****------------------------------------------------------------------------------
> > ** ** **> ** ** **> > EMC VNX: the world's simplest storage, starting
> under $10K
> > ** ** **> ** ** **> > The only unified storage solution that offers
> unified
> > ** ** **management
> > ** ** **> ** ** **> > Up to 160% more powerful than alternatives and
> 25% more
> > ** ** **efficient.
> > ** ** **> ** ** **> > Guaranteed.
> [2][3][4]http://p.sf.net/sfu/emc-vnx-dev2dev
> > ** ** **> ** ** **>
> > ** ** **> ** ** **> > _______________________________________________
> > ** ** **> ** ** **> > tmux-users mailing list
> > ** ** **> ** ** **> > [3][4][5][email protected]
> > ** ** **> ** ** **> >
> > ** **
> **[4][5][6]https://lists.sourceforge.net/lists/listinfo/tmux-users
> > ** ** **> ** ** **>
> > ** ** **> ** ** **>
> > ** ** **> ** ** **>
> > ** ** **> ** **
> > ** **
>
> ****------------------------------------------------------------------------------
> > ** ** **> ** ** **> Special Offer -- Download ArcSight Logger for
> FREE!
> > ** ** **> ** ** **> Finally, a world-class log management solution at
> an even
> > ** ** **better
> > ** ** **> ** ** **> price-free! And you'll get a free "Love Thy Logs"
> t-shirt
> > ** ** **when you
> > ** ** **> ** ** **> download Logger. Secure your free ArcSight Logger
> TODAY!
> > ** ** **> ** ** **> [5][6][7]http://p.sf.net/sfu/arcsisghtdev2dev
> > ** ** **> ** ** **> _______________________________________________
> > ** ** **> ** ** **> tmux-users mailing list
> > ** ** **> ** ** **> [6][7][8][email protected]
> > ** ** **> ** ** **>
> > ** **
> **[7][8][9]https://lists.sourceforge.net/lists/listinfo/tmux-users
> > ** ** **>
> > ** ** **> References
> > ** ** **>
> > ** ** **> ** **Visible links
> > ** ** **> ** **1. mailto:[9][10][email protected]
> > ** ** **> ** **2. [10][11]http://p.sf.net/sfu/emc-vnx-dev2dev
> > ** ** **> ** **3. mailto:[11][12][email protected]
> > ** ** **> ** **4.
> [12][13]https://lists.sourceforge.net/lists/listinfo/tmux-users
> > ** ** **> ** **5. [13][14]http://p.sf.net/sfu/arcsisghtdev2dev
> > ** ** **> ** **6. mailto:[14][15][email protected]
> > ** ** **> ** **7.
> [15][16]https://lists.sourceforge.net/lists/listinfo/tmux-users
> > ** ** **>
> > ** **
>
> **------------------------------------------------------------------------------
> > ** ** **> Special Offer -- Download ArcSight Logger for FREE!
> > ** ** **> Finally, a world-class log management solution at an even
> better
> > ** ** **> price-free! And you'll get a free "Love Thy Logs" t-shirt
> when you
> > ** ** **> download Logger. Secure your free ArcSight Logger TODAY!
> > ** ** **> [16][17]http://p.sf.net/sfu/arcsisghtdev2dev
> >
> > ** ** **> _______________________________________________
> > ** ** **> tmux-users mailing list
> > ** ** **> [17][18][email protected]
> > ** ** **>
> [18][19]https://lists.sourceforge.net/lists/listinfo/tmux-users
> >
> > References
> >
> > ** **Visible links
> > ** **1. mailto:[20][email protected]
> > ** **2. mailto:[21][email protected]
> > ** **3. [22]http://p.sf.net/sfu/emc-vnx-dev2dev
> > ** **4. mailto:[23][email protected]
> > ** **5. [24]https://lists.sourceforge.net/lists/listinfo/tmux-users
> > ** **6. [25]http://p.sf.net/sfu/arcsisghtdev2dev
> > ** **7. mailto:[26][email protected]
> > ** **8. [27]https://lists.sourceforge.net/lists/listinfo/tmux-users
> > ** **9. mailto:[28][email protected]
> > ** 10. [29]http://p.sf.net/sfu/emc-vnx-dev2dev
> > ** 11. mailto:[30][email protected]
> > ** 12. [31]https://lists.sourceforge.net/lists/listinfo/tmux-users
> > ** 13. [32]http://p.sf.net/sfu/arcsisghtdev2dev
> > ** 14. mailto:[33][email protected]
> > ** 15. [34]https://lists.sourceforge.net/lists/listinfo/tmux-users
> > ** 16. [35]http://p.sf.net/sfu/arcsisghtdev2dev
> > ** 17. mailto:[36][email protected]
> > ** 18. [37]https://lists.sourceforge.net/lists/listinfo/tmux-users
>
> References
>
> Visible links
> 1. mailto:[email protected]
> 2. mailto:[email protected]
> 3. mailto:[email protected]
> 4. http://p.sf.net/sfu/emc-vnx-dev2dev
> 5. mailto:[email protected]
> 6. https://lists.sourceforge.net/lists/listinfo/tmux-users
> 7. http://p.sf.net/sfu/arcsisghtdev2dev
> 8. mailto:[email protected]
> 9. https://lists.sourceforge.net/lists/listinfo/tmux-users
> 10. mailto:[email protected]
> 11. http://p.sf.net/sfu/emc-vnx-dev2dev
> 12. mailto:[email protected]
> 13. https://lists.sourceforge.net/lists/listinfo/tmux-users
> 14. http://p.sf.net/sfu/arcsisghtdev2dev
> 15. mailto:[email protected]
> 16. https://lists.sourceforge.net/lists/listinfo/tmux-users
> 17. http://p.sf.net/sfu/arcsisghtdev2dev
> 18. mailto:[email protected]
> 19. https://lists.sourceforge.net/lists/listinfo/tmux-users
> 20. mailto:[email protected]
> 21. mailto:[email protected]
> 22. http://p.sf.net/sfu/emc-vnx-dev2dev
> 23. mailto:[email protected]
> 24. https://lists.sourceforge.net/lists/listinfo/tmux-users
> 25. http://p.sf.net/sfu/arcsisghtdev2dev
> 26. mailto:[email protected]
> 27. https://lists.sourceforge.net/lists/listinfo/tmux-users
> 28. mailto:[email protected]
> 29. http://p.sf.net/sfu/emc-vnx-dev2dev
> 30. mailto:[email protected]
> 31. https://lists.sourceforge.net/lists/listinfo/tmux-users
> 32. http://p.sf.net/sfu/arcsisghtdev2dev
> 33. mailto:[email protected]
> 34. https://lists.sourceforge.net/lists/listinfo/tmux-users
> 35. http://p.sf.net/sfu/arcsisghtdev2dev
> 36. mailto:[email protected]
> 37. https://lists.sourceforge.net/lists/listinfo/tmux-users
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
tmux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-users