Documentation
¶
Index ¶
- Constants
- Variables
- func CheckAndTruncateLineLengths(text string, maxLength int) string
- func ClipboardBorder(height int, width int, borderBottom string) lipgloss.Style
- func ClipboardPrettierName(name string, width int, isDir bool, isSelected bool) string
- func FileNameWithoutExtension(fileName string) string
- func FilePanelBorderStyle(height int, width int, filePanelFocussed bool, borderBottom string) lipgloss.Style
- func FilePanelDividerStyle(filePanelFocussed bool) lipgloss.Style
- func FilePanelFocusColor(filePanelFocussed bool) lipgloss.Color
- func FilePreviewBox(height int, width int) lipgloss.Style
- func FirstUseModal(height int, width int) lipgloss.Style
- func FormatFileSize(size int64) string
- func FullScreenStyle(height int, width int) lipgloss.Style
- func GenerateBorder() lipgloss.Border
- func GenerateDefaultProgress() progress.Model
- func GenerateFooterBorder(countString string, width int) string
- func GenerateGradientColor() progress.Option
- func GenerateNewFileTextInput() textinput.Model
- func GeneratePinnedRenameTextInput(cursorPos int, defaultValue string) textinput.Model
- func GeneratePromptTextInput() textinput.Model
- func GenerateRenameTextInput(width int, cursorPos int, defaultValue string) textinput.Model
- func GenerateSearchBar() textinput.Model
- func GetElementIcon(file string, isDir bool, nerdFont bool) icon.Style
- func InitTrash() bool
- func IsBufferPrintable(buffer []byte) bool
- func IsExtensionExtractable(ext string) bool
- func IsTextFile(filename string) (bool, error)
- func LoadAllDefaultConfig(content embed.FS)
- func LoadConfigError(value string) string
- func LoadConfigFile()
- func LoadConfigStringGlobals(content embed.FS) error
- func LoadHotkeysError(value string) string
- func LoadHotkeysFile(ignoreMissingFields bool)
- func LoadInitialPrerenderedVariables()
- func LoadPrerenderedVariables()
- func LoadThemeConfig()
- func LoadThemeFile()
- func MakePrintable(line string) string
- func MakePrintableWithEscCheck(line string, allowEsc bool) string
- func MetadataBorder(height int, width int, borderBottom string, metadataFocussed bool) lipgloss.Style
- func ModalBorderStyle(height int, width int) lipgloss.Style
- func ModalBorderStyleLeft(height int, width int) lipgloss.Style
- func PopulateConfigFromFile(configFilePath string) error
- func PopulateGlobalConfigs() error
- func PopulateHotkeyFromFile(hotkeyFilePath string) error
- func PopulateThemeFromFile(themeFilePath string) error
- func PrettierDirectoryPreviewName(name string, isDir bool, bgColor lipgloss.Color) string
- func PrettierName(name string, width int, isDir bool, isSelected bool, bgColor lipgloss.Color) string
- func ProcsssBarBorder(height int, width int, borderBottom string, processBarFocussed bool) lipgloss.Style
- func SideBarBorderStyle(height int, sidebarFocussed bool) lipgloss.Style
- func SortOptionsModalBorderStyle(height int, width int, borderBottom string) lipgloss.Style
- func StringColorRender(fgColor lipgloss.Color, bgColor lipgloss.Color) lipgloss.Style
- func TransparentAllBackgroundColor()
- func TruncateMiddleText(text string, maxChars int, tails string) string
- func TruncateText(text string, maxChars int, tails string) string
- func TruncateTextBeginning(text string, maxChars int, tails string) string
- func ValidateConfig(c *ConfigType) error
- func WriteThemeFiles(content embed.FS) error
- type CDCurrentPanelAction
- type ConfigType
- type HotkeysType
- type ModelAction
- type NoAction
- type OpenPanelAction
- type ShellCommandAction
- type SplitPanelAction
- type ThemeType
Constants ¶
const ( MinimumHeight = 24 MinimumWidth = 60 // TODO : These are model object properties, not global properties // We are modifying them in the code many time. They need to be part of model struct. ModalWidth = 60 ModalHeight = 7 )
const DateModifiedOption = "Date Modified"
const DefaultCommandTimeout = 5000 * time.Millisecond
const PermanentDeleteWarnContent = "This operation cannot be undone and your data will be completely lost."
const PermanentDeleteWarnTitle = "Are you sure you want to completely delete"
const SameRenameWarnContent = "This operation will override the existing file"
const SameRenameWarnTitle = "There is already a file or directory with that name"
const TrashWarnContent = "This operation will move file or directory to trash can."
const TrashWarnTitle = "Are you sure you want to move this to trash can"
const WheelRunTime = 5
Variables ¶
var ( HotkeysTomlString string ConfigTomlString string DefaultThemeString string )
Variables for holding default configurations of each settings
var ( SideBarSuperfileTitle string SideBarPinnedDivider string SideBarDisksDivider string SideBarNoneText string ProcessBarNoneText string FilePanelTopDirectoryIcon string FilePanelNoneText string FilePreviewNoContentText string FilePreviewNoFileInfoText string FilePreviewUnsupportedFormatText string FilePreviewUnsupportedFileMode string FilePreviewDirectoryUnreadableText string FilePreviewEmptyText string FilePreviewError string CheckboxChecked string CheckboxCheckedFocused string CheckboxEmpty string CheckboxEmptyFocused string ModalConfirmInputText string ModalCancelInputText string ModalOkayInputText string ModalInputSpacingText string LipglossError string )
var ( TerminalTooSmall lipgloss.Style TerminalCorrectSize lipgloss.Style )
var ( MainStyle lipgloss.Style FilePanelStyle lipgloss.Style SidebarStyle lipgloss.Style ModalStyle lipgloss.Style )
var ( SidebarDividerStyle lipgloss.Style SidebarTitleStyle lipgloss.Style SidebarSelectedStyle lipgloss.Style )
var ( FilePanelCursorStyle lipgloss.Style ModalCursorStyle lipgloss.Style )
var ( FilePanelTopDirectoryIconStyle lipgloss.Style FilePanelTopPathStyle lipgloss.Style FilePanelItemSelectedStyle lipgloss.Style FilePanelSelectBoxStyle lipgloss.Style )
var ( ProcessErrorStyle lipgloss.Style ProcessInOperationStyle lipgloss.Style ProcessCancelStyle lipgloss.Style ProcessSuccessfulStyle lipgloss.Style )
var ( ModalCancel lipgloss.Style ModalConfirm lipgloss.Style ModalTitleStyle lipgloss.Style ModalErrorStyle lipgloss.Style )
var ( HelpMenuHotkeyStyle lipgloss.Style HelpMenuTitleStyle lipgloss.Style )
var ( PromptSuccessStyle lipgloss.Style PromptFailureStyle lipgloss.Style )
var ( FilePanelBorderColor lipgloss.Color SidebarBorderColor lipgloss.Color FilePanelBorderActiveColor lipgloss.Color SidebarBorderActiveColor lipgloss.Color ModalBorderActiveColor lipgloss.Color FullScreenBGColor lipgloss.Color FilePanelBGColor lipgloss.Color SidebarBGColor lipgloss.Color ModalBGColor lipgloss.Color FullScreenFGColor lipgloss.Color FilePanelFGColor lipgloss.Color SidebarFGColor lipgloss.Color ModalFGColor lipgloss.Color )
var (
BottomMiddleBorderSplit string
)
var TransparentBackgroundColor string
var (
UnsupportedPreviewFormats = []string{".pdf", ".torrent"}
)
Functions ¶
func CheckAndTruncateLineLengths ¶
Truncate line lengths and keep ANSI
func ClipboardBorder ¶
Generate border style for clipboard and can custom bottom border
func ClipboardPrettierName ¶
func FilePanelBorderStyle ¶
func FilePanelBorderStyle(height int, width int, filePanelFocussed bool, borderBottom string) lipgloss.Style
Generate border style for file panel
func FilePanelDividerStyle ¶
Generate file panel divider style
func FilePanelFocusColor ¶
Return border color based on file panel status
func FilePreviewBox ¶
Generate filePreview Box
func FirstUseModal ¶
Generate first use modal style (This modal pop up when user first use superfile)
func FormatFileSize ¶
func FullScreenStyle ¶
Generate full screen style for terminal size too small etc
func GenerateDefaultProgress ¶
func GenerateFooterBorder ¶
func GenerateGradientColor ¶
func GeneratePromptTextInput ¶
func GenerateRenameTextInput ¶
func GenerateSearchBar ¶
TODO : Fix Code duplication in textInput.Model creation This eventually caused a bug, where we created new model for sidebar search, and Didn't set `Width` in that. Take Width and other parameters as input in one function Generate search bar for file panel
func IsBufferPrintable ¶
Separated this out out for easy testing
func IsExtensionExtractable ¶
IsExtensionExtractable checks if a string is a valid compressed archive file extension.
func LoadAllDefaultConfig ¶
LoadAllDefaultConfig : Load all default configurations from embedded superfile_config folder into global configurations variables and write theme files if its needed.
func LoadConfigFile ¶
func LoadConfigFile()
Load configurations from the configuration file. Compares the content with the default values and modify the config file to include default configs if the FixConfigFile flag is on TODO : Fix the code duplication with LoadHotkeysFile().
func LoadConfigStringGlobals ¶
func LoadHotkeysFile ¶
func LoadHotkeysFile(ignoreMissingFields bool)
Load keybinds from the hotkeys file. Compares the content with the default values and modify the hotkeys if the FixHotkeys flag is on.
func LoadPrerenderedVariables ¶
func LoadPrerenderedVariables()
Dependecies - TODO We should programmatically guarantee these dependencies. And log error if its not satisfied. LoadThemeConfig() in style.go should be finished loadConfigFile() in config_types.go should be finished InitIcon() in config package in function.go should be finished
func LoadThemeConfig ¶
func LoadThemeConfig()
func LoadThemeFile ¶
func LoadThemeFile()
LoadThemeFile : Load configurations from theme file into &theme set default values if we cant read user's theme file
func MakePrintable ¶
func MakePrintableWithEscCheck ¶
Although some characters like `\x0b`(vertical tab) are printable, previewing them breaks the layout. So, among the "non-graphic" printable characters, we only need \n and \t Space and NBSP are already considered graphic by unicode. Allow Any rune that is above ASCII control characters range 0x7f for valid unicodes like nerdfont \uf410 \U000f0868 Also allow \x0b that is for escape sequences This function should better not be broken into multiple functions
func MetadataBorder ¶
func MetadataBorder(height int, width int, borderBottom string, metadataFocussed bool) lipgloss.Style
Generate border style for metadata and can custom bottom border
func PopulateConfigFromFile ¶
func PopulateGlobalConfigs ¶
func PopulateGlobalConfigs() error
Used only in unit tests Populate config variables based on given file
func PopulateHotkeyFromFile ¶
func PopulateThemeFromFile ¶
func PrettierName ¶
func ProcsssBarBorder ¶
func ProcsssBarBorder(height int, width int, borderBottom string, processBarFocussed bool) lipgloss.Style
Generate border style for process and can custom bottom border
func SideBarBorderStyle ¶
Generate border style for sidebar
func SortOptionsModalBorderStyle ¶
Generate sort options modal border style
func StringColorRender ¶
Return only fg and bg color style
func TransparentAllBackgroundColor ¶
func TransparentAllBackgroundColor()
func TruncateTextBeginning ¶
func ValidateConfig ¶
func ValidateConfig(c *ConfigType) error
func WriteThemeFiles ¶
Types ¶
type CDCurrentPanelAction ¶
type CDCurrentPanelAction struct {
Location string
}
func (CDCurrentPanelAction) String ¶
func (c CDCurrentPanelAction) String() string
type ConfigType ¶
type ConfigType struct {
Theme string `toml:"theme" comment:"More details are at https://superfile.dev/configure/superfile-config/\nchange your theme"`
Editor string `toml:"editor" comment:"\nThe editor files will be opened with. (Leave blank to use the EDITOR environment variable)."`
DirEditor string `toml:"dir_editor" comment:"\nThe editor directories will be opened with. (Leave blank to use the default editors)."`
AutoCheckUpdate bool `toml:"auto_check_update" comment:"\nAuto check for update"`
CdOnQuit bool `` /* 138-byte string literal not displayed */
DefaultOpenFilePreview bool `toml:"default_open_file_preview" comment:"\nWhether to open file preview automatically every time superfile is opened."`
ShowImagePreview bool `toml:"show_image_preview" comment:"\nWhether to show image preview."`
DefaultDirectory string `toml:"default_directory" comment:"\nThe path of the first file panel when superfile is opened."`
FileSizeUseSI bool `` /* 131-byte string literal not displayed */
DefaultSortType int `toml:"default_sort_type" comment:"\nDefault sort type (0: Name, 1: Size, 2: Date Modified, 3: Type)."`
SortOrderReversed bool `toml:"sort_order_reversed" comment:"\nDefault sort order (false: Ascending, true: Descending)."`
CaseSensitiveSort bool `toml:"case_sensitive_sort" comment:"\nCase sensitive sort by name (capital \"B\" comes before \"a\" if true)."`
ShellCloseOnSuccess bool `toml:"shell_close_on_success" comment:"\nWhether to close the shell on successful command execution."`
Debug bool `toml:"debug" comment:"\nWhether to enable debug mode."`
// IgnoreMissingFields controls whether warnings about missing TOML fields are suppressed.
IgnoreMissingFields bool `toml:"ignore_missing_fields" comment:"\nWhether to ignore warnings about missing fields in the config file."`
Nerdfont bool `` /* 147-byte string literal not displayed */
ShowSelectIcons bool `toml:"show_select_icons" comment:"\nShow checkbox icons in select mode (requires nerdfont)"`
TransparentBackground bool `` /* 137-byte string literal not displayed */
FilePreviewWidth int `` /* 227-byte string literal not displayed */
CodePreviewer string `` /* 153-byte string literal not displayed */
SidebarWidth int `` /* 199-byte string literal not displayed */
BorderTop string `toml:"border_top" comment:"\nBorder style"`
BorderBottom string `toml:"border_bottom"`
BorderLeft string `toml:"border_left"`
BorderRight string `toml:"border_right"`
BorderTopLeft string `toml:"border_top_left"`
BorderTopRight string `toml:"border_top_right"`
BorderBottomLeft string `toml:"border_bottom_left"`
BorderBottomRight string `toml:"border_bottom_right"`
BorderMiddleLeft string `toml:"border_middle_left"`
BorderMiddleRight string `toml:"border_middle_right"`
Metadata bool `` /* 222-byte string literal not displayed */
EnableMD5Checksum bool `toml:"enable_md5_checksum" comment:"Enable MD5 checksum generation for files"`
ZoxideSupport bool `toml:"zoxide_support" comment:"Zoxide support for the fast navigation"`
}
Configuration settings
var Config ConfigType
func (*ConfigType) GetIgnoreMissingFields ¶ added in v1.3.2
func (c *ConfigType) GetIgnoreMissingFields() bool
GetIgnoreMissingFields reports whether warnings about missing TOML fields should be ignored.
type HotkeysType ¶
type HotkeysType struct {
Confirm []string `` /* 175-byte string literal not displayed */
Quit []string `toml:"quit"`
CdQuit []string `toml:"cd_quit"`
// movement
ListUp []string `toml:"list_up" comment:"movement"`
ListDown []string `toml:"list_down"`
PageUp []string `toml:"page_up"`
PageDown []string `toml:"page_down"`
CloseFilePanel []string `toml:"close_file_panel" comment:"file panel control"`
CreateNewFilePanel []string `toml:"create_new_file_panel"`
NextFilePanel []string `toml:"next_file_panel"`
PreviousFilePanel []string `toml:"previous_file_panel"`
ToggleFilePreviewPanel []string `toml:"toggle_file_preview_panel"`
OpenSortOptionsMenu []string `toml:"open_sort_options_menu"`
ToggleReverseSort []string `toml:"toggle_reverse_sort"`
FocusOnProcessBar []string `toml:"focus_on_process_bar" comment:"change focus"`
FocusOnSidebar []string `toml:"focus_on_sidebar"`
FocusOnMetaData []string `toml:"focus_on_metadata"`
FilePanelItemCreate []string `toml:"file_panel_item_create" comment:"create file/directory and rename "`
FilePanelItemRename []string `toml:"file_panel_item_rename"`
CopyItems []string `toml:"copy_items" comment:"file operate"`
PasteItems []string `toml:"paste_items"`
CutItems []string `toml:"cut_items"`
DeleteItems []string `toml:"delete_items"`
PermanentlyDeleteItems []string `toml:"permanently_delete_items"`
ExtractFile []string `toml:"extract_file" comment:"compress and extract"`
CompressFile []string `toml:"compress_file"`
OpenFileWithEditor []string `toml:"open_file_with_editor" comment:"editor"`
OpenCurrentDirectoryWithEditor []string `toml:"open_current_directory_with_editor"`
PinnedDirectory []string `toml:"pinned_directory" comment:"other"`
ToggleDotFile []string `toml:"toggle_dot_file"`
ChangePanelMode []string `toml:"change_panel_mode"`
OpenHelpMenu []string `toml:"open_help_menu"`
OpenCommandLine []string `toml:"open_command_line"`
OpenSPFPrompt []string `toml:"open_spf_prompt"`
OpenZoxide []string `toml:"open_zoxide"`
CopyPath []string `toml:"copy_path"`
CopyPWD []string `toml:"copy_present_working_directory"`
ConfirmTyping []string `` /* 177-byte string literal not displayed */
CancelTyping []string `toml:"cancel_typing"`
ParentDirectory []string `` /* 221-byte string literal not displayed */
SearchBar []string `toml:"search_bar"`
FilePanelSelectModeItemsSelectDown []string `` /* 245-byte string literal not displayed */
FilePanelSelectModeItemsSelectUp []string `toml:"file_panel_select_mode_items_select_up"`
FilePanelSelectAllItem []string `toml:"file_panel_select_all_items"`
}
var Hotkeys HotkeysType
type ModelAction ¶
type ModelAction interface {
String() string
}
Placeholder inteface for now, might later move 'model' type to commons and have and add an execute(model) function to this
type OpenPanelAction ¶
type OpenPanelAction struct {
Location string
}
func (OpenPanelAction) String ¶
func (o OpenPanelAction) String() string
type ShellCommandAction ¶
type ShellCommandAction struct {
Command string
}
func (ShellCommandAction) String ¶
func (s ShellCommandAction) String() string
type SplitPanelAction ¶
type SplitPanelAction struct{}
We could later move 'model' type to commons and have these actions implement an execute(model) interface
func (SplitPanelAction) String ¶
func (s SplitPanelAction) String() string
type ThemeType ¶
type ThemeType struct {
// Code syntax highlight theme
CodeSyntaxHighlightTheme string `toml:"code_syntax_highlight"`
// Border
FilePanelBorder string `toml:"file_panel_border"`
SidebarBorder string `toml:"sidebar_border"`
// Border Active
FilePanelBorderActive string `toml:"file_panel_border_active"`
SidebarBorderActive string `toml:"sidebar_border_active"`
ModalBorderActive string `toml:"modal_border_active"`
// Background (bg)
FullScreenBG string `toml:"full_screen_bg"`
FilePanelBG string `toml:"file_panel_bg"`
SidebarBG string `toml:"sidebar_bg"`
ModalBG string `toml:"modal_bg"`
// Foreground (fg)
FullScreenFG string `toml:"full_screen_fg"`
FilePanelFG string `toml:"file_panel_fg"`
SidebarFG string `toml:"sidebar_fg"`
ModalFG string `toml:"modal_fg"`
// Special Color
Cursor string `toml:"cursor"`
Correct string `toml:"correct"`
Error string `toml:"error"`
Hint string `toml:"hint"`
Cancel string `toml:"cancel"`
GradientColor []string `toml:"gradient_color"`
DirectoryIconColor string `toml:"directory_icon_color"`
// File Panel Special Items
FilePanelTopDirectoryIcon string `toml:"file_panel_top_directory_icon"`
FilePanelTopPath string `toml:"file_panel_top_path"`
FilePanelItemSelectedFG string `toml:"file_panel_item_selected_fg"`
FilePanelItemSelectedBG string `toml:"file_panel_item_selected_bg"`
// Sidebar Special Items
SidebarTitle string `toml:"sidebar_title"`
SidebarItemSelectedFG string `toml:"sidebar_item_selected_fg"`
SidebarItemSelectedBG string `toml:"sidebar_item_selected_bg"`
SidebarDivider string `toml:"sidebar_divider"`
// Modal Special Items
ModalCancelFG string `toml:"modal_cancel_fg"`
ModalCancelBG string `toml:"modal_cancel_bg"`
ModalConfirmFG string `toml:"modal_confirm_fg"`
ModalConfirmBG string `toml:"modal_confirm_bg"`
HelpMenuHotkey string `toml:"help_menu_hotkey"`
HelpMenuTitle string `toml:"help_menu_title"`
}
Theme configuration
var Theme ThemeType