ui

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 40 Imported by: 0

Documentation

Overview

modified from https://github.com/mistakenelf/teacup/blob/main/image/image.go

Index

Constants

This section is empty.

Variables

View Source
var (
	EmojiLike      = "❤️"
	EmojiEmptyLike = "🤍"
	EmojiRecyle    = "♻️"
	EmojiComment   = "💬"
	EmojiPerson    = "👤"
)
View Source
var (
	Height atomic.Int32
	Width  atomic.Int32
)
View Source
var CastViewKeyMap = casetViewKeymap{
	LikeCast: key.NewBinding(
		key.WithKeys("l"),
		key.WithHelp("l", "like cast"),
	),
	ViewProfile: key.NewBinding(
		key.WithKeys("p"),
		key.WithHelp("p", "view profile"),
	),
	ViewChannel: key.NewBinding(
		key.WithKeys("c"),
		key.WithHelp("c", "view channel"),
	),
	ViewParent: key.NewBinding(
		key.WithKeys("t"),
		key.WithHelp("t", "view parent"),
	),
	Comment: key.NewBinding(
		key.WithKeys("r"),
		key.WithHelp("r", "reply"),
	),
	OpenCast: key.NewBinding(
		key.WithKeys("o"),
		key.WithHelp("o", "open in browser"),
	),
}
View Source
var Fallback = FallbackModel{}
View Source
var FeedKeyMap = feedKeymap{
	ViewCast: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("enter", "view cast"),
	),
	LikeCast: key.NewBinding(
		key.WithKeys("l"),
		key.WithHelp("l", "like cast"),
	),
	ViewProfile: key.NewBinding(
		key.WithKeys("p"),
		key.WithHelp("p", "view profile"),
	),
	ViewChannel: key.NewBinding(
		key.WithKeys("c"),
		key.WithHelp("c", "view channel"),
	),
	OpenCast: key.NewBinding(
		key.WithKeys("o"),
		key.WithHelp("o", "open in browser "),
	),
}
View Source
var GlobalKeyMap = kmap{
	// contains filtered or unexported fields
}
View Source
var NavKeyMap = navKeymap{
	Feed: key.NewBinding(
		key.WithKeys("F", "1"),
		key.WithHelp("F/1", "feed"),
	),
	Publish: key.NewBinding(
		key.WithKeys("P"),
		key.WithHelp("P", "publish cast"),
	),
	QuickSelect: key.NewBinding(
		key.WithKeys("ctrl+k"),
		key.WithHelp("ctrl+k", "quick select"),
	),
	Help: key.NewBinding(
		key.WithKeys("?"),
		key.WithHelp("?", "help"),
	),
	ToggleSidebarFocus: key.NewBinding(
		key.WithKeys("tab"),
		key.WithHelp("tab", "toggle sidebar focus"),
	),
	ToggleSidebarVisibility: key.NewBinding(
		key.WithKeys("shift+tab"),
		key.WithHelp("shift+tab", "toggle sidebar focus"),
	),
	Previous: key.NewBinding(
		key.WithKeys("esc"),
		key.WithHelp("esc", "focus previous"),
	),
	ViewNotifications: key.NewBinding(
		key.WithKeys("N"),
		key.WithHelp("N", "view notifications"),
	),
}

Functions

func CastContent

func CastContent(cast *api.Cast, maxHeight int, imgs ...ImageModel) string

func CastStats

func CastStats(cast *api.Cast, margin int) string

func GetHeight

func GetHeight() int

func GetWidth

func GetWidth() int

func NewStyle

func NewStyle() lipgloss.Style

func OpenURL

func OpenURL(url string) tea.Cmd

func SetHeight

func SetHeight(h int)

func SetWidth

func SetWidth(w int)

func ToString

func ToString(width int, img image.Image) string

ToString converts an image to a string representation of an image.

func UserBio

func UserBio(user *api.User) string

func UsernameHeader

func UsernameHeader(user *api.User, img *ImageModel) string

Types

type App

type App struct {
	// contains filtered or unexported fields
}

func NewApp

func NewApp(cfg *config.Config, ctx *AppContext, pubonly bool) *App

func NewLocalApp

func NewLocalApp(cfg *config.Config, pubInit bool) *App

func NewSSHApp

func NewSSHApp(cfg *config.Config, s ssh.Session, r *lipgloss.Renderer) (*App, error)

func (*App) FocusCast

func (a *App) FocusCast() tea.Cmd

func (*App) FocusChannel

func (a *App) FocusChannel() tea.Cmd

func (*App) FocusFeed

func (a *App) FocusFeed() tea.Cmd

func (*App) FocusHelp added in v0.1.4

func (a *App) FocusHelp()

func (*App) FocusNotifications added in v0.1.4

func (a *App) FocusNotifications() tea.Cmd

func (*App) FocusPrev

func (a *App) FocusPrev() tea.Cmd

func (*App) FocusProfile

func (a *App) FocusProfile() tea.Cmd

func (*App) FocusPublish added in v0.1.4

func (a *App) FocusPublish()

func (*App) FocusQuickSelect added in v0.1.4

func (a *App) FocusQuickSelect()

func (*App) GetFocused

func (a *App) GetFocused() tea.Model

func (*App) GoToCast added in v0.1.4

func (a *App) GoToCast(hash string) tea.Cmd

func (*App) Init

func (a *App) Init() tea.Cmd

func (*App) PublicKey

func (a *App) PublicKey() string

func (*App) SetNavName

func (a *App) SetNavName(name string)

func (*App) ToggleHelp added in v0.1.4

func (a *App) ToggleHelp()

func (*App) Update

func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*App) View

func (a *App) View() string

type AppContext

type AppContext struct {
	// contains filtered or unexported fields
}

type CastFeedItem

type CastFeedItem struct {
	// contains filtered or unexported fields
}

func NewCastFeedItem

func NewCastFeedItem(app *App, cast *api.Cast, compact bool) (*CastFeedItem, tea.Cmd)

NewCastFeedItem displays a cast in compact form within a list implements list.Item (and tea.Model only for updating image)

func (*CastFeedItem) AsRow

func (m *CastFeedItem) AsRow(ch, stats bool) []string

func (*CastFeedItem) Description

func (i *CastFeedItem) Description() string

func (*CastFeedItem) FilterValue

func (i *CastFeedItem) FilterValue() string

func (*CastFeedItem) Init

func (m *CastFeedItem) Init() tea.Cmd

func (*CastFeedItem) Title

func (i *CastFeedItem) Title() string

func (*CastFeedItem) Update

func (m *CastFeedItem) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*CastFeedItem) View

func (m *CastFeedItem) View() string

type CastView

type CastView struct {
	// contains filtered or unexported fields
}

func NewCastView

func NewCastView(app *App, cast *api.Cast) *CastView

func (*CastView) Clear

func (m *CastView) Clear()

func (*CastView) Init

func (m *CastView) Init() tea.Cmd

func (*CastView) LikeCast added in v0.1.4

func (m *CastView) LikeCast() tea.Cmd

func (*CastView) OpenCast added in v0.1.4

func (m *CastView) OpenCast() tea.Cmd

func (*CastView) Reply added in v0.1.4

func (m *CastView) Reply()

func (*CastView) SetCast

func (m *CastView) SetCast(cast *api.Cast) tea.Cmd

func (*CastView) Update

func (m *CastView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*CastView) View

func (m *CastView) View() string

func (*CastView) ViewChannel added in v0.1.4

func (m *CastView) ViewChannel() tea.Cmd

func (*CastView) ViewParent added in v0.1.4

func (m *CastView) ViewParent() tea.Cmd

func (*CastView) ViewProfile added in v0.1.4

func (m *CastView) ViewProfile() tea.Cmd

type FallbackModel

type FallbackModel struct{}

func (FallbackModel) Init

func (m FallbackModel) Init() tea.Cmd

func (FallbackModel) Update

func (m FallbackModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (FallbackModel) View

func (m FallbackModel) View() string

type FeedView

type FeedView struct {
	// contains filtered or unexported fields
}

func NewFeedView

func NewFeedView(app *App, ft feedType) *FeedView

func (*FeedView) Clear

func (m *FeedView) Clear()

func (*FeedView) Init

func (m *FeedView) Init() tea.Cmd

func (*FeedView) LikeCurrentItem

func (m *FeedView) LikeCurrentItem() tea.Cmd

func (*FeedView) OpenCurrentItem

func (m *FeedView) OpenCurrentItem() tea.Cmd

func (*FeedView) SelectCurrentItem

func (m *FeedView) SelectCurrentItem() tea.Cmd

func (*FeedView) SetDefaultParams

func (m *FeedView) SetDefaultParams() tea.Cmd

func (*FeedView) SetDescription

func (m *FeedView) SetDescription(desc string)

func (*FeedView) SetParams

func (m *FeedView) SetParams(req *api.FeedRequest) tea.Cmd

func (*FeedView) SetShowChannel

func (m *FeedView) SetShowChannel(show bool)

func (*FeedView) SetShowStats

func (m *FeedView) SetShowStats(show bool)

func (*FeedView) SetSize

func (m *FeedView) SetSize(w, h int)

func (*FeedView) Update

func (m *FeedView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*FeedView) View

func (m *FeedView) View() string

func (*FeedView) ViewCurrentChannel

func (m *FeedView) ViewCurrentChannel() tea.Cmd

func (*FeedView) ViewCurrentProfile

func (m *FeedView) ViewCurrentProfile() tea.Cmd

type HelpView

type HelpView struct {
	// contains filtered or unexported fields
}

func NewHelpView

func NewHelpView(app *App, km keymap) *HelpView

func (*HelpView) Init

func (m *HelpView) Init() tea.Cmd

func (*HelpView) IsFull

func (m *HelpView) IsFull() bool

func (*HelpView) SetFull

func (m *HelpView) SetFull(full bool)

func (*HelpView) SetSize

func (m *HelpView) SetSize(w, h int)

func (*HelpView) ShortView

func (m *HelpView) ShortView() string

func (*HelpView) Update

func (m *HelpView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*HelpView) View

func (m *HelpView) View() string

type ImageModel

type ImageModel struct {
	Viewport    *viewport.Model
	BorderColor lipgloss.AdaptiveColor
	Active      bool
	Borderless  bool
	URL         string

	ImageString string
	// contains filtered or unexported fields
}

ImageModel represents the properties of a code bubble.

func NewImage

func NewImage(active, borderless bool, borderColor lipgloss.AdaptiveColor) *ImageModel

New creates a new instance of code.

func (*ImageModel) Clear

func (m *ImageModel) Clear()

func (*ImageModel) GotoTop

func (m *ImageModel) GotoTop()

GotoTop jumps to the top of the viewport.

func (ImageModel) Init

func (m ImageModel) Init() tea.Cmd

Init initializes the code bubble.

func (*ImageModel) Matches

func (m *ImageModel) Matches(msg tea.Msg) bool

func (*ImageModel) Render added in v0.1.4

func (m *ImageModel) Render() tea.Cmd

func (*ImageModel) SetBorderColor

func (m *ImageModel) SetBorderColor(color lipgloss.AdaptiveColor)

SetBorderColor sets the current color of the border.

func (*ImageModel) SetBorderless

func (m *ImageModel) SetBorderless(borderless bool)

SetBorderless sets weather or not to show the border.

func (*ImageModel) SetIsActive

func (m *ImageModel) SetIsActive(active bool)

SetIsActive sets if the bubble is currently active

func (*ImageModel) SetSize

func (m *ImageModel) SetSize(w, h int)

func (*ImageModel) SetURL

func (m *ImageModel) SetURL(url string, embed bool)

func (*ImageModel) Update

func (m *ImageModel) Update(msg tea.Msg) (*ImageModel, tea.Cmd)

Update handles updating the UI of a code bubble.

func (ImageModel) View

func (m ImageModel) View() string

View returns a string representation of the code bubble.

type Loading

type Loading struct {
	// contains filtered or unexported fields
}

func NewLoading

func NewLoading() *Loading

func (*Loading) Init

func (m *Loading) Init() tea.Cmd

func (*Loading) IsActive

func (m *Loading) IsActive() bool

func (*Loading) SetActive

func (m *Loading) SetActive(v bool)

func (*Loading) SetSize

func (m *Loading) SetSize(w, h int)

func (*Loading) Update

func (m *Loading) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Loading) View

func (m *Loading) View() string

type NotificationsView added in v0.1.4

type NotificationsView struct {
	// contains filtered or unexported fields
}

func NewNotificationsView added in v0.1.4

func NewNotificationsView(app *App) *NotificationsView

func (*NotificationsView) Active added in v0.1.4

func (m *NotificationsView) Active() bool

func (*NotificationsView) Init added in v0.1.4

func (m *NotificationsView) Init() tea.Cmd

func (*NotificationsView) SetActive added in v0.1.4

func (m *NotificationsView) SetActive(active bool)

func (*NotificationsView) SetSize added in v0.1.4

func (m *NotificationsView) SetSize(w, h int)

func (*NotificationsView) Update added in v0.1.4

func (m *NotificationsView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*NotificationsView) View added in v0.1.4

func (m *NotificationsView) View() string

type Profile

type Profile struct {
	// contains filtered or unexported fields
}

func NewProfile

func NewProfile(app *App) *Profile

func (*Profile) Init

func (m *Profile) Init() tea.Cmd

func (*Profile) SetFID

func (m *Profile) SetFID(fid uint64) tea.Cmd

func (*Profile) Update

func (m *Profile) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Profile) View

func (m *Profile) View() string

type ProfileMsg

type ProfileMsg struct {
	// contains filtered or unexported fields
}

type PublishInput

type PublishInput struct {
	// contains filtered or unexported fields
}

func NewPublishInput

func NewPublishInput(app *App) *PublishInput

func (*PublishInput) Active

func (m *PublishInput) Active() bool

func (*PublishInput) Clear

func (m *PublishInput) Clear()

func (*PublishInput) Init

func (m *PublishInput) Init() tea.Cmd

func (*PublishInput) SetActive

func (m *PublishInput) SetActive(active bool)

func (*PublishInput) SetContext

func (m *PublishInput) SetContext(parent, channelParentUrl string, parentAuthor uint64) tea.Cmd

func (*PublishInput) SetFocus

func (m *PublishInput) SetFocus(focus bool)

func (*PublishInput) SetSize

func (m *PublishInput) SetSize(w, h int)

func (*PublishInput) Update

func (m *PublishInput) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*PublishInput) View

func (m *PublishInput) View() string

type QuickSelect

type QuickSelect struct {
	// contains filtered or unexported fields
}

func NewQuickSelect

func NewQuickSelect(app *App) *QuickSelect

func (*QuickSelect) Active

func (m *QuickSelect) Active() bool

func (*QuickSelect) Init

func (m *QuickSelect) Init() tea.Cmd

func (*QuickSelect) SetActive

func (m *QuickSelect) SetActive(active bool)

func (*QuickSelect) SetOnSelect

func (m *QuickSelect) SetOnSelect(f func(i *selectItem) tea.Cmd)

func (*QuickSelect) SetSize

func (m *QuickSelect) SetSize(w, h int)

func (*QuickSelect) Update

func (m *QuickSelect) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*QuickSelect) View

func (m *QuickSelect) View() string

type RepliesView

type RepliesView struct {
	// contains filtered or unexported fields
}

func NewRepliesView

func NewRepliesView(app *App) *RepliesView

func (*RepliesView) Clear

func (m *RepliesView) Clear()

func (*RepliesView) Init

func (m *RepliesView) Init() tea.Cmd

func (*RepliesView) SetOpHash

func (m *RepliesView) SetOpHash(hash string) tea.Cmd

func (*RepliesView) SetSize

func (m *RepliesView) SetSize(w, h int)

func (*RepliesView) Update

func (m *RepliesView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*RepliesView) View

func (m *RepliesView) View() string

type SelectCastMsg

type SelectCastMsg struct {
	// contains filtered or unexported fields
}

type SelectProfileMsg

type SelectProfileMsg struct {
	// contains filtered or unexported fields
}
type Sidebar struct {
	// contains filtered or unexported fields
}

func NewSidebar

func NewSidebar(app *App) *Sidebar

func (*Sidebar) Active

func (m *Sidebar) Active() bool

func (*Sidebar) Init

func (m *Sidebar) Init() tea.Cmd

func (*Sidebar) SetActive

func (m *Sidebar) SetActive(active bool)

func (*Sidebar) SetSize

func (m *Sidebar) SetSize(w, h int)

func (*Sidebar) Update

func (m *Sidebar) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Sidebar) View

func (m *Sidebar) View() string

type SplashView

type SplashView struct {
	// contains filtered or unexported fields
}

func NewSplashView

func NewSplashView(app *App) *SplashView

func (*SplashView) Active

func (m *SplashView) Active() bool

func (*SplashView) Init

func (m *SplashView) Init() tea.Cmd

func (*SplashView) SetActive

func (m *SplashView) SetActive(active bool)

func (*SplashView) SetInfo

func (m *SplashView) SetInfo(content string)

func (*SplashView) SetSize

func (m *SplashView) SetSize(w, h int)

func (*SplashView) ShowSignin

func (m *SplashView) ShowSignin(v bool)

func (*SplashView) Update

func (m *SplashView) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*SplashView) View

func (m *SplashView) View() string

type StatusLine

type StatusLine struct {
	// contains filtered or unexported fields
}

func NewStatusLine

func NewStatusLine(app *App) *StatusLine

func (*StatusLine) Init

func (m *StatusLine) Init() tea.Cmd

func (*StatusLine) SetSize

func (m *StatusLine) SetSize(width, height int)

func (*StatusLine) Update

func (m *StatusLine) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*StatusLine) View

func (m *StatusLine) View() string

type UpdateSignerMsg

type UpdateSignerMsg struct {
	Signer *api.Signer
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL