From b7e7669999b0f7d86c46dbf3dbab4a6b6424d88e Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Thu, 12 Feb 2015 13:29:49 +0100 Subject: [PATCH] Improve fetching "window_layout" value It's faster now. --- CHANGELOG.md | 3 +++ scripts/helpers.sh | 7 ------- scripts/restore.sh | 7 +++++++ scripts/save.sh | 20 ++++++++++++++------ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7dedba..6d5291d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ### 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 - bugfix: zoomed windows related regression diff --git a/scripts/helpers.sh b/scripts/helpers.sh index 1fdfaae..6b654af 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -66,13 +66,6 @@ is_session_grouped() { [[ "$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 resurrect_dir() { diff --git a/scripts/restore.sh b/scripts/restore.sh index 7e890f3..495e286 100755 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -245,6 +245,13 @@ restore_active_pane_for_each_window() { 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() { while read line; do if is_line_type "grouped_session" "$line"; then diff --git a/scripts/save.sh b/scripts/save.sh index e6f4e7d..45ec621 100755 --- a/scripts/save.sh +++ b/scripts/save.sh @@ -85,6 +85,11 @@ dump_windows_raw(){ tmux list-windows -a -F "$(window_format)" } +toggle_window_zoom() { + local target="$1" + tmux resize-pane -Z -t "$target" +} + _save_command_strategy_file() { 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" @@ -167,11 +172,6 @@ dump_panes() { if is_session_grouped "$session_name"; then continue 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)" 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 @@ -184,6 +184,15 @@ dump_windows() { if is_session_grouped "$session_name"; then continue 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}" done } @@ -210,7 +219,6 @@ save_all() { if save_bash_history_option_on; then dump_bash_history fi - restore_zoomed_windows } show_output() {