ui

package
v0.0.0-...-77bfbca Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Base window for the app

Miscellaneous small UI components

Edit gist view

Functions for open, close, and save files

Modal for configuring the Github API token

The main file menu

Index

Constants

This section is empty.

Variables

View Source
var CONFIG_DIR_NAME = "./gist-editor" // FIXME: should not be hardcoded

Path under the user's home directory for storing app configuration

View Source
var GITHUB_CONFIG_FILE = path.Join(userConfigPath(), "github-token.txt") // FIXME: Improve file format

Functions

func ButtonContainer

func ButtonContainer(numItems int, objects ...fyne.CanvasObject) *fyne.Container

Button container with padding and right alignment

func FileMenu

func FileMenu(cfg *AppConfig) (*fyne.MainMenu, func(bool))

Returns a main File menu, and a function to toggle Save allowed

func ReadGithubToken

func ReadGithubToken() (string, error)

ReadGithubToken reads and returns the Github API token, if it exists.

func StartUI

func StartUI()

func TitleBox

func TitleBox(msg string) *fyne.Container

Returns a title text container with some spacing

func TitleText

func TitleText(msg string) fyne.Widget

A text component with bold styling TODO: Figure out how to increase font size

Types

type AppConfig

type AppConfig struct {
	App                  *fyne.App
	MainWindow           MainWindow
	ListWindow           *ListView
	Editor               *Editor
	CurrentFile          *GistFile
	GithubConfig         *github.GithubConfig
	GithubSettingsWindow *GithubSettingsWindow
}

Basic app structure, with windows and other data to be passed around

func (*AppConfig) CloseFile

func (cfg *AppConfig) CloseFile()

CloseFile closes the currently open markdown file and closes the editor window

func (*AppConfig) Exit

func (cfg *AppConfig) Exit()

Exit the application

func (*AppConfig) LoadConfig

func (cfg *AppConfig) LoadConfig() error

LoadConfig reads and stores the config settings from the config file

func (*AppConfig) MakeUI

func (cfg *AppConfig) MakeUI()

Generate and store the basic UI components

func (AppConfig) New

func (AppConfig) New() AppConfig

New initializes a new AppConfig instance

func (*AppConfig) NewFile

func (cfg *AppConfig) NewFile()

NewFile opens a new empty markdown editor

func (*AppConfig) OpenFile

func (cfg *AppConfig) OpenFile()

OpenFile opens a local markdown file

func (*AppConfig) RunUI

func (cfg *AppConfig) RunUI()

RunUI starts the application

func (*AppConfig) SaveFile

func (cfg *AppConfig) SaveFile()

SaveFile saves the currently open markdown file locally to disk

func (*AppConfig) SaveFileAs

func (cfg *AppConfig) SaveFileAs()

SaveFileAs saves the currently open markdown file locally to disk with a new filename

func (*AppConfig) ShowEditWindow

func (cfg *AppConfig) ShowEditWindow()

Show the Edit Gists view

func (*AppConfig) ShowGithubTokenModal

func (cfg *AppConfig) ShowGithubTokenModal()

Show the Github Token modal

func (*AppConfig) ShowListWindow

func (cfg *AppConfig) ShowListWindow()

Show the All Gists list view

type Editor

type Editor struct {
	*editor.MultiLineWidget
	Title string

	IsVisible bool
	// contains filtered or unexported fields
}

Editor represents the Gist editor window, and provides methods to update the title & content of the editor widget

func (*Editor) Clear

func (e *Editor) Clear()

Clear resets the title and contents of the text editor

func (*Editor) Content

func (e *Editor) Content() string

GetContent returns the text contents of the editor

func (*Editor) Hide

func (e *Editor) Hide()

Hide hides the editor window

func (Editor) New

func (e Editor) New(cfg *AppConfig) *Editor

New creates a new Editor window and text editor widget

func (*Editor) Redo

func (e *Editor) Redo()

Redo performs an redo operation on the text editor content

func (*Editor) SetContent

func (e *Editor) SetContent(text string)

SetContent sets the contents of the text editor field

func (*Editor) Show

func (e *Editor) Show()

Show displays the editor window

func (*Editor) Undo

func (e *Editor) Undo()

Undo performs an undo operation on the text editor content

type GistFile

type GistFile struct {
	Gist *github.Gist
	// contains filtered or unexported fields
}

A GistFile represents a currently open local or remote markdown file

func (*GistFile) Close

func (g *GistFile) Close()

Close clears a Gist file to empty and marks as closed

func (*GistFile) Save

func (g *GistFile) Save()

Save saves a Gist file to local storage

func (*GistFile) SaveAs

func (g *GistFile) SaveAs()

SaveAs saves a Gist file to local storage with a new filename

type GithubSettingsWindow

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

GithubSettingsWindow is the the Github config settings window

func (GithubSettingsWindow) Hide

func (g GithubSettingsWindow) Hide()

Hide hides the Github settings modal

func (*GithubSettingsWindow) Load

func (g *GithubSettingsWindow) Load(cfg *AppConfig) error

Load reads the github setting from file, and stores to the app config.

func (GithubSettingsWindow) New

New returns a new instance of the GithubSettingsWindow

func (GithubSettingsWindow) Show

func (g GithubSettingsWindow) Show()

Show shows the Github settings modal

type ListView

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

ListView is the user's Gist list view window

func (*ListView) Clear

func (l *ListView) Clear()

Clear clears the list view data

func (*ListView) Hide

func (l *ListView) Hide()

Hide Hides the list view window

func (ListView) New

func (l ListView) New(cfg *AppConfig) *ListView

New creates a ListView instance with list view window

func (*ListView) SetGists

func (l *ListView) SetGists(data []github.Gist)

SetGists populates the list view data

func (*ListView) Show

func (l *ListView) Show()

Show shows the list view window

type MainWindow

type MainWindow struct {
	Window fyne.Window

	SetCanSave func(bool) // toggle whether Save / SaveAs is allowed in the main menu
	// contains filtered or unexported fields
}

MainWindow is the main app window with menu & methods for create & show

func (MainWindow) Close

func (m MainWindow) Close()

Close Closes the main window and starts the application

func (MainWindow) New

func (m MainWindow) New(cfg *AppConfig) MainWindow

New intitializes the main window UI and returns a MainWindow instance

func (MainWindow) ShowAndRun

func (m MainWindow) ShowAndRun()

Show shows the main window and starts the application

type PreviewEditContainer

type PreviewEditContainer struct {
	Content      *container.Split // split view of the preview and edit panes
	ToggleButton *widget.Button   // the toggle Preview button
	// contains filtered or unexported fields
}

PreviewEditContainer is the wrapper for the Preview and Edit panes. It shows the editor on the left, with preview on the right in split view. The toggle method hides the preview pane (moves to collapsed state).

func (PreviewEditContainer) New

func (p PreviewEditContainer) New(
	previewPane *fyne.Container,
	editPane *fyne.Container,
) *PreviewEditContainer

New returns a new PreviewEditContainer with toggle functionality

func (*PreviewEditContainer) PreviewIsVisible

func (p *PreviewEditContainer) PreviewIsVisible() bool

PreviewIsVisible returns whether the markdown preview pane is visible, determined by the offset attribute of the Split element. If the user has adjusted it, it may be visible.

func (*PreviewEditContainer) TogglePreview

func (p *PreviewEditContainer) TogglePreview()

TogglePreview toggles the visiblility of the markdown preview pane.

Jump to

Keyboard shortcuts

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