Documentation
¶
Overview ¶
Package app holds ZPad's state and builds its window.
Index ¶
- Constants
- Variables
- func CleanupPreviewCache()
- func NoteFrame(d time.Duration)
- func SetThemeSource(id string)
- func SetVersion(v string)
- func SetupLogging(dir string) string
- func TextExtensions() []string
- type App
- func (a *App) Attach(win *mygo.Window)
- func (a *App) BeforeQuit(e *mygo.QuitEvent)
- func (a *App) CloseActiveTab()
- func (a *App) CloseTab(paneIdx, i int)
- func (a *App) ConvertCase(mode caseconv.Mode)
- func (a *App) HandleOpenFile(path string)
- func (a *App) HandleSecondInstance(args []string, dir string)
- func (a *App) InstallMenu()
- func (a *App) NewFile()
- func (a *App) OpenActiveInBrowser()
- func (a *App) OpenCommandLine(args []string)
- func (a *App) OpenFileDialog()
- func (a *App) OpenFolderDialog()
- func (a *App) OpenLog()
- func (a *App) OpenPaths(paths []string)
- func (a *App) Prepare()
- func (a *App) Redo()
- func (a *App) ReopenWithEncoding(kind encoding.Kind)
- func (a *App) RestoreSession()
- func (a *App) SaveActive()
- func (a *App) SaveAsActive()
- func (a *App) SaveWithEncoding(kind encoding.Kind)
- func (a *App) SelectLanguage(lang *editor.Language)
- func (a *App) SetAppIcon(data []byte)
- func (a *App) SetError(msg string)
- func (a *App) SetErrorToast(title, detail string)
- func (a *App) SetLineEnding(eol string)
- func (a *App) SetToast(msg string)
- func (a *App) ShowActiveInFileManager()
- func (a *App) ToggleMarkdownPreview()
- func (a *App) Undo()
- func (a *App) View(c *ui.Context)
- type Document
- type Pane
- type Tab
Constants ¶
const (
LogName = "zpad.log"
)
The diagnostic log, next to the settings: what mygo says of the renderer it chose, and how long the app's frames and file operations take. A Windows build is a GUI program without a console, so what mygo prints there would otherwise be lost.
const MenuBarHeight = 32
MenuBarHeight is the height of the menu bar Windows draws as its title bar. main.go passes it as mygo.WindowOptions.TitleBarHeight, so the system's window buttons fill the same band.
Variables ¶
var Version = "dev"
Version is the version the status bar and the About dialog show. main sets it from mygo.json, which mygo build links in: that file is the app's only version, so a release bumps one file. It is "dev" until then, as under go test or go run.
Functions ¶
func CleanupPreviewCache ¶ added in v0.8.0
func CleanupPreviewCache()
CleanupPreviewCache removes any temporary directory created for remote Markdown preview images.
func NoteFrame ¶ added in v0.2.0
NoteFrame records how long a frame took to build and paint, and writes a summary when frames have been running slow. It times the app's own work on the main thread, not the GPU's present: a summary points at the editor, while a log quiet through a stuttering window points at the renderer.
func SetThemeSource ¶
func SetThemeSource(id string)
SetThemeSource applies a theme's appearance to the native window chrome before App.Run and when the theme changes: a named theme keeps the light or dark title bar it is built on, "system" follows the desktop.
func SetVersion ¶ added in v0.2.0
func SetVersion(v string)
SetVersion records the version mygo build or mygo dev linked in; an empty one, as from a plain go build, keeps the default.
func SetupLogging ¶ added in v0.2.0
SetupLogging sends the standard logger to dir/zpad.log and to stderr, so that what mygo logs survives a build without a console, and returns the path it opened. It returns "" when logging is off (ZPAD_LOG=off) or the file cannot be written: logging never keeps the editor from starting. ZPAD_LOG names another file.
func TextExtensions ¶
func TextExtensions() []string
TextExtensions returns the extensions the open dialog offers as text.
Types ¶
type App ¶
type App struct {
Settings settings.Settings
SettingsDir string
// LogPath is where SetupLogging writes, "" when logging is off.
LogPath string
// Dark reports whether the current theme is built on a dark palette.
// Settings.Theme says which theme it is.
Dark bool
// contains filtered or unexported fields
}
App is the state the window shows.
func (*App) BeforeQuit ¶
BeforeQuit asks to save before the application quits.
func (*App) ConvertCase ¶
ConvertCase changes the case of the active tab's selections.
func (*App) HandleOpenFile ¶
HandleOpenFile opens a file the system asks the app to show. Before the window exists, it keeps the path for Attach.
func (*App) HandleSecondInstance ¶
HandleSecondInstance opens what a later launch was asked to open and brings this window forward. Windows and Linux start a process per file opened from the file manager, whose command line arrives here; that process exits at once.
func (*App) NewFile ¶
func (a *App) NewFile()
NewFile adds an untitled document. The menu's CmdOrCtrl+N runs it with no frame of the view around it, so it asks for the frame that shows the tab.
func (*App) OpenActiveInBrowser ¶ added in v0.2.0
func (a *App) OpenActiveInBrowser()
OpenActiveInBrowser opens the active tab's file in the system browser. Unsaved changes are saved first, so the browser shows what the editor shows.
func (*App) OpenCommandLine ¶
OpenCommandLine opens the files and folders this process was started with, skipping flags.
func (*App) OpenFileDialog ¶
func (a *App) OpenFileDialog()
OpenFileDialog asks for files and opens them.
func (*App) OpenFolderDialog ¶
func (a *App) OpenFolderDialog()
OpenFolderDialog asks for a workspace directory.
func (*App) OpenLog ¶ added in v0.2.0
func (a *App) OpenLog()
OpenLog opens the diagnostic log in a tab: what mygo said of the renderer, the files opened, and the frames that ran slow.
func (*App) Prepare ¶
func (a *App) Prepare()
Prepare marks the app as running and resolves the system appearance. Call it on the main thread once the app is ready, before the window.
func (*App) ReopenWithEncoding ¶
ReopenWithEncoding reads the active file again as kind.
func (*App) RestoreSession ¶
func (a *App) RestoreSession()
RestoreSession loads the workspace of the last launch, when the user asked for it, and the unsaved text kept for this launch, whether they asked to restore the session or not.
func (*App) SaveAsActive ¶
func (a *App) SaveAsActive()
SaveAsActive saves the active tab under another name.
func (*App) SaveWithEncoding ¶
SaveWithEncoding saves the active tab in kind.
func (*App) SelectLanguage ¶ added in v0.5.1
SelectLanguage gives the active untitled document the language chosen in the status bar, which changes its highlight, the name its save starts from, and whether it can be previewed as Markdown. A file that already has a path takes its language from that path, so renaming it is how its highlight changes.
func (*App) SetAppIcon ¶ added in v0.2.0
SetAppIcon gives the About dialog the icon the app embeds. mygo build reads the same PNG for the app's own icon, and mygo.json's resourcesExclude keeps it out of the app, so that no file beside the app carries it: the binary does.
func (*App) SetError ¶
SetError shows an error in the status bar, for a failure that has no better home: one the user must act on while its document is open.
Actions that end, as opening a file does, tell with SetErrorToast instead, so that a message the user cannot act on does not stay.
func (*App) SetErrorToast ¶ added in v0.2.0
SetErrorToast tells near the bottom of the window that something the user asked for did not happen: title says what, detail why, and it goes away on its own.
func (*App) SetLineEnding ¶
SetLineEnding converts every line of the active tab to eol.
func (*App) ShowActiveInFileManager ¶
func (a *App) ShowActiveInFileManager()
ShowActiveInFileManager reveals the active file in the system file manager.
func (*App) ToggleMarkdownPreview ¶ added in v0.2.0
func (a *App) ToggleMarkdownPreview()
ToggleMarkdownPreview shows the active Markdown tab as rendered Markdown, or returns it to the editor.
type Document ¶
type Document struct {
ID string
Path string
Buffer *editor.Buffer
Encoding encoding.Kind
// Language is the file's language, shown in the status bar; the buffer
// gets it only when the file is short enough to highlight.
Language *editor.Language
Size int64
ModTime time.Time
ReadOnly bool
// UntitledSeq is the number the document was created with, for the name
// its save dialog starts from; 0 for a document with a path.
UntitledSeq int
// DraftID names the recovery copy of the document's unsaved text. It
// stays the same across renames and saves, so that a copy is dropped or
// rewritten rather than looked for by path.
DraftID string
// contains filtered or unexported fields
}
Document is an open file and the text the editor edits.
func (*Document) DisplayPath ¶
DisplayPath is the path relative to root when it is inside it.
func (*Document) Name ¶
name is what the tab, the title and the prompts call the document: a saved file by its file name, an untitled one by the number it was created with. The number stays as the other tabs close, so that a prompt naming one points at it rather than at whichever tab moved into its place.
func (*Document) PreviewText ¶ added in v0.2.0
PreviewText returns the buffer's text, copied only when it has changed.
Source Files
¶
- about_ui.go
- actions.go
- app.go
- browser.go
- case.go
- close.go
- diff.go
- diff_ui.go
- document.go
- drafts.go
- external.go
- fileops.go
- fileops_ui.go
- icons.go
- language.go
- log.go
- menu.go
- menubar.go
- preview.go
- preview_image.go
- search.go
- search_ui.go
- selections.go
- session.go
- settings_ui.go
- shortcut.go
- snippets.go
- snippets_ui.go
- tools.go
- view.go
- vim.go