Improve fetching "window_layout" value

It's faster now.
This commit is contained in:
Bruno Sutic 2015-02-12 13:29:49 +01:00
parent 952e1f9784
commit b7e7669999
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
4 changed files with 24 additions and 13 deletions

View File

@ -1,6 +1,9 @@
# Changelog # Changelog
### master ### master
- Improve fetching proper window_layout for zoomed windows. In order to fetch
proper value, window has to get unzoomed. This is now done faster so that
"unzoom,fetch value,zoom" cycle is almost unnoticable to the user.
### v2.2.0, 2015-02-12 ### v2.2.0, 2015-02-12
- bugfix: zoomed windows related regression - bugfix: zoomed windows related regression

View File

@ -66,13 +66,6 @@ is_session_grouped() {
[[ "$GROUPED_SESSIONS" == *"${d}${session_name}${d}"* ]] [[ "$GROUPED_SESSIONS" == *"${d}${session_name}${d}"* ]]
} }
restore_zoomed_windows() {
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $6 ~ /Z/ && $9 == 1 { print $2, $3; }' $(last_resurrect_file) |
while IFS=$d read session_name window_number; do
tmux resize-pane -t "${session_name}:${window_number}" -Z
done
}
# path helpers # path helpers
resurrect_dir() { resurrect_dir() {

View File

@ -245,6 +245,13 @@ restore_active_pane_for_each_window() {
done done
} }
restore_zoomed_windows() {
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $6 ~ /Z/ && $9 == 1 { print $2, $3; }' $(last_resurrect_file) |
while IFS=$d read session_name window_number; do
tmux resize-pane -t "${session_name}:${window_number}" -Z
done
}
restore_grouped_sessions() { restore_grouped_sessions() {
while read line; do while read line; do
if is_line_type "grouped_session" "$line"; then if is_line_type "grouped_session" "$line"; then

View File

@ -85,6 +85,11 @@ dump_windows_raw(){
tmux list-windows -a -F "$(window_format)" tmux list-windows -a -F "$(window_format)"
} }
toggle_window_zoom() {
local target="$1"
tmux resize-pane -Z -t "$target"
}
_save_command_strategy_file() { _save_command_strategy_file() {
local save_command_strategy="$(get_tmux_option "$save_command_strategy_option" "$default_save_command_strategy")" local save_command_strategy="$(get_tmux_option "$save_command_strategy_option" "$default_save_command_strategy")"
local strategy_file="$CURRENT_DIR/../save_command_strategies/${save_command_strategy}.sh" local strategy_file="$CURRENT_DIR/../save_command_strategies/${save_command_strategy}.sh"
@ -167,11 +172,6 @@ dump_panes() {
if is_session_grouped "$session_name"; then if is_session_grouped "$session_name"; then
continue continue
fi fi
# check if current pane is part of a maximized window and if the pane is active
if [[ "${window_flags}" == *Z* ]] && [[ ${pane_active} == 1 ]]; then
# unmaximize the pane
tmux resize-pane -Z -t "${session_name}:${window_number}"
fi
full_command="$(pane_full_command $pane_pid)" full_command="$(pane_full_command $pane_pid)"
echo "${line_type}${d}${session_name}${d}${window_number}${d}${window_name}${d}${window_active}${d}${window_flags}${d}${pane_index}${d}${dir}${d}${pane_active}${d}${pane_command}${d}:${full_command}" echo "${line_type}${d}${session_name}${d}${window_number}${d}${window_name}${d}${window_active}${d}${window_flags}${d}${pane_index}${d}${dir}${d}${pane_active}${d}${pane_command}${d}:${full_command}"
done done
@ -184,6 +184,15 @@ dump_windows() {
if is_session_grouped "$session_name"; then if is_session_grouped "$session_name"; then
continue continue
fi fi
# window_layout is not correct for zoomed windows
if [[ "$window_flags" == *Z* ]]; then
# unmaximize the window
toggle_window_zoom "${session_name}:${window_index}"
# get correct window layout
window_layout="$(tmux display-message -p -t "${session_name}:${window_index}" -F "#{window_layout}")"
# maximize window again
toggle_window_zoom "${session_name}:${window_index}"
fi
echo "${line_type}${d}${session_name}${d}${window_index}${d}${window_active}${d}${window_flags}${d}${window_layout}" echo "${line_type}${d}${session_name}${d}${window_index}${d}${window_active}${d}${window_flags}${d}${window_layout}"
done done
} }
@ -210,7 +219,6 @@ save_all() {
if save_bash_history_option_on; then if save_bash_history_option_on; then
dump_bash_history dump_bash_history
fi fi
restore_zoomed_windows
} }
show_output() { show_output() {