diff --git a/data/core/emptyview.lua b/data/core/emptyview.lua index 9d375c20..36ba8fb7 100644 --- a/data/core/emptyview.lua +++ b/data/core/emptyview.lua @@ -8,8 +8,18 @@ local function draw_text(x, y, color) local th = style.big_font:get_height() local dh = 2 * th + style.padding.y * 2 local x1, y1 = x, y + (dh - th) / 2 - x = renderer.draw_text(style.big_font, "Lite XL", x1, y1, color) - renderer.draw_text(style.font, "version " .. VERSION, x1, y1 + th, color) + local xv = x1 + local title = "Lite XL" + local version = "version " .. VERSION + local title_width = style.big_font:get_width(title) + local version_width = style.font:get_width(version) + if version_width > title_width then + version = VERSION + version_width = style.font:get_width(version) + xv = x1 - (version_width - title_width) + end + x = renderer.draw_text(style.big_font, title, x1, y1, color) + renderer.draw_text(style.font, version, xv, y1 + th, color) x = x + style.padding.x renderer.draw_rect(x, y, math.ceil(1 * SCALE), dh, color) local lines = { diff --git a/meson.build b/meson.build index aec0cdb1..3821e24c 100644 --- a/meson.build +++ b/meson.build @@ -9,13 +9,32 @@ project('lite-xl', ] ) +#=============================================================================== +# Project version including git commit if possible +#=============================================================================== +version = meson.project_version() + +if get_option('buildtype') != 'release' + git_command = find_program('git', required : false) + + if git_command.found() + git_commit = run_command( + [git_command, 'rev-parse', 'HEAD'] + ).stdout().strip() + + if git_commit != '' + version += ' (git-' + git_commit.substring(0, 8) + ')' + endif + endif +endif + #=============================================================================== # Configuration #=============================================================================== conf_data = configuration_data() conf_data.set('PROJECT_BUILD_DIR', meson.current_build_dir()) conf_data.set('PROJECT_SOURCE_DIR', meson.current_source_dir()) -conf_data.set('PROJECT_VERSION', meson.project_version()) +conf_data.set('PROJECT_VERSION', version) #=============================================================================== # Compiler Settings