forgot to commit this
This commit is contained in:
parent
61b930c588
commit
a7f1bbdd19
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
snake.go
|
||||
133
main.go
133
main.go
@ -2,27 +2,38 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"log"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/charmbracelet/ssh"
|
||||
"github.com/charmbracelet/wish"
|
||||
wishtea "github.com/charmbracelet/wish/bubbletea"
|
||||
"log"
|
||||
)
|
||||
|
||||
var asciiArt = []string{}
|
||||
|
||||
type model struct {
|
||||
title string
|
||||
sections []string
|
||||
selected int
|
||||
currentScreen string
|
||||
width int
|
||||
height int
|
||||
mouseX int
|
||||
mouseY int
|
||||
mouseActive bool
|
||||
isClicked bool
|
||||
}
|
||||
|
||||
func initialModel() model {
|
||||
return model{
|
||||
title: "tuff SSH stuff",
|
||||
title: "Đorđe Kšan",
|
||||
sections: []string{"About", "Projects", "Contact"},
|
||||
currentScreen: "menu",
|
||||
mouseActive: true,
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,9 +43,17 @@ func (m model) Init() tea.Cmd {
|
||||
|
||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case tea.WindowSizeMsg:
|
||||
m.width = msg.Width
|
||||
m.height = msg.Height
|
||||
if m.mouseX < 0 || m.mouseX > m.width || m.mouseY < 0 || m.mouseY > m.height {
|
||||
m.mouseActive = false
|
||||
}
|
||||
|
||||
case tea.KeyMsg:
|
||||
|
||||
switch msg.String() {
|
||||
case "q", "ctrl+c", "esc":
|
||||
case "q", "ctrl+c":
|
||||
return m, tea.Quit
|
||||
|
||||
case "up", "k":
|
||||
@ -49,15 +68,29 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
case "enter":
|
||||
m.currentScreen = m.sections[m.selected]
|
||||
|
||||
return m, nil
|
||||
|
||||
case "left", "h":
|
||||
case "right", "l":
|
||||
case "b", "backspace":
|
||||
case "b", "u", "backspace", "esc":
|
||||
m.currentScreen = "menu"
|
||||
return m, nil
|
||||
default:
|
||||
fmt.Println("click")
|
||||
}
|
||||
|
||||
//TODO add mouse logic
|
||||
case tea.MouseMsg:
|
||||
m.mouseX = msg.X
|
||||
m.mouseY = msg.Y
|
||||
m.mouseActive = m.mouseX >= 0 && m.mouseX < m.width && m.mouseY >= 0 && m.mouseY < m.height
|
||||
|
||||
if msg.Button == tea.MouseButtonLeft && msg.Type == tea.MouseEventType(tea.MouseActionRelease) {
|
||||
fmt.Println("mouse click")
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
return m, nil
|
||||
@ -95,25 +128,104 @@ func (m model) View() string {
|
||||
output += sectionStyle.Render("- "+section) + "\n"
|
||||
}
|
||||
}
|
||||
|
||||
output += "\n" + footerStyle.Render("Press q to quit.") + "\n"
|
||||
} else {
|
||||
switch m.currentScreen {
|
||||
case "About":
|
||||
output = titleStyle.Render("About Me") + "\n\n" + "Tbh I don't even know anymore. <3"
|
||||
output = m.renderAbout()
|
||||
|
||||
case "Projects":
|
||||
output = titleStyle.Render("Projects") + "\n\n" + "Here are some projects I’ve worked on..."
|
||||
output = m.renderProjects()
|
||||
case "Contact":
|
||||
output = titleStyle.Render("Contact") + "\n\n" + "Get in touch with me at djordje@ksan.dev."
|
||||
output = m.renderContact()
|
||||
|
||||
}
|
||||
|
||||
output += "\n" + footerStyle.Render("Press b to go back to the menu.") + "\n"
|
||||
}
|
||||
|
||||
output += "\n" + footerStyle.Render("Press q to quit.") + "\n"
|
||||
return lipgloss.Place(
|
||||
m.width,
|
||||
m.height,
|
||||
lipgloss.Center,
|
||||
lipgloss.Center,
|
||||
output,
|
||||
)
|
||||
}
|
||||
|
||||
return output
|
||||
var aboutText = `
|
||||
Tbh I don't even know anymore. <3
|
||||
`
|
||||
|
||||
var contactText = `
|
||||
Get in touch with me at djordje@ksan.dev.
|
||||
`
|
||||
|
||||
var projectsText = `
|
||||
Here are some projects I’ve worked on...
|
||||
`
|
||||
|
||||
var (
|
||||
titleStyle = lipgloss.NewStyle().
|
||||
Bold(true).
|
||||
Foreground(lipgloss.Color("#E2E8F0")).
|
||||
Background(lipgloss.Color("#0F172A")).
|
||||
Padding(0, 3)
|
||||
|
||||
sectionStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#94A3B8"))
|
||||
|
||||
selectedSectionStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#8A1D7D")).
|
||||
Bold(true)
|
||||
|
||||
footerStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#64748B"))
|
||||
|
||||
contentStyle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#FFFFFF"))
|
||||
)
|
||||
|
||||
func (m model) renderAbout() string {
|
||||
var str strings.Builder
|
||||
|
||||
str.WriteString(titleStyle.Render("━━━ About Me ━━━"))
|
||||
str.WriteString("\n")
|
||||
str.WriteString(contentStyle.Render(aboutText))
|
||||
str.WriteString("\n")
|
||||
str.WriteString(footerStyle.Render("esc: back to menu"))
|
||||
|
||||
return str.String()
|
||||
|
||||
}
|
||||
|
||||
func (m model) renderProjects() string {
|
||||
|
||||
var str strings.Builder
|
||||
|
||||
str.WriteString(titleStyle.Render("━━━ Projects ━━━"))
|
||||
str.WriteString("\n")
|
||||
str.WriteString(contentStyle.Render(projectsText))
|
||||
str.WriteString("\n")
|
||||
str.WriteString(footerStyle.Render("esc: back to menu"))
|
||||
|
||||
return str.String()
|
||||
}
|
||||
|
||||
func (m model) renderContact() string {
|
||||
var str strings.Builder
|
||||
|
||||
str.WriteString(titleStyle.Render("━━━ Contact ━━━"))
|
||||
str.WriteString("\n")
|
||||
str.WriteString(contentStyle.Render(contactText))
|
||||
str.WriteString("\n")
|
||||
str.WriteString(footerStyle.Render("esc: back to menu"))
|
||||
|
||||
return str.String()
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
server, _ := wish.NewServer(
|
||||
wish.WithAddress("0.0.0.0:2222"),
|
||||
wish.WithHostKeyPath(".ssh/host_ed25519"),
|
||||
@ -133,5 +245,6 @@ func teaHandler(s ssh.Session) (tea.Model, []tea.ProgramOption) {
|
||||
|
||||
return initialModel(), []tea.ProgramOption{
|
||||
tea.WithAltScreen(),
|
||||
tea.WithMouseCellMotion(),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user