WIP: feature/1-add-support-for-fs-crud #47

Draft
glenux wants to merge 28 commits from feature/1-add-support-for-fs-crud into develop
Showing only changes of commit c270df01e7 - Show all commits

View file

@ -88,7 +88,7 @@ module GX
config_root.filesystems config_root.filesystems
end end
def choose_filesystem def choose_filesystem : GX::Models::AbstractFilesystemConfig?
names_display = {} of String => NamedTuple( names_display = {} of String => NamedTuple(
filesystem: Models::AbstractFilesystemConfig, filesystem: Models::AbstractFilesystemConfig,
ansi_name: String) ansi_name: String)
@ -97,17 +97,8 @@ module GX
return if config_root.nil? return if config_root.nil?
config_root.filesystems.each do |filesystem| config_root.filesystems.each do |filesystem|
fs_str = filesystem.type.ljust(12, ' ') result_name = _fzf_plain_name(filesystem)
ansi_name = _fzf_ansi_name(filesystem)
suffix = ""
suffix_ansi = ""
if filesystem.mounted?
suffix = "[open]"
suffix_ansi = "[#{"open".colorize(:green)}]"
end
result_name = "#{fs_str} #{filesystem.name} #{suffix}".strip
ansi_name = "#{fs_str.colorize(:dark_gray)} #{filesystem.name} #{suffix_ansi}".strip
names_display[result_name] = { names_display[result_name] = {
filesystem: filesystem, filesystem: filesystem,
@ -128,12 +119,18 @@ module GX
selected_filesystem selected_filesystem
end end
private def generate_display_name(filesystem : Models::AbstractFilesystemConfig) : String private def _fzf_plain_name(filesystem : Models::AbstractFilesystemConfig) : String
fs_str = filesystem.type.ljust(12, ' ') fs_str = filesystem.type.ljust(12, ' ')
suffix = filesystem.mounted? ? "[open]" : "" suffix = filesystem.mounted? ? "[open]" : ""
"#{fs_str} #{filesystem.name} #{suffix}".strip "#{fs_str} #{filesystem.name} #{suffix}".strip
end end
private def _fzf_ansi_name(filesystem : Models::AbstractFilesystemConfig) : String
fs_str = filesystem.type.ljust(12, ' ').colorize(:dark_gray)
suffix = filesystem.mounted? ? "[#{"open".colorize(:green)}]" : ""
"#{fs_str} #{filesystem.name} #{suffix}".strip
end
private def graphical_environment? private def graphical_environment?
if ENV["DISPLAY"]? || ENV["WAYLAND_DISPLAY"]? if ENV["DISPLAY"]? || ENV["WAYLAND_DISPLAY"]?
return true return true