summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTitanSnow <[email protected]>2017-04-30 16:10:16 +0800
committerTitanSnow <[email protected]>2017-04-30 16:10:16 +0800
commitc4befb68350f0c2cc25e4cfe3834a9b1f0ca66f8 (patch)
tree52257413a2aa81d33fede5c0807ca2e8e08051c5
parenta980348ac39a4b45492601bf1e12dfd0e4d1a892 (diff)
fix default value view
-rw-r--r--xmake/core/base/option.lua20
1 files changed, 13 insertions, 7 deletions
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index 2c4dfe323..09cb148f6 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -1046,13 +1046,13 @@ function option.show_options(options)
-- append color
option_info = "${green}" .. option_info .. "${clear}"
+ function get_linelen(st)
+ local poss = string.find(string.reverse(st), "\n")
+ if not poss then return (#st) end
+ local start_pos, _ = poss
+ return start_pos - 1
+ end
function inwidth_append(dst, st, padding, width, remain_width)
- function get_linelen(st)
- local poss = string.find(string.reverse(st), "\n")
- if not poss then return (#st) end
- local start_pos, _ = poss
- return start_pos - 1
- end
function get_lastspace(st)
local poss = string.find(string.reverse(st), "[%s-]")
if not poss then return (#st) end
@@ -1090,7 +1090,13 @@ function option.show_options(options)
-- append the default value
local default = opt[4]
if default then
- option_info = inwidth_append(option_info, " (default: ${bright}" .. tostring(default) .. "${clear})", padding + 1, console_width) -- wrong, but looks ok
+ option_info = inwidth_append(option_info, " (default: ", padding + 1, console_width)
+ local origin_width = get_linelen(option_info)
+ option_info = option_info .. "${bright}"
+ option_info = inwidth_append(option_info, tostring(default), padding + 1, console_width, console_width - origin_width)
+ origin_width = option._ifelse(origin_width + (#(tostring(default))) > console_width, get_linelen(option_info), origin_width + (#(tostring(default))))
+ option_info = option_info .. "${clear}"
+ option_info = inwidth_append(option_info, ")", padding + 1, console_width, console_width - origin_width)
end
-- print option info