ui

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: ISC Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const Overlay = "/overlay"

Variables

View Source
var ColorDefault = vaxis.Color(0)
View Source
var ColorGreen = vaxis.IndexColor(2)
View Source
var ColorRed = vaxis.IndexColor(9)

Functions

func DecodeImage

func DecodeImage(r io.Reader) (image.Image, string, error)

func IsSplitRune

func IsSplitRune(r rune) bool

func New

func New(config Config) (ui *UI, colors ConfigColors, err error)

func NotifyStart

func NotifyStart(opened func(*NotifyEvent))

func NotifyStop

func NotifyStop()

Types

type BufferList

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

func NewBufferList

func NewBufferList(ui *UI) BufferList

NewBufferList returns a new BufferList. Call Resize() once before using it.

func (*BufferList) Add

func (bs *BufferList) Add(netID, netName, title string) (i int, added bool)

func (*BufferList) AddLine

func (bs *BufferList) AddLine(netID, title string, line Line)

func (*BufferList) AddLines

func (bs *BufferList) AddLines(netID, title string, before, after []Line)

func (*BufferList) Buffer

func (bs *BufferList) Buffer(i int) (netID, title string, ok bool)

func (*BufferList) CloseOverlay

func (bs *BufferList) CloseOverlay()

func (*BufferList) Current

func (bs *BufferList) Current() (netID, title string)

func (*BufferList) DrawHorizontalBufferList

func (bs *BufferList) DrawHorizontalBufferList(vx *Vaxis, x0, y0, width int, offset *int)

func (*BufferList) DrawTimeline

func (bs *BufferList) DrawTimeline(ui *UI, x0, y0, nickColWidth int)

func (*BufferList) DrawVerticalBufferList

func (bs *BufferList) DrawVerticalBufferList(vx *Vaxis, x0, y0, width, height int, offset *int)

func (*BufferList) FilterBuffers

func (bs *BufferList) FilterBuffers(enable bool, query string)

func (*BufferList) Focused

func (bs *BufferList) Focused() bool

func (*BufferList) GetLeftMost

func (bs *BufferList) GetLeftMost(screenWidth int) int

func (*BufferList) GetMuted

func (bs *BufferList) GetMuted(netID, title string) bool

func (*BufferList) GetPinned

func (bs *BufferList) GetPinned(netID, title string) bool

func (*BufferList) HasOverlay

func (bs *BufferList) HasOverlay() bool

func (*BufferList) Highlights

func (bs *BufferList) Highlights() int

func (*BufferList) HorizontalBufferOffset

func (bs *BufferList) HorizontalBufferOffset(x int, offset int) int

func (*BufferList) LinesAboveOffset

func (bs *BufferList) LinesAboveOffset() int

LinesAboveOffset returns a rough approximate of the number of lines above the offset (that is, starting from the bottom of the screen, up to the first line).

func (*BufferList) Next

func (bs *BufferList) Next()

func (*BufferList) NextUnread

func (bs *BufferList) NextUnread()

func (*BufferList) OpenOverlay

func (bs *BufferList) OpenOverlay()

func (*BufferList) Previous

func (bs *BufferList) Previous()

func (*BufferList) PreviousUnread

func (bs *BufferList) PreviousUnread()

func (*BufferList) Remove

func (bs *BufferList) Remove(netID, title string) bool

func (*BufferList) RemoveNetwork

func (bs *BufferList) RemoveNetwork(netID string)

func (*BufferList) ResizeTimeline

func (bs *BufferList) ResizeTimeline(tlInnerWidth, tlHeight, textWidth int)

func (*BufferList) ScrollDown

func (bs *BufferList) ScrollDown(n int)

func (*BufferList) ScrollDownHighlight

func (bs *BufferList) ScrollDownHighlight() bool

func (*BufferList) ScrollTopicLeft

func (bs *BufferList) ScrollTopicLeft(n int)

func (*BufferList) ScrollTopicRight

func (bs *BufferList) ScrollTopicRight(n int)

func (*BufferList) ScrollUp

func (bs *BufferList) ScrollUp(n int)

func (*BufferList) ScrollUpHighlight

func (bs *BufferList) ScrollUpHighlight() bool

func (*BufferList) SetFocused

func (bs *BufferList) SetFocused(focused bool)

func (*BufferList) SetMuted

func (bs *BufferList) SetMuted(netID, title string, muted bool)

func (*BufferList) SetPinned

func (bs *BufferList) SetPinned(netID, title string, pinned bool)

func (*BufferList) SetRead

func (bs *BufferList) SetRead(netID, title string, timestamp time.Time)

func (*BufferList) SetTopic

func (bs *BufferList) SetTopic(netID, title string, topic StyledString)

func (*BufferList) To

func (bs *BufferList) To(i int) bool

func (*BufferList) UpdateRead

func (bs *BufferList) UpdateRead() (netID, title string, timestamp time.Time)

func (*BufferList) VerticalBufferOffset

func (bs *BufferList) VerticalBufferOffset(y int, offset int) int

type ColorScheme

type ColorScheme struct {
	Type   ColorSchemeType
	Others vaxis.Color
	Self   vaxis.Color
}

type ColorSchemeType

type ColorSchemeType int
const (
	ColorSchemeBase ColorSchemeType = iota
	ColorSchemeExtended
	ColorSchemeFixed
)

type Completion

type Completion struct {
	Async   any // not nil if this completion is asynchronously loading values
	AsyncID int

	StartIdx  int
	EndIdx    int
	Text      []rune
	Display   []rune
	CursorIdx int // in runes
}

type Config

type Config struct {
	NickColWidth      int
	ChanColWidth      int
	ChanColEnabled    bool
	MemberColWidth    int
	MemberColEnabled  bool
	TextMaxWidth      int
	AutoComplete      func(cursorIdx int, text []rune) []Completion
	Mouse             bool
	MergeLine         func(former *Line, addition Line)
	Colors            ConfigColors
	LocalIntegrations bool
	WithConsole       console.Console
	WithTTY           string
}

type ConfigColors

type ConfigColors struct {
	Gray   vaxis.Color
	Status vaxis.Color
	Prompt vaxis.Color
	Unread vaxis.Color
	Nicks  ColorScheme
}

type Editor

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

Editor is the text field where the user writes messages and commands.

func NewEditor

func NewEditor(ui *UI) Editor

NewEditor returns a new Editor. Call Resize() once before using it.

func (*Editor) AsyncCompletions

func (e *Editor) AsyncCompletions(id int, cs []Completion)

func (*Editor) AutoComplete

func (e *Editor) AutoComplete() (ok bool)

func (*Editor) BackSearch

func (e *Editor) BackSearch()

func (*Editor) Clear

func (e *Editor) Clear() bool

func (*Editor) Content

func (e *Editor) Content() []rune

Content result must not be modified.

func (*Editor) Down

func (e *Editor) Down()

func (*Editor) Draw

func (e *Editor) Draw(vx *Vaxis, x0, y int, hint string)

func (*Editor) Empty

func (e *Editor) Empty() bool

func (*Editor) End

func (e *Editor) End()

func (*Editor) Enter

func (e *Editor) Enter() bool

func (*Editor) Flush

func (e *Editor) Flush() string

func (*Editor) Home

func (e *Editor) Home()

func (*Editor) Left

func (e *Editor) Left()

func (*Editor) LeftWord

func (e *Editor) LeftWord()

func (*Editor) PutRune

func (e *Editor) PutRune(r rune)

func (*Editor) RemCluster

func (e *Editor) RemCluster() (ok bool)

func (*Editor) RemClusterForward

func (e *Editor) RemClusterForward() (ok bool)

func (*Editor) RemWord

func (e *Editor) RemWord() (ok bool)

func (*Editor) Resize

func (e *Editor) Resize(width int)

func (*Editor) Right

func (e *Editor) Right()

func (*Editor) RightWord

func (e *Editor) RightWord()

func (*Editor) Set

func (e *Editor) Set(text string)

func (*Editor) Up

func (e *Editor) Up()

type Line

type Line struct {
	At        time.Time
	Head      string
	Body      StyledString
	HeadColor vaxis.Color
	Notify    NotifyType
	Highlight bool
	Readable  bool
	Mergeable bool
	Data      interface{}
	// contains filtered or unexported fields
}

func (*Line) IsZero

func (l *Line) IsZero() bool

func (*Line) NewLines

func (l *Line) NewLines(vx *Vaxis, width int) []int

NewLines returns the offsets, in bytes, where the line should be split.

type NotifyEvent

type NotifyEvent struct {
	NetID  string
	Buffer string
}

type NotifyType

type NotifyType int
const (
	NotifyNone NotifyType = iota
	NotifyUnread
	NotifyHighlight
)

type StyledString

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

func IRCString

func IRCString(raw string) StyledString

func PlainSprintf

func PlainSprintf(format string, a ...interface{}) StyledString

func PlainString

func PlainString(s string) StyledString

func Styled

func Styled(s string, style vaxis.Style) StyledString

func (StyledString) ParseURLs

func (s StyledString) ParseURLs() StyledString

func (StyledString) String

func (s StyledString) String() string

type StyledStringBuilder

type StyledStringBuilder struct {
	strings.Builder
	// contains filtered or unexported fields
}

func (*StyledStringBuilder) AddStyle

func (sb *StyledStringBuilder) AddStyle(start int, style vaxis.Style)

func (*StyledStringBuilder) Reset

func (sb *StyledStringBuilder) Reset()

func (*StyledStringBuilder) SetStyle

func (sb *StyledStringBuilder) SetStyle(style vaxis.Style)

func (*StyledStringBuilder) StyledString

func (sb *StyledStringBuilder) StyledString() StyledString

func (*StyledStringBuilder) WriteStyledString

func (sb *StyledStringBuilder) WriteStyledString(s StyledString)

type UI

type UI struct {
	Events chan any
	// contains filtered or unexported fields
}

func (*UI) AddBuffer

func (ui *UI) AddBuffer(netID, netName, title string) (i int, added bool)

func (*UI) AddLine

func (ui *UI) AddLine(netID, buffer string, line Line)

func (*UI) AddLines

func (ui *UI) AddLines(netID, buffer string, before, after []Line)

func (*UI) AsyncCompletions

func (ui *UI) AsyncCompletions(id int, cs []Completion)

func (*UI) Beep

func (ui *UI) Beep()

func (*UI) Buffer

func (ui *UI) Buffer(i int) (netID, title string, ok bool)

func (*UI) ChannelColClicked

func (ui *UI) ChannelColClicked() bool

func (*UI) ChannelWidth

func (ui *UI) ChannelWidth() int

func (*UI) Click

func (ui *UI) Click(x, y int, event vaxis.Mouse)

func (*UI) ClickBuffer

func (ui *UI) ClickBuffer(i int)

func (*UI) ClickChannelCol

func (ui *UI) ClickChannelCol(v bool)

func (*UI) ClickMember

func (ui *UI) ClickMember(i int)

func (*UI) ClickMemberCol

func (ui *UI) ClickMemberCol(v bool)

func (*UI) ClickedBuffer

func (ui *UI) ClickedBuffer() int

func (*UI) ClickedMember

func (ui *UI) ClickedMember() int

func (*UI) Close

func (ui *UI) Close()

func (*UI) CloseOverlay

func (ui *UI) CloseOverlay()

func (*UI) CurrentBuffer

func (ui *UI) CurrentBuffer() (netID, title string)

func (*UI) Draw

func (ui *UI) Draw(members []irc.Member)

func (*UI) Exit

func (ui *UI) Exit()

func (*UI) FilterBuffers

func (ui *UI) FilterBuffers(enable bool, query string)

func (*UI) Focused

func (ui *UI) Focused() bool

func (*UI) GetMuted

func (ui *UI) GetMuted(netID, buffer string) bool

func (*UI) GetPinned

func (ui *UI) GetPinned(netID, buffer string) bool

func (*UI) GoToBufferNo

func (ui *UI) GoToBufferNo(i int)

func (*UI) HasEvent

func (ui *UI) HasEvent(x, y int) bool

func (*UI) HasOverlay

func (ui *UI) HasOverlay() bool

func (*UI) Highlights

func (ui *UI) Highlights() int

func (*UI) HorizontalBufferOffset

func (ui *UI) HorizontalBufferOffset(x int) int

func (*UI) IdentColor

func (ui *UI) IdentColor(scheme ColorScheme, ident string, self bool) vaxis.Color

func (*UI) IdentString

func (ui *UI) IdentString(scheme ColorScheme, ident string, self bool) StyledString

func (*UI) ImageReady

func (ui *UI) ImageReady() bool

func (*UI) InputAutoComplete

func (ui *UI) InputAutoComplete() (ok bool)

func (*UI) InputBackSearch

func (ui *UI) InputBackSearch()

func (*UI) InputBackspace

func (ui *UI) InputBackspace() (ok bool)

func (*UI) InputClear

func (ui *UI) InputClear() bool

func (*UI) InputContent

func (ui *UI) InputContent() []rune

InputContent result must not be modified.

func (*UI) InputDelete

func (ui *UI) InputDelete() (ok bool)

func (*UI) InputDeleteWord

func (ui *UI) InputDeleteWord() (ok bool)

func (*UI) InputDown

func (ui *UI) InputDown()

func (*UI) InputEnd

func (ui *UI) InputEnd()

func (*UI) InputEnter

func (ui *UI) InputEnter() bool

InputEnter returns true if the event was eaten

func (*UI) InputFlush

func (ui *UI) InputFlush() (content string)

func (*UI) InputHome

func (ui *UI) InputHome()

func (*UI) InputLeft

func (ui *UI) InputLeft()

func (*UI) InputLeftWord

func (ui *UI) InputLeftWord()

func (*UI) InputRight

func (ui *UI) InputRight()

func (*UI) InputRightWord

func (ui *UI) InputRightWord()

func (*UI) InputRune

func (ui *UI) InputRune(r rune)

func (*UI) InputSet

func (ui *UI) InputSet(text string)

func (*UI) InputUp

func (ui *UI) InputUp()

func (*UI) JumpBuffer

func (ui *UI) JumpBuffer(sub string) bool

func (*UI) JumpBufferIndex

func (ui *UI) JumpBufferIndex(i int) bool

func (*UI) JumpBufferNetwork

func (ui *UI) JumpBufferNetwork(netID, buffer string) bool

func (*UI) LinesAboveOffset

func (ui *UI) LinesAboveOffset() int

func (*UI) MemberColClicked

func (ui *UI) MemberColClicked() bool

func (*UI) MemberOffset

func (ui *UI) MemberOffset() int

func (*UI) MemberWidth

func (ui *UI) MemberWidth() int

func (*UI) NextBuffer

func (ui *UI) NextBuffer()

func (*UI) NextUnreadBuffer

func (ui *UI) NextUnreadBuffer()

func (*UI) Notify

func (ui *UI) Notify(title string, body string)

func (*UI) OpenOverlay

func (ui *UI) OpenOverlay(hint string)

func (*UI) PreviousBuffer

func (ui *UI) PreviousBuffer()

func (*UI) PreviousUnreadBuffer

func (ui *UI) PreviousUnreadBuffer()

func (*UI) RemoveBuffer

func (ui *UI) RemoveBuffer(netID, title string)

func (*UI) RemoveNetworkBuffers

func (ui *UI) RemoveNetworkBuffers(netID string)

func (*UI) Resize

func (ui *UI) Resize()

func (*UI) ResizeChannelCol

func (ui *UI) ResizeChannelCol(x int)

func (*UI) ResizeMemberCol

func (ui *UI) ResizeMemberCol(x int)

func (*UI) ScrollChannelDownBy

func (ui *UI) ScrollChannelDownBy(n int)

func (*UI) ScrollChannelUpBy

func (ui *UI) ScrollChannelUpBy(n int)

func (*UI) ScrollDown

func (ui *UI) ScrollDown()

func (*UI) ScrollDownBy

func (ui *UI) ScrollDownBy(n int)

func (*UI) ScrollDownHighlight

func (ui *UI) ScrollDownHighlight() bool

func (*UI) ScrollMemberDownBy

func (ui *UI) ScrollMemberDownBy(n int)

func (*UI) ScrollMemberUpBy

func (ui *UI) ScrollMemberUpBy(n int)

func (*UI) ScrollToBuffer

func (ui *UI) ScrollToBuffer()

func (*UI) ScrollTopicLeftBy

func (ui *UI) ScrollTopicLeftBy(n int)

func (*UI) ScrollTopicRightBy

func (ui *UI) ScrollTopicRightBy(n int)

func (*UI) ScrollUp

func (ui *UI) ScrollUp()

func (*UI) ScrollUpBy

func (ui *UI) ScrollUpBy(n int)

func (*UI) ScrollUpHighlight

func (ui *UI) ScrollUpHighlight() bool

func (*UI) SetColorTheme

func (ui *UI) SetColorTheme(mode vaxis.ColorThemeMode)

func (*UI) SetFocused

func (ui *UI) SetFocused(focused bool)

func (*UI) SetMouseShape

func (ui *UI) SetMouseShape(shape vaxis.MouseShape)

func (*UI) SetMuted

func (ui *UI) SetMuted(netID, buffer string, muted bool)

func (*UI) SetPinned

func (ui *UI) SetPinned(netID, buffer string, pinned bool)

func (*UI) SetPrompt

func (ui *UI) SetPrompt(prompt StyledString)

func (*UI) SetRead

func (ui *UI) SetRead(netID, buffer string, timestamp time.Time)

func (*UI) SetStatus

func (ui *UI) SetStatus(status string)

func (*UI) SetTitle

func (ui *UI) SetTitle(title string)

func (*UI) SetTopic

func (ui *UI) SetTopic(netID, buffer string, topic StyledString)

func (*UI) ShouldExit

func (ui *UI) ShouldExit() bool

func (*UI) ShowImage

func (ui *UI) ShowImage(img image.Image) bool

func (*UI) Size

func (ui *UI) Size() (int, int)

func (*UI) ToggleChannelList

func (ui *UI) ToggleChannelList()

func (*UI) ToggleMemberList

func (ui *UI) ToggleMemberList()

func (*UI) UpdateRead

func (ui *UI) UpdateRead() (netID, buffer string, timestamp time.Time)

func (*UI) VerticalBufferOffset

func (ui *UI) VerticalBufferOffset(y int) int

type Vaxis

type Vaxis struct {
	*vaxis.Vaxis
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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