TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

split tmux, set width/height variables for each pane

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Finished Scripts
View previous topic :: View next topic  
Author Message
goofy



Joined: 24 Mar 2008
Posts: 164

PostPosted: Wed Mar 26, 2014 12:41 pm    Post subject: split tmux, set width/height variables for each pane Reply with quote

this script will split your screen in two panes
it works using this statement:

"if 1/2 of terminal_width is less than desired split_width(81), use desired split_width
otherwise
use 50/50 split "

this insures a 50/50 split will not leave your primary terminal undersized due
to screen resolution or font size.

(you will need to change the name of the file you want to tail)

Here is the code
Code:
#nop    find terminal dimensions
        #format {screen_width}  {%C}         {}
        #format {screen_height} {%R}         {}

#nop    to determine tmux split width
    #math {tmux_split} {$screen_width - 81}
    #math {tmux_half} {$screen_width / 2}

#nop    checking for *tmux*    (free linux software)         
    #act {tmux %1} {#var tmux on}
    #script {path} {tmux -V}
    #showme {$path[1]}   
     
    #nop check for open tmux panes and split accordingly
    #act {0: [%1x%2] [history %3/%4, %5 bytes] %%%6 (active)} {
        #var screen_0_height %1;
        #var screen_0_width %2;
        #if { "$screen_1" != "open" } {
            #if { "$tmux_split" >= "$tmux_half" } {
                #sys {tmux split-window -h -p 50 "tail -f all_but_roomname.log"};
                #sys {tmux select-pane -t 0};
                } {
                #sys {tmux split-window -h -l $tmux_split "tail -f all_but_roomname.log"};
                #sys {tmux select-pane -t 0};
                };
            };
        }
    #act {1: [%1x%2] [history %3/%4, %5 bytes] %%%6} {
        #var screen_1 open;
        #var screen_1_height %1;
        #var screen_1_width %2;
        }
    #script {path} {tmux list-panes}
    #showme {listing current tmux panes...}
    #showme { }
    #showme {$path[2]}
    #showme {$path[1]}


this should be useful aslo if you enjoy editing with vi

Code:

#nop for editing with vi/vim
#nop see the line 'tmux split -h 'vi ~/ARTT/%1;'?
#noip change '~/ARTT/' to desired directory

#alias  {ls} {#sys ls *.tt}
#alias  {vi %1}{
    #var screen_1 shut;
    #script {path} {tmux list-panes};
    #showme {listing current tmux panes...};
    #showme {$path[2]};
    #if { "$screen_1" == "open" } {#sys tmux kill-pane -t 1};
    #run {vi} {
        tmux split -h 'vi ~/ARTT/%1;
        tmux split-window -h -p 100 "tail -f all_but_roomname.log";
        tmux select-pane -t 0;'
        };
    }

#nop redundant?
    #act {1: [%1x%2] [history %3/%4, %5 bytes] %%%6} {
        #var screen_1 open;
        #var screen_1_height %1;
        #var screen_1_width %2;
        }


The code below includes extra functionality described at the bottom
Code:
#nop    find terminal dimensions
        #format {screen_width}  {%C}         {}
        #format {screen_height} {%R}         {}

#nop    to determine tmux split width
    #math {tmux_split} {$screen_width - 81}
    #math {tmux_half} {$screen_width / 2}

#nop    checking for *tmux*    (free linux software)         
    #act {tmux %1} {#var tmux on}
    #script {path} {tmux -V}
    #showme {$path[1]}   
     
    #nop check for open tmux panes and split accordingly
    #act {0: [%1x%2] [history %3/%4, %5 bytes] %%%6 (active)} {
        #var screen_0_height %1;
        #var screen_0_width %2;
        #if { "$screen_1" != "open" } {
            #sys > /home/guest/ARTT/log/character_score.log;
            #sys tmux source ~/ARTT/artt_tmux.conf;
            #if { "$tmux_split" >= "$tmux_half" } {
                #sys {tmux split-window -h -p 50 "tail -f all_but_roomname.log"};
                #sys {tmux select-pane -t 0};
                } {
                #sys {tmux split-window -h -l $tmux_split "tail -f all_but_roomname.log"};
                #sys {tmux select-pane -t 0};
                };
            };
        }
    #act {1: [%1x%2] [history %3/%4, %5 bytes] %%%6} {
        #var screen_1 open;
        #var screen_1_height %1;
        #var screen_1_width %2;
        }
    #script {path} {tmux list-panes}
    #showme {listing current tmux panes...}
    #showme { }
    #showme {$path[2]}
    #showme {$path[1]}


this code, included above is to show character score in tmux status and can be removed or implemented as desired.

clear the log holding your character score
Code:
            #sys > /home/guest/ARTT/log/character_score.log;


your custom tmux config which tails character score
Code:
            #sys tmux source ~/ARTT/artt_tmux.conf;


add this to your custom tmux config to tail character score
Code:
set -g status-left '#[fg=gray]#(cat /home/guest/ARTT/log/character_score.log | tail -f)'


and add something like this to your mud score
Code:
    #line log {/home/guest/ARTT/log/character_score.log} {class:$class race:$race hometown:$hometown age

_________________
www.abandonedrealms.com


Last edited by goofy on Sat Mar 29, 2014 3:21 pm; edited 1 time in total
Back to top
View user's profile Send private message
goofy



Joined: 24 Mar 2008
Posts: 164

PostPosted: Mon Dec 22, 2014 7:24 pm    Post subject: Reply with quote

updated tmux.tt
questions are welcome.
Code:
#nop    c--------------------o    tmux split-window,
#nop    |       tmux.tt      |    tail data from msdp
#nop    c--------------------c
#nop            script
#nop    c---------------------o    c---------------o
#nop    | abandonedrealms.com |    | tintin.sf.net |
#nop    c---------------------c    c---------------c
#nop            realms                   client

#class tmux open

#alias tmux_lsp {
    #script {path} {tmux lsp};
    #foreach {$path[]} {pane} {
        #regexp {$path[$pane]} {%+: [%+x%+] [history %* bytes] {.?}%d} {
            #var {pane&1}
                {
                {n}{&1}
                {t}{%&6}
                {x}{&2}
                {y}{&3}
                };
            };
        };
    #unvar path;
    #unvar pane;
    };tmux_lsp

#alias {wipe_logs} {
    #script {log_file} {ls log | grep '%*'.log};
    #foreach {$log_file[]} {file} {#sys {> ${log}$log_file[$file]} };
    #unalias wipe_logs;
    #unvar log_file;
    #unvar file;
    };wipe_logs

#alias {create_tmux_panes} {
    #nop    * here we check to see if terminal window has;
    #nop      opened wide enough for our tmux pane split.;
    #nop      we also make sure tmux hasn't already split;

    #if { "$pane0[x]" > "100" & "$pane1[n]" != "1" } {

        #nop    * y=height & x=width;
        #format {terminal_x} {%C} {};
        #format {terminal_y} {%R} {};

        #alias splitw_tailf {#sys {
            tmux splitw %%1 %%2 %%3 'tail -f ${log}%%4'};
            };
        #nop    * adds ( split + 1 ) each time split -h occurs;
        #nop      +1 cause of space taken by tmux pane borders;
        #nop      figures lines remaining for leftp_y_remnants;

        #var leftp_y_sum 0;
        #alias leftp_y_gain { #math {leftp_y_sum} {$leftp_y_sum + %%1} };
        #alias selectp {#sys {tmux select-pane %%1}};

        #nop desired width;
        #nop for your main;
        #var pane_x_main 85;

        #var {x} {$terminal_x};
        #var {y} {$pane_x_main};
        #math {pane_x_side} { ( $x - $y ) / 2 };

        #nop    ^ subtract main pane width from terminal width;
        #nop    | to get remaining width for our two side panes;

        #var {x} {$terminal_y};
        #math {pane_y_right} { ( $x / 2 ) - 3 };

        #nop    c---------------------------o;
        #nop    | The tmux window splitting |;
        #nop    c---------------------------c;

        #nop 9    .right_side;
        splitw_tailf -h -l $pane_x_side Inventory.log;

        #nop 10    .right_side;
        splitw_tailf -v -l $pane_y_right inventory.log;
        selectp -U;

        #nop 11    .right_side;
        splitw_tailf -v -l 2 Affects.log;
        selectp -U;

        #nop 12    .right_side;
        splitw_tailf -v -l $pane_y_right affects.log;
        selectp -L;

            #nop    * Alas, we return to the;
            #nop      pane where we started.;
            #nop      We want a nice pane on;
            #nop      left side now, however;
            #nop      tmux is naughty & only;
            #nop      creates panes on right;
            #nop      therefore, we have got;
            #nop      to try on swap-pane -U;
            #nop           naughty tmux!;

        #nop 0    .left_side;
        splitw_tailf -h -l $pane_x_main Group.log;
        leftp_y_gain 3;

        #nop    * swap center/left pane,
        #nop      you get the left pane;
        #sys tmux swap-pane -U;

        #nop 7    .left_side;
        splitw_tailf -v -l 2 tick.log; 
        selectp -U;
        leftp_y_gain 3;

        #nop 6    .left_side;
        splitw_tailf -v -l 2 world_time.log;
        selectp -U;
        leftp_y_gain 3;

        #nop 4    .left_side;
        #var map_height 11;
        splitw_tailf -v -l $map_height blank.log;
        leftp_y_gain 12;

        #var {x} {$pane_x_side}; 
        #var {y} {4};
        #math {blank_pane} { ( $x / 2 ) + $y };

        #nop    * blank_pane variable above;
        #nop      determines the width of a;
        #nop      pane adjacent to map with;
        #nop     'y' we can center map.;

        #nop 5    .left_side;
        splitw_tailf -h -l $blank_pane map.log;
        selectp -U;

        #nop 3    .left_side;
        splitw_tailf -v -l 2 room_name.log;
        leftp_y_gain 3;
        selectp -U;

        #nop 2    .left_side;
        splitw_tailf -v -l 2 area_name.log;
        leftp_y_gain 3;
        selectp -U;

        #nop    * let's take what's left our;
        #nop      our left horizontal lines;
        #nop      (represented by leftp_y_remnants);
        #nop      and make one more pane!;

        #var x {$terminal_y};
        #var y {$leftp_y_sum};
        #math {leftp_y_remnants} { ($x - $y) };

        #nop 1    .left_side;
        splitw_tailf -v -l $leftp_y_remnants group.log;

        selectp -R;

        #delay 1 { #sys {tmux displayp} };

        #unvar terminal_x_test;
        #unvar map_x;
        #unvar path;
        #unvar x;
        #unvar y;
        tmux_lsp;
        };
    };create_tmux_panes

#class tmux close

_________________
www.abandonedrealms.com
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Finished Scripts All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group