-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from shalldie/feat-gitee
Feat gitee
- Loading branch information
Showing
18 changed files
with
314 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ output | |
__debug_bin | ||
# debug env | ||
*.env | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package dialog | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"strings" | ||
|
||
"github.com/charmbracelet/bubbles/list" | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/shalldie/gog/gs" | ||
) | ||
|
||
// https://github.com/charmbracelet/bubbletea/blob/master/examples/list-simple/main.go | ||
|
||
var ( | ||
itemStyle = lipgloss.NewStyle().PaddingLeft(4) | ||
selectedItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(lipgloss.Color("170")) | ||
) | ||
|
||
type selectItem string | ||
|
||
func (i selectItem) FilterValue() string { return "" } | ||
|
||
type itemDelegate struct{} | ||
|
||
func (d itemDelegate) Height() int { return 1 } | ||
func (d itemDelegate) Spacing() int { return 0 } | ||
func (d itemDelegate) Update(_ tea.Msg, _ *list.Model) tea.Cmd { return nil } | ||
func (d itemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) { | ||
i, ok := listItem.(selectItem) | ||
if !ok { | ||
return | ||
} | ||
|
||
str := fmt.Sprintf("%d. %s", index+1, i) | ||
|
||
fn := itemStyle.Render | ||
if index == m.Index() { | ||
fn = func(s ...string) string { | ||
return selectedItemStyle.Render("> " + strings.Join(s, " ")) | ||
} | ||
} | ||
|
||
fmt.Fprint(w, fn(str)) | ||
} | ||
|
||
func createSelect() list.Model { | ||
l := list.New([]list.Item{}, itemDelegate{}, 0, 0) | ||
l.SetShowTitle(false) | ||
l.SetFilteringEnabled(false) | ||
l.SetShowPagination(false) | ||
l.SetShowHelp(false) | ||
l.SetShowStatusBar(false) | ||
return l | ||
} | ||
|
||
func (m *DialogModel) updateSelect() { | ||
if len(m.Payload.SelectList) <= 0 { | ||
return | ||
} | ||
items := gs.Map(m.Payload.SelectList, func(pf string, index int) list.Item { | ||
return selectItem(pf) | ||
}) | ||
|
||
m.Select.SetItems(items) | ||
m.Select.SetHeight(len(items) + 3) | ||
} |
Oops, something went wrong.