#!/bin/sh #********************************************************************** # Copyright (C) 2021 - The Geeqie Team # # Author: Colin Clark # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #********************************************************************** ## @file ## @brief Generate Help .xml files describing window shortcut keys. ## ## The .xml files are included within ./doc/docbook/GuideReferenceKeyboardShortcuts.xml ## ## For separate windows, source code files are searched for the string "hard_coded_window_keys" ## which is an array containing the shortcut key and the menu label. ## ## For the main window the source file ./src/layout-util.cc is searched for ## lines which contain shortcut definitions. ## ## This needs to be run only when the sortcut keys have been changed ## duplicates_xml="Duplicates window" search_xml="Search window" pan_view_xml="Pan view window" collections_xml="Collections window" image_xml="Image view window" main_window_xml="Main window" pre_1_xml="\n \n " pre_2_xml=" keyboard shortcuts\n \n \n \n \n Shortcut\n Action\n \n \n \n " post_xml="
" post_main_window_xml=" 1...6 Toggle mark 1 ... 6 Ctrl +1...Ctrl +6 Select mark 1 ... 6 " # shellcheck disable=SC2016 awk_window='BEGIN { {FS=","} while ($0 !~ /^hard_coded_window_keys/) {getline} } $0~/\{static_cast\\(0\), 0/ {exit} { gsub(/\{static_cast\\(0\)/, "", $1); gsub(/\{static_cast\\(GDK_CONTROL_MASK \+ GDK_SHIFT_MASK\)/, "Ctrl + Shift +", $1); gsub(/{GDK_CONTROL_MASK/, "Ctrl +", $1); gsub(/{GDK_SHIFT_MASK/, "Shift +", $1); gsub(/{GDK_MOD1_MASK/, "Alt +", $1); gsub(/ GDK_KEY_/, "", $2); gsub(/\047/, "", $2); gsub(/N_\(/, "", $3); gsub(/\)\}/, "", $3); gsub(/"/, "", $3); } {print " ", $1, "", $2, " ", $3, " "} ' # This assumes that lines beginning with /^ { "/ are the only ones in layout-util.cc containing key shortcuts # shellcheck disable=SC2016 awk_main_window='BEGIN { {FS=","} } $0 ~ /^ { "/ { if ($4 !~ /nullptr/) { { gsub(/^[[:space:]]+|[[:space:]]+$/,"",$4); gsub(/^[[:space:]]+|[[:space:]]+$/,"",$5); gsub(/{0/, "", $4); gsub(//, "Ctrl + ", $4); gsub(//, "Alt + ", $4); gsub(//, "Shift + ", $4); gsub(/"/,"", $4); gsub(/slash/,"/", $4); gsub(/bracketleft/,"[", $4); gsub(/bracketright/,"]", $4); gsub(/"/,"", $5); gsub(/N_\(/, "", $5); gsub(/\)\}/, "", $5); gsub(/"/, "", $5); gsub(/\.\.\./, "", $5); gsub(/)/, "", $5); } {print " ", "", $4, " ", $5, " "} } } ' keys_xml=$(awk "$awk_window" ./src/dupe.cc ) printf '%b\n' "$pre_1_xml $duplicates_xml $pre_2_xml $keys_xml $post_xml" > ./doc/docbook/GuideReferenceDuplicatesShortcuts.xml keys_xml=$(awk "$awk_window" ./src/search.cc ) printf '%b\n' "$pre_1_xml $search_xml $pre_2_xml $keys_xml $post_xml" > ./doc/docbook/GuideReferenceSearchShortcuts.xml keys_xml=$(awk "$awk_window" ./src/pan-view/pan-view.cc ) printf '%b\n' "$pre_1_xml $pan_view_xml $pre_2_xml $keys_xml $post_xml" > ./doc/docbook/GuideReferencePanViewShortcuts.xml keys_xml=$(awk "$awk_window" ./src/collect-table.cc) printf '%b\n' "$pre_1_xml $collections_xml $pre_2_xml $keys_xml $post_xml" > ./doc/docbook/GuideReferenceCollectionsShortcuts.xml keys_xml=$(awk "$awk_window" ./src/img-view.cc) printf '%b\n' "$pre_1_xml $image_xml $pre_2_xml $keys_xml $post_xml" > ./doc/docbook/GuideReferenceImageViewShortcuts.xml keys_xml=$(awk "$awk_main_window" ./src/layout-util.cc) printf '%b\n' "$pre_1_xml $main_window_xml $pre_2_xml $keys_xml $post_main_window_xml" > ./doc/docbook/GuideReferenceMainWindowShortcuts.xml