Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
remove emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
ingbyr committed Sep 13, 2022
1 parent a674dc2 commit a0eb4fb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 37 deletions.
18 changes: 9 additions & 9 deletions gohost/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ func TestGroupService_Save(t *testing.T) {
a := assert.New(t)
service := GetService()
groups := []*Group{
{ID: 001, ParentID: 000, Name: "g-1", Desc: "desc1"},
{ID: 011, ParentID: 001, Name: "g-1-1", Desc: "desc11"},
{ID: 002, ParentID: 000, Name: "g-1", Desc: "desc1"},
{ID: 011, ParentID: 002, Name: "g-1-1", Desc: "desc11"},
{ID: 111, ParentID: 011, Name: "g-1-1-1", Desc: "desc111"},
{ID: 112, ParentID: 011, Name: "g-1-1-2", Desc: "desc112"},
{ID: 012, ParentID: 001, Name: "g-1-2", Desc: "desc12"},
{ID: 013, ParentID: 001, Name: "g-1-3", Desc: "desc13"},
{ID: 012, ParentID: 002, Name: "g-1-2", Desc: "desc12"},
{ID: 013, ParentID: 002, Name: "g-1-3", Desc: "desc13"},
{ID: 131, ParentID: 013, Name: "g-1-3-1", Desc: "desc131"},
{ID: 132, ParentID: 013, Name: "g-1-3-2", Desc: "desc132"},
{ID: 002, ParentID: 000, Name: "g-2", Desc: "desc2"},
{ID: 003, ParentID: 000, Name: "g-3", Desc: "desc3"},
{ID: 031, ParentID: 003, Name: "g-3-1", Desc: "desc31"},
{ID: 032, ParentID: 003, Name: "g-3-2", Desc: "desc32"},
{ID: 004, ParentID: 000, Name: "g-4", Desc: "desc4"},
{ID: 003, ParentID: 000, Name: "g-2", Desc: "desc2"},
{ID: 004, ParentID: 000, Name: "g-3", Desc: "desc3"},
{ID: 031, ParentID: 004, Name: "g-3-1", Desc: "desc31"},
{ID: 032, ParentID: 004, Name: "g-3-2", Desc: "desc32"},
{ID: 005, ParentID: 000, Name: "g-4", Desc: "desc4"},
}
for _, g := range groups {
if err := service.SaveGroup(g); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion gohost/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestService_SaveHost(t *testing.T) {
Name: "host-1000",
Content: []byte("127.0.0.1 localhost"),
Desc: "host1000",
GroupID: 3,
GroupID: 4,
},
&LocalHost{
ID: 1001,
Expand Down
7 changes: 6 additions & 1 deletion tui/editor_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"gohost/gohost"
"gohost/log"
"gohost/tui/keys"
"strings"
)

type EditorView struct {
Expand Down Expand Up @@ -99,7 +100,11 @@ func (v *EditorView) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (v *EditorView) View() string {
var statusLine string
if len(v.statusLine) > v.width {
statusLine = v.statusLine[:v.width-3] + "..."
if v.width <= 3 {
v.statusLine = strings.Repeat(" ", v.width)
} else {
statusLine = v.statusLine[:v.width-3] + "..."
}
} else {
statusLine = v.statusLine
}
Expand Down
2 changes: 1 addition & 1 deletion tui/main_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (m *Model) setFullHelp(state sessionState, kb [][]key.Binding) {

func (m *Model) resizeViews(sizeMsg tea.WindowSizeMsg, cmds *[]tea.Cmd) {
log.Debug(fmt.Sprintf("window w %d h %d", sizeMsg.Width, sizeMsg.Height))
m.leftViewWidth = (sizeMsg.Width - m.styleWidth) / 3
m.leftViewWidth = (sizeMsg.Width - m.styleWidth) / 4
m.rightViewWidth = (sizeMsg.Width - m.styleWidth) - m.leftViewWidth
height := sizeMsg.Height - m.styleHeight - m.shortHelperHeight
log.Debug(fmt.Sprintf("left w %d right w %d h %d", m.leftViewWidth, m.rightViewWidth, height))
Expand Down
50 changes: 25 additions & 25 deletions tui/tree_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,35 @@ func (d *nodeItemDelegate) Render(w io.Writer, m list.Model, index int, item lis
return
}
var str string
if d.width <= 3 {
str = strings.Repeat(".", d.width)
} else {
switch node.Node.(type) {
case *gohost.Group:
var icon string
if node.IsFolded() {
icon = "πŸ“"
} else {
icon = "πŸ“‚"
}
str = strings.Repeat(" ", node.Depth()) + icon + node.Title()
case *gohost.SysHost:
str = strings.Repeat(" ", node.Depth()) + "🐝" + node.Title()
case *gohost.LocalHost:
str = strings.Repeat(" ", node.Depth()) + "πŸ“‘" + node.Title()
case *gohost.RemoteHost:
str = strings.Repeat(" ", node.Depth()) + "🌐" + node.Title()
}
if m.Index() == index {
str = d.selectedStyle.Render("> " + str)
switch node.Node.(type) {
case *gohost.Group:
var icon string
if node.IsFolded() {
icon = "/ "
} else {
str = d.normalStyle.Render(" " + str)
icon = "| "
}
if len(str) > d.width {
str = strings.Repeat(" ", node.Depth()) + icon + node.Title()
case *gohost.SysHost:
str = strings.Repeat(" ", node.Depth()) + "* " + node.Title()
case *gohost.LocalHost:
str = strings.Repeat(" ", node.Depth()) + "# " + node.Title()
case *gohost.RemoteHost:
str = strings.Repeat(" ", node.Depth()) + "@" + node.Title()
}
if m.Index() == index {
str = d.selectedStyle.Render("> " + str)
} else {
str = d.normalStyle.Render(" " + str)
}
if len(str) > d.width {
if d.width <= 3 {
str = strings.Repeat(" ", d.width)
} else {
str = str[:d.width-3] + "..."
} else if len(str) < d.width {
str = str + strings.Repeat(" ", d.width-len(str))
}
} else if len(str) < d.width {
str = str + strings.Repeat(" ", d.width-len(str))
}

_, _ = fmt.Fprint(w, str)
Expand Down

0 comments on commit a0eb4fb

Please sign in to comment.