Skip to content

fn color_picker #

fn color_picker(opts ColorPickerOptions) ?Color

color_picker opens an RGBA color picker dialog and returns the selected color or none if the selection was canceled. Optionally, it takes a color and opacity argument. color sets the dialogs initial color. opacity can be set to false to disable the opacity slider on Linux.

fn file_dialog #

fn file_dialog(opts FileDialogOptions) ?string

file_dialog opens a file dialog and returns the selected path or none if the selection was canceled.

fn message #

fn message(message string, opts MessageOptions) bool

message launches a message box and returns true if OK or Yes was pressed.

fn open_dir #

fn open_dir(opts FileOpenOptions) !(string, []string)

open_dir opens a file dialog and returns the path of the selected directory and a list of its contents. Optionally, path can be specified as the default folder the dialog will attempt to open in. It returns an error if the selection was cancelled or if reading the directory contents fails.

fn open_file #

fn open_file(opts FileOpenOptions) !os.File

open_file opens a file dialog and returns the os.File of the selected file. Optionally, path can be specified as the default folder the dialog will attempt to open in. It returns an error if the selection was cancelled or if reading the file fails.

fn prompt #

fn prompt(message string, opts PromptOptions) ?string

prompt launches an input prompt with an "OK" and "Cancel" button.

fn read_file #

fn read_file(opts FileOpenOptions) !string

read_file opens a file dialog and reads the file contents of the selected file. Optionally, path can be specified as the default folder the dialog will attempt to open in. It returns an error if the selection was cancelled or if reading the file fails.

fn save_file #

fn save_file(content string, opts FileSaveOptions) !

save_file opens a file dialog and saves the given content to the selected path. Optionally, path can be specified as the default folder the dialog will attempt to open in. filename can be provided to set the default text that will appear in the filename input. It returns an error if the selection was canceled or if writing the file fails.

type Color #

type Color = C.osdialog_color

Color represents an RGBA color struct.

Examples

c := Color{
	r: 93
	g: 135
	b: 191
	a: 255
}
color_picker(color: Color{93, 135, 191, 255})

enum FileAction #

enum FileAction {
	open
	open_dir
	save
}

enum MessageButtons #

enum MessageButtons {
	ok
	ok_cancel
	yes_no
}

enum MessageLevel #

enum MessageLevel {
	info
	warning
	error
}

struct ColorPickerOptions #

@[params]
struct ColorPickerOptions {
pub:
	color   Color = Color{ // is the initial color.
		r: rand.u8()
		g: rand.u8()
		b: rand.u8()
		a: 255
	}
	opacity bool = true // can be set to `false` to disable the opacity slider on Linux.
}

struct FileDialogOptions #

@[params]
struct FileDialogOptions {
pub:
	action   FileAction
	path     string // is the default folder the dialog will attempt to open in.
	filename string // is the default text that will appear in the filename input. Only when the action is `.save`.
}

struct FileOpenOptions #

@[params]
struct FileOpenOptions {
pub:
	path string // is the default folder the dialog will attempt to open in.
}

struct FileSaveOptions #

@[params]
struct FileSaveOptions {
pub:
	path     string // is the default folder the dialog will attempt to open in.
	filename string // is the default text that will appear in the filename input.
}

struct MessageOptions #

@[params]
struct MessageOptions {
pub:
	level   MessageLevel
	buttons MessageButtons
}

struct PromptOptions #

@[params]
struct PromptOptions {
pub:
	level MessageLevel
	text  string // is the initial input text.
}