Skip to content

Commit

Permalink
update custom border style
Browse files Browse the repository at this point in the history
  • Loading branch information
yorukot committed Apr 28, 2024
1 parent 465920e commit 6ff0576
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/internal/config_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ type ConfigType struct {
BorderTopRight string `toml:"border_top_right"`
BorderBottomLeft string `toml:"border_bottom_left"`
BorderBottomRight string `toml:"border_bottom_right"`
BorderSplitLeft string `toml:"border_split_left"`
BorderSplitRight string `toml:"border_split_right"`
BorderMiddleLeft string `toml:"border_middle_left"`
BorderMiddleRight string `toml:"border_middle_right"`

Metadata bool `toml:"metadata" comment:"\n==========PLUGINS========== #\n\nShow more detailed metadata, please install exiftool before enabling this plugin!"`
}
Expand Down
4 changes: 2 additions & 2 deletions src/internal/default_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ border_top_left = "┏"
border_top_right = "┓"
border_bottom_left = "┗"
border_bottom_right = "┛"
border_split_left = ""
border_split_right = ""
border_middle_left = ""
border_middle_right = ""
#
# ==========PLUGINS========== #
#
Expand Down
8 changes: 4 additions & 4 deletions src/internal/model_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ func filePanelRender(m model) string {
panelModeString = "󰆽 Select"
}

f[i] += filePanelDividerStyle(filePanel.focusType).Render(strings.Repeat("━", filePanelWidth)) + "\n"
f[i] += filePanelDividerStyle(filePanel.focusType).Render(strings.Repeat(Config.BorderTop, filePanelWidth)) + "\n"
f[i] += " " + filePanel.searchBar.View() + "\n"
if len(filePanel.element) == 0 {
f[i] += filePanelStyle.Render("  No such file or directory")
bottomBorder := generateFooterBorder(fmt.Sprintf("%s┣━┫%s", panelModeString, "0/0"), footerBorderWidth)
bottomBorder := generateFooterBorder(fmt.Sprintf("%s%s%s", panelModeString, bottomMiddleBorderSplit, "0/0"), footerBorderWidth)
f[i] = filePanelBorderStyle(m.mainPanelHeight, filePanelWidth, filePanel.focusType, bottomBorder).Render(f[i])
} else {
for h := filePanel.render; h < filePanel.render+panelElementHeight(m.mainPanelHeight) && h < len(filePanel.element); h++ {
Expand All @@ -115,7 +115,7 @@ func filePanelRender(m model) string {
cursorPosition := strconv.Itoa(filePanel.cursor + 1)
totalElement := strconv.Itoa(len(filePanel.element))

bottomBorder := generateFooterBorder(fmt.Sprintf("%s┣━┫%s/%s", panelModeString, cursorPosition, totalElement), footerBorderWidth)
bottomBorder := generateFooterBorder(fmt.Sprintf("%s%s%s/%s", panelModeString, bottomMiddleBorderSplit, cursorPosition, totalElement), footerBorderWidth)
f[i] = filePanelBorderStyle(m.mainPanelHeight, filePanelWidth, filePanel.focusType, bottomBorder).Render(f[i])
}
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func clipboardRender(m model) string {
} else {
bottomWidth = footerWidth(m.fullWidth)
}
clipboardRender = clipboardBoarder(bottomElementHight(footerHeight), bottomWidth, "━").Render(clipboardRender)
clipboardRender = clipboardBoarder(bottomElementHight(footerHeight), bottomWidth, Config.BorderBottom).Render(clipboardRender)

return clipboardRender
}
Expand Down
7 changes: 6 additions & 1 deletion src/internal/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ var (
sidebarWidth = 20
)

var (
bottomMiddleBorderSplit string
)
var (
terminalTooSmall lipgloss.Style
terminalCorrectSize lipgloss.Style
Expand Down Expand Up @@ -65,6 +68,8 @@ var (
)

func LoadThemeConfig() {
bottomMiddleBorderSplit = Config.BorderMiddleLeft + Config.BorderBottom + Config.BorderMiddleRight

filePanelBorderColor = lipgloss.Color(theme.FilePanelBorder)
sidebarBorderColor = lipgloss.Color(theme.SidebarBorder)
footerBorderColor = lipgloss.Color(theme.FooterBorder)
Expand Down Expand Up @@ -161,7 +166,7 @@ func generateGradientColor() progress.Option {
}

func generateFooterBorder(countString string, width int) string {
return strings.Repeat("━", width-len(countString)) + "┫" + countString + "┣"
return strings.Repeat(Config.BorderBottom, width-len(countString)) + Config.BorderMiddleRight + countString + Config.BorderMiddleLeft
}

func footerWidth(fullWidth int) int {
Expand Down
36 changes: 19 additions & 17 deletions src/internal/style_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ func filePanelBorderStyle(height int, width int, focusType filePanelFocusType, b
border.Right = ""
for i := 0; i < height; i++ {
if i == 1 {
border.Left += "┣"
border.Right += "┫"
border.Left += Config.BorderMiddleLeft
border.Right += Config.BorderMiddleRight
} else {
border.Left += "┃"
border.Right += "┃"
border.Left += Config.BorderLeft
border.Right += Config.BorderRight
}
}
border.Bottom = borderBottom
Expand Down Expand Up @@ -50,7 +50,7 @@ func sideBarBorderStyle(height int, focus focusPanelType) lipgloss.Style {
// Generate border style for process and can custom bottom border
func procsssBarBoarder(height int, width int, borderBottom string, focusType focusPanelType) lipgloss.Style {
border := generateBorder()
border.Top = "━┫ Processes " + strings.Repeat("━", width)
border.Top = Config.BorderTop + Config.BorderMiddleRight + " Processes " + Config.BorderMiddleLeft + strings.Repeat(Config.BorderTop, width)
border.Bottom = borderBottom

processBorderStateColor := footerBorderColor
Expand All @@ -71,7 +71,7 @@ func procsssBarBoarder(height int, width int, borderBottom string, focusType foc
// Generate border style for metadata and can custom bottom border
func metadataBoarder(height int, width int, borderBottom string, focusType focusPanelType) lipgloss.Style {
border := generateBorder()
border.Top = "━┫ Metadata " + strings.Repeat("━", width)
border.Top = Config.BorderTop + Config.BorderMiddleRight + " Metadata " + Config.BorderMiddleLeft + strings.Repeat(Config.BorderTop, width)
border.Bottom = borderBottom

metadataBorderStateColor := footerBorderColor
Expand All @@ -92,7 +92,7 @@ func metadataBoarder(height int, width int, borderBottom string, focusType focus
// Generate border style for clipboard and can custom bottom border
func clipboardBoarder(height int, width int, borderBottom string) lipgloss.Style {
border := generateBorder()
border.Top = "━┫ Clipboard w" + strings.Repeat("━", width)
border.Top = Config.BorderTop + Config.BorderMiddleRight + " Clipboard " + Config.BorderMiddleLeft + strings.Repeat(Config.BorderTop, width)
border.Bottom = borderBottom

return lipgloss.NewStyle().
Expand All @@ -107,10 +107,11 @@ func clipboardBoarder(height int, width int, borderBottom string) lipgloss.Style

// Generate modal (pop up widnwos) border style
func modalBorderStyle(height int, width int) lipgloss.Style {
border := generateBorder()
return lipgloss.NewStyle().Height(height).
Width(width).
Align(lipgloss.Center, lipgloss.Center).
Border(lipgloss.ThickBorder()).
Border(border).
BorderForeground(modalBorderActiveColor).
BorderBackground(modalBGColor).
Background(modalBGColor).
Expand All @@ -119,10 +120,11 @@ func modalBorderStyle(height int, width int) lipgloss.Style {

// Generate first use modal style (This modal pop up when user first use superfile)
func firstUseModal(height int, width int) lipgloss.Style {
border := generateBorder()
return lipgloss.NewStyle().Height(height).
Width(width).
Align(lipgloss.Left, lipgloss.Center).
Border(lipgloss.ThickBorder()).
Border(border).
BorderForeground(modalBorderActiveColor).
BorderBackground(modalBGColor).
Background(modalBGColor).
Expand Down Expand Up @@ -180,13 +182,13 @@ func stringColorRender(fgColor lipgloss.Color, bgColor lipgloss.Color) lipgloss.
// Geerate border style
func generateBorder() lipgloss.Border {
return lipgloss.Border{
Top: "━",
Bottom: "━",
Left: "┃",
Right: "┃",
TopLeft: "┏",
TopRight: "┓",
BottomLeft: "┗",
BottomRight: "┛",
Top: Config.BorderTop,
Bottom: Config.BorderBottom,
Left: Config.BorderLeft,
Right: Config.BorderRight,
TopLeft: Config.BorderTopLeft,
TopRight: Config.BorderTopRight,
BottomLeft: Config.BorderBottomLeft,
BottomRight: Config.BorderBottomRight,
}
}

0 comments on commit 6ff0576

Please sign in to comment.