Skip to content

Commit

Permalink
use alternate border for move mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakenelf committed Sep 16, 2021
1 parent 8682de5 commit 117be11
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
20 changes: 17 additions & 3 deletions internal/pane/pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Model struct {
Style lipgloss.Style
IsActive bool
Borderless bool
AlternateBorder bool
ActiveBorderColor string
InactiveBorderColor string
}
Expand Down Expand Up @@ -87,8 +88,8 @@ func (m *Model) GotoBottom() {
}

// SetActiveBorderColors sets the active border colors.
func (m *Model) SetActiveBorderColor(color string) {
m.ActiveBorderColor = color
func (m *Model) ShowAlternateBorder(show bool) {
m.AlternateBorder = show
}

// GetWidth returns the width of the pane.
Expand All @@ -111,12 +112,25 @@ func (m Model) View() string {
borderColor := m.InactiveBorderColor
border := lipgloss.NormalBorder()
padding := 1
alternateBorder := lipgloss.Border{
Top: "-",
Bottom: "-",
Left: "|",
Right: "|",
TopLeft: "*",
TopRight: "*",
BottomLeft: "*",
BottomRight: "*",
}

if m.Borderless {
border = lipgloss.HiddenBorder()
}

// If the pane is active, use the active border color.
if m.AlternateBorder {
border = alternateBorder
}

if m.IsActive {
borderColor = m.ActiveBorderColor
}
Expand Down
15 changes: 12 additions & 3 deletions internal/ui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// A moveDirItemMsg is received any time a file or directory has been moved.
case moveDirItemMsg:
// Set active color back to default.
m.primaryPane.SetActiveBorderColor(m.appConfig.Colors.Pane.ActiveBorderColor)
m.primaryPane.ShowAlternateBorder(false)
m.dirTree.SetContent(msg)
m.primaryPane.SetContent(m.dirTree.View())
m.statusBar.SetContent(
Expand Down Expand Up @@ -440,9 +440,18 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, m.keys.EnterMoveMode):
if !m.showCommandBar && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 0 {
m.inMoveMode = true
m.primaryPane.SetActiveBorderColor(constants.Colors.Blue)
m.primaryPane.ShowAlternateBorder(true)
m.initialMoveDirectory, _ = directory.GetWorkingDirectory()
m.itemToMove = m.dirTree.GetSelectedFile()
m.statusBar.SetContent(
m.dirTree.GetTotalFiles(),
m.dirTree.GetCursor(),
m.appConfig.Settings.ShowIcons,
m.showCommandBar,
m.inMoveMode,
m.dirTree.GetSelectedFile(),
m.itemToMove,
)
}

// Zip up the currently selected item.
Expand Down Expand Up @@ -495,7 +504,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.statusBar.BlurCommandBar()
m.statusBar.ResetCommandBar()
m.secondaryPane.GotoTop()
m.primaryPane.SetActiveBorderColor(m.appConfig.Colors.Pane.ActiveBorderColor)
m.primaryPane.ShowAlternateBorder(false)
m.secondaryPane.SetContent(lipgloss.NewStyle().
Width(m.secondaryPane.GetWidth() - m.secondaryPane.Style.GetHorizontalFrameSize()).
Render(m.help.View(m.keys)),
Expand Down

0 comments on commit 117be11

Please sign in to comment.