From 87712cf0e43fed624f8a9f610be42b1fe174b9fe Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sun, 7 Oct 2012 12:59:37 +0100 Subject: [PATCH] Show the program version in the Help header. 1. On startup read the file git-rev if exists and initialize a new global G_program_version. 2. In filechooser's help page's header show the version. This helps to easily identify what version the user is running without asking him to cat git-rev file manually. --- filechooser.lua | 3 ++- reader.lua | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/filechooser.lua b/filechooser.lua index 7cde6e144..a6fdcb86c 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -498,7 +498,8 @@ function FileChooser:addAllCommands() self.commands:add(KEY_H,nil,"H", "show help page", function(self) - HelpPage:show(0, G_height, self.commands) + local title="Hotkeys "..G_program_version + HelpPage:show(0, G_height, self.commands, title) self.pagedirty = true end ) diff --git a/reader.lua b/reader.lua index afddbc65f..57c6d1ba6 100755 --- a/reader.lua +++ b/reader.lua @@ -99,6 +99,15 @@ if optarg["G"] ~= nil then globalgamma = optarg["G"] end +local vfile = io.open("git-rev", "r") +if vfile then + G_program_version = vfile:read("*a") or "?" + G_program_version = G_program_version:gsub("[\n\r]+", "") + vfile.close() +else + G_program_version = "(unknown version)" +end + if util.isEmulated()==1 then input.open("") -- SDL key codes