FileManager: truncate left in selected files list (#10783)

Truncate the path to view the filename in full. Closes #10760.
reviewable/pr10773/r1
hius07 9 months ago committed by GitHub
parent cc391514b5
commit 1544ca28af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1269,7 +1269,10 @@ end
function FileManager:showSelectedFilesList()
local selected_files = {}
for file in pairs(self.selected_files) do
table.insert(selected_files, { text = file })
table.insert(selected_files, {
text = file,
bidi_wrap_func = BD.filepath,
})
end
local function sorting(a, b)
local a_path, a_name = util.splitFilePathName(a.text)
@ -1287,6 +1290,7 @@ function FileManager:showSelectedFilesList()
local menu = Menu:new{
is_borderless = true,
is_popout = false,
truncate_left = true,
show_parent = menu_container,
onMenuSelect = function(_, item)
UIManager:close(menu_container)

@ -224,13 +224,17 @@ function MenuItem:init()
text = text,
face = self.face,
bold = self.bold,
truncate_left = self.truncate_left,
fgcolor = self.dim and Blitbuffer.COLOR_DARK_GRAY or nil,
}
local w = item_name:getWidth()
if w > available_width then
-- We give it a little more room if truncated for better visual
local text_max_width_if_ellipsis = available_width
-- We give it a little more room if truncated at the right for better visual
-- feeling (which might make it no more truncated, but well...)
local text_max_width_if_ellipsis = available_width + text_mandatory_padding - text_ellipsis_mandatory_padding
if not self.truncate_left then
text_max_width_if_ellipsis = text_max_width_if_ellipsis + text_mandatory_padding - text_ellipsis_mandatory_padding
end
item_name:setMaxWidth(text_max_width_if_ellipsis)
else
if self.with_dots then
@ -1063,6 +1067,7 @@ function Menu:updateItems(select_number)
linesize = self.linesize,
single_line = self.single_line,
multilines_show_more_text = multilines_show_more_text,
truncate_left = self.truncate_left,
align_baselines = self.align_baselines,
with_dots = self.with_dots,
line_color = self.line_color,

Loading…
Cancel
Save