Hi

Thanks for the diff,

It could be much smaller by doing:

        if (!options_get_number(&wp->window->options, "app-private-window"))
                break;

In both cases, instead of putting everything inside the if.

You also need to set a default value in tmux.c or tmux will die with a fatal
error the first time this code is hit, because the option isn't set.

I'm not sure about the option name, I think it should be something like
use-alternate-screen.

Can't you change your editor to use tabs instead of spaces or enter a literal
tab?


On Sun, Feb 07, 2010 at 10:15:12PM +0100, clemens fischer wrote:
> The patch adds a per-window option "app-private-window".  Tmux'
> behaviour doesn't change if it is set "on".  If set to "off", saving to
> tmux' alternate screen is disabled, no saving and restoring to a saved
> grid, and the history stays on.
> 
> As far as I know, this latter mode is compatible to "screen".  I did not
> find the spot where default values for options are defined.  Propably
> due to my using spaces instead of tabs, the patch is much bulkier than
> it needs to be, sorry about that.
> 
> 
> clemens
> 
> 
> Index: cmd-set-option.c
> ===================================================================
> --- cmd-set-option.c.orig
> +++ cmd-set-option.c
> @@ -138,6 +138,7 @@ const struct set_option_entry set_sessio
>  
>  const struct set_option_entry set_window_option_table[] = {
>       { "aggressive-resize", SET_OPTION_FLAG, 0, 0, NULL },
> +     { "app-private-window", SET_OPTION_FLAG, 0, 0, NULL },
>       { "automatic-rename", SET_OPTION_FLAG, 0, 0, NULL },
>       { "clock-mode-colour", SET_OPTION_COLOUR, 0, 0, NULL },
>       { "clock-mode-style",
> Index: input.c
> ===================================================================
> --- input.c.orig
> +++ input.c
> @@ -1178,27 +1178,29 @@ input_handle_sequence_sm(struct input_ct
>               case 1049:
>                       if (wp->saved_grid != NULL)
>                               break;
> -                     sx = screen_size_x(s);
> -                     sy = screen_size_y(s);
>  
>                       /*
>                        * Enter alternative screen mode. A copy of the visible
>                        * screen is saved and the history is not updated
>                        */
>  
> -                     wp->saved_grid = grid_create(sx, sy, 0);
> -                     grid_duplicate_lines(
> +            if (options_get_number(&wp->window->options, 
> "app-private-window")) {
> +                sx = screen_size_x(s);
> +                sy = screen_size_y(s);
> +                wp->saved_grid = grid_create(sx, sy, 0);
> +                grid_duplicate_lines(
>                           wp->saved_grid, 0, s->grid, screen_hsize(s), sy);
> -                     wp->saved_cx = s->cx;
> -                     wp->saved_cy = s->cy;
> -                     memcpy(&wp->saved_cell,
> -                         &ictx->cell, sizeof wp->saved_cell);
> +                wp->saved_cx = s->cx;
> +                wp->saved_cy = s->cy;
> +                memcpy(&wp->saved_cell,
> +                    &ictx->cell, sizeof wp->saved_cell);
>  
> -                     grid_view_clear(s->grid, 0, 0, sx, sy);
> +                grid_view_clear(s->grid, 0, 0, sx, sy);
>  
> -                     wp->base.grid->flags &= ~GRID_HISTORY;
> +                wp->base.grid->flags &= ~GRID_HISTORY;
>  
> -                     wp->flags |= PANE_REDRAW;
> +                wp->flags |= PANE_REDRAW;
> +            }
>                       break;
>               default:
>                       log_debug("unknown SM [%hhu]: %u", ictx->private, n);
> @@ -1254,44 +1256,46 @@ input_handle_sequence_rm(struct input_ct
>               case 1049:
>                       if (wp->saved_grid == NULL)
>                               break;
> -                     sx = screen_size_x(s);
> -                     sy = screen_size_y(s);
>  
>                       /*
>                        * Exit alternative screen mode and restore the copied
>                        * grid.
>                        */
>  
> -                     /*
> -                      * If the current size is bigger, temporarily resize
> -                      * to the old size before copying back.
> -                      */
> -                     if (sy > wp->saved_grid->sy)
> -                             screen_resize(s, sx, wp->saved_grid->sy);
> -
> -                     /* Restore the grid, cursor position and cell. */
> -                     grid_duplicate_lines(
> -                         s->grid, screen_hsize(s), wp->saved_grid, 0, sy);
> -                     s->cx = wp->saved_cx;
> -                     if (s->cx > screen_size_x(s) - 1)
> -                             s->cx = screen_size_x(s) - 1;
> -                     s->cy = wp->saved_cy;
> -                     if (s->cy > screen_size_y(s) - 1)
> -                             s->cy = screen_size_y(s) - 1;
> -                     memcpy(&ictx->cell, &wp->saved_cell, sizeof ictx->cell);
> -
> -                     /*
> -                      * Turn history back on (so resize can use it) and then
> -                      * resize back to the current size.
> -                      */
> -                     wp->base.grid->flags |= GRID_HISTORY;
> -                     if (sy > wp->saved_grid->sy)
> -                             screen_resize(s, sx, sy);
> +            if (options_get_number(&wp->window->options, 
> "app-private-window")) {
> +                sx = screen_size_x(s);
> +                sy = screen_size_y(s);
> +                /*
> +                * If the current size is bigger, temporarily resize
> +                * to the old size before copying back.
> +                */
> +                if (sy > wp->saved_grid->sy)
> +                    screen_resize(s, sx, wp->saved_grid->sy);
> +
> +                /* Restore the grid, cursor position and cell. */
> +                grid_duplicate_lines(
> +                    s->grid, screen_hsize(s), wp->saved_grid, 0, sy);
> +                s->cx = wp->saved_cx;
> +                if (s->cx > screen_size_x(s) - 1)
> +                    s->cx = screen_size_x(s) - 1;
> +                s->cy = wp->saved_cy;
> +                if (s->cy > screen_size_y(s) - 1)
> +                    s->cy = screen_size_y(s) - 1;
> +                memcpy(&ictx->cell, &wp->saved_cell, sizeof ictx->cell);
> +
> +                /*
> +                * Turn history back on (so resize can use it) and then
> +                * resize back to the current size.
> +                */
> +                wp->base.grid->flags |= GRID_HISTORY;
> +                if (sy > wp->saved_grid->sy)
> +                    screen_resize(s, sx, sy);
>  
> -                     grid_destroy(wp->saved_grid);
> -                     wp->saved_grid = NULL;
> +                grid_destroy(wp->saved_grid);
> +                wp->saved_grid = NULL;
>  
> -                     wp->flags |= PANE_REDRAW;
> +                wp->flags |= PANE_REDRAW;
> +            }
>                       break;
>               default:
>                       log_debug("unknown RM [%hhu]: %u", ictx->private, n);
> Index: tmux.1
> ===================================================================
> --- tmux.1.orig
> +++ tmux.1
> @@ -1795,6 +1795,16 @@ this option is good for full-screen prog
>  .Dv SIGWINCH
>  and poor for interactive programs such as shells.
>  .Pp
> +.It Xo Ic app-private-window
> +.Op Ic on | off
> +.Xc
> +Every application initializing its window can have it all to itself.
> +.Nm
> +will save the previous window contents and restore it afterwards, the
> +applications contents will not be saved in the history.  This makes
> +sense if full screen edit sessions are not supposed to clutter the
> +history.
> +.Pp
>  .It Xo Ic automatic-rename
>  .Op Ic on | off
>  .Xc
> 
> 
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to