text_input

package
v0.0.0-...-1fbd8b4 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TextInput

type TextInput struct {
	client.BaseProxy
	// contains filtered or unexported fields
}

TextInput : text input

An object used for text input. Adds support for text input and input methods to applications. A text_input object is created from a wl_text_input_manager and corresponds typically to a text entry in an application.

Requests are used to activate/deactivate the text_input object and set state information like surrounding and selected text or the content type. The information about entered text is sent to the text_input object via the pre-edit and commit events. Using this interface removes the need for applications to directly process hardware key events and compose text out of them.

Text is generally UTF-8 encoded, indices and lengths are in bytes.

Serials are used to synchronize the state between the text input and an input method. New serials are sent by the text input in the commit_state request and are used by the input method to indicate the known text input state in events like preedit_string, commit_string, and keysym. The text input can then ignore events from the input method which are based on an outdated state (for example after a reset).

Warning! The protocol described in this file is experimental and backward incompatible changes may be made. Backward compatible changes may be added together with the corresponding interface version bump. Backward incompatible changes are done by bumping the version number in the protocol and interface names and resetting the interface version. Once the protocol is to be declared stable, the 'z' prefix and the version number in the protocol and interface names are removed and the interface version number is reset.

func NewTextInput

func NewTextInput(ctx *client.Context) *TextInput

NewTextInput : text input

An object used for text input. Adds support for text input and input methods to applications. A text_input object is created from a wl_text_input_manager and corresponds typically to a text entry in an application.

Requests are used to activate/deactivate the text_input object and set state information like surrounding and selected text or the content type. The information about entered text is sent to the text_input object via the pre-edit and commit events. Using this interface removes the need for applications to directly process hardware key events and compose text out of them.

Text is generally UTF-8 encoded, indices and lengths are in bytes.

Serials are used to synchronize the state between the text input and an input method. New serials are sent by the text input in the commit_state request and are used by the input method to indicate the known text input state in events like preedit_string, commit_string, and keysym. The text input can then ignore events from the input method which are based on an outdated state (for example after a reset).

Warning! The protocol described in this file is experimental and backward incompatible changes may be made. Backward compatible changes may be added together with the corresponding interface version bump. Backward incompatible changes are done by bumping the version number in the protocol and interface names and resetting the interface version. Once the protocol is to be declared stable, the 'z' prefix and the version number in the protocol and interface names are removed and the interface version number is reset.

func (*TextInput) Activate

func (i *TextInput) Activate(seat *client.Seat, surface *client.Surface) error

Activate : request activation

Requests the text_input object to be activated (typically when the text entry gets focus).

The seat argument is a wl_seat which maintains the focus for this activation. The surface argument is a wl_surface assigned to the text_input object and tracked for focus lost. The enter event is emitted on successful activation.

func (*TextInput) CommitState

func (i *TextInput) CommitState(serial uint32) error

CommitState :

serial: used to identify the known state

func (*TextInput) Deactivate

func (i *TextInput) Deactivate(seat *client.Seat) error

Deactivate : request deactivation

Requests the text_input object to be deactivated (typically when the text entry lost focus). The seat argument is a wl_seat which was used for activation.

func (*TextInput) Destroy

func (i *TextInput) Destroy() error

func (*TextInput) Dispatch

func (i *TextInput) Dispatch(opcode uint32, fd int, data []byte)

func (*TextInput) HideInputPanel

func (i *TextInput) HideInputPanel() error

HideInputPanel : hide input panels

Requests input panels (virtual keyboard) to hide.

func (*TextInput) InvokeAction

func (i *TextInput) InvokeAction(button, index uint32) error

InvokeAction :

func (*TextInput) Reset

func (i *TextInput) Reset() error

Reset : reset

Should be called by an editor widget when the input state should be reset, for example after the text was changed outside of the normal input method flow.

func (*TextInput) SetCommitStringHandler

func (i *TextInput) SetCommitStringHandler(f TextInputCommitStringHandlerFunc)

SetCommitStringHandler : sets handler for TextInputCommitStringEvent

func (*TextInput) SetContentType

func (i *TextInput) SetContentType(hint, purpose uint32) error

SetContentType : set content purpose and hint

Sets the content purpose and content hint. While the purpose is the basic purpose of an input field, the hint flags allow to modify some of the behavior.

When no content type is explicitly set, a normal content purpose with default hints (auto completion, auto correction, auto capitalization) should be assumed.

func (*TextInput) SetCursorPositionHandler

func (i *TextInput) SetCursorPositionHandler(f TextInputCursorPositionHandlerFunc)

SetCursorPositionHandler : sets handler for TextInputCursorPositionEvent

func (*TextInput) SetCursorRectangle

func (i *TextInput) SetCursorRectangle(x, y, width, height int32) error

SetCursorRectangle :

func (*TextInput) SetDeleteSurroundingTextHandler

func (i *TextInput) SetDeleteSurroundingTextHandler(f TextInputDeleteSurroundingTextHandlerFunc)

SetDeleteSurroundingTextHandler : sets handler for TextInputDeleteSurroundingTextEvent

func (*TextInput) SetEnterHandler

func (i *TextInput) SetEnterHandler(f TextInputEnterHandlerFunc)

SetEnterHandler : sets handler for TextInputEnterEvent

func (*TextInput) SetInputPanelStateHandler

func (i *TextInput) SetInputPanelStateHandler(f TextInputInputPanelStateHandlerFunc)

SetInputPanelStateHandler : sets handler for TextInputInputPanelStateEvent

func (*TextInput) SetKeysymHandler

func (i *TextInput) SetKeysymHandler(f TextInputKeysymHandlerFunc)

SetKeysymHandler : sets handler for TextInputKeysymEvent

func (*TextInput) SetLanguageHandler

func (i *TextInput) SetLanguageHandler(f TextInputLanguageHandlerFunc)

SetLanguageHandler : sets handler for TextInputLanguageEvent

func (*TextInput) SetLeaveHandler

func (i *TextInput) SetLeaveHandler(f TextInputLeaveHandlerFunc)

SetLeaveHandler : sets handler for TextInputLeaveEvent

func (*TextInput) SetModifiersMapHandler

func (i *TextInput) SetModifiersMapHandler(f TextInputModifiersMapHandlerFunc)

SetModifiersMapHandler : sets handler for TextInputModifiersMapEvent

func (*TextInput) SetPreeditCursorHandler

func (i *TextInput) SetPreeditCursorHandler(f TextInputPreeditCursorHandlerFunc)

SetPreeditCursorHandler : sets handler for TextInputPreeditCursorEvent

func (*TextInput) SetPreeditStringHandler

func (i *TextInput) SetPreeditStringHandler(f TextInputPreeditStringHandlerFunc)

SetPreeditStringHandler : sets handler for TextInputPreeditStringEvent

func (*TextInput) SetPreeditStylingHandler

func (i *TextInput) SetPreeditStylingHandler(f TextInputPreeditStylingHandlerFunc)

SetPreeditStylingHandler : sets handler for TextInputPreeditStylingEvent

func (*TextInput) SetPreferredLanguage

func (i *TextInput) SetPreferredLanguage(language string) error

SetPreferredLanguage : sets preferred language

Sets a specific language. This allows for example a virtual keyboard to show a language specific layout. The "language" argument is an RFC-3066 format language tag.

It could be used for example in a word processor to indicate the language of the currently edited document or in an instant message application which tracks languages of contacts.

func (*TextInput) SetSurroundingText

func (i *TextInput) SetSurroundingText(text string, cursor, anchor uint32) error

SetSurroundingText : sets the surrounding text

Sets the plain surrounding text around the input position. Text is UTF-8 encoded. Cursor is the byte offset within the surrounding text. Anchor is the byte offset of the selection anchor within the surrounding text. If there is no selected text anchor, then it is the same as cursor.

func (*TextInput) SetTextDirectionHandler

func (i *TextInput) SetTextDirectionHandler(f TextInputTextDirectionHandlerFunc)

SetTextDirectionHandler : sets handler for TextInputTextDirectionEvent

func (*TextInput) ShowInputPanel

func (i *TextInput) ShowInputPanel() error

ShowInputPanel : show input panels

Requests input panels (virtual keyboard) to show.

type TextInputCommitStringEvent

type TextInputCommitStringEvent struct {
	Serial uint32
	Text   string
}

TextInputCommitStringEvent : commit

Notify when text should be inserted into the editor widget. The text to commit could be either just a single character after a key press or the result of some composing (pre-edit). It could also be an empty text when some text should be removed (see delete_surrounding_text) or when the input cursor should be moved (see cursor_position).

Any previously set composing text should be removed.

type TextInputCommitStringHandlerFunc

type TextInputCommitStringHandlerFunc func(TextInputCommitStringEvent)

type TextInputContentHint

type TextInputContentHint uint32
const (
	// TextInputContentHintNone : no special behaviour
	TextInputContentHintNone TextInputContentHint = 0x0
	// TextInputContentHintDefault : auto completion, correction and capitalization
	TextInputContentHintDefault TextInputContentHint = 0x7
	// TextInputContentHintPassword : hidden and sensitive text
	TextInputContentHintPassword TextInputContentHint = 0xc0
	// TextInputContentHintAutoCompletion : suggest word completions
	TextInputContentHintAutoCompletion TextInputContentHint = 0x1
	// TextInputContentHintAutoCorrection : suggest word corrections
	TextInputContentHintAutoCorrection TextInputContentHint = 0x2
	// TextInputContentHintAutoCapitalization : switch to uppercase letters at the start of a sentence
	TextInputContentHintAutoCapitalization TextInputContentHint = 0x4
	// TextInputContentHintLowercase : prefer lowercase letters
	TextInputContentHintLowercase TextInputContentHint = 0x8
	// TextInputContentHintUppercase : prefer uppercase letters
	TextInputContentHintUppercase TextInputContentHint = 0x10
	// TextInputContentHintTitlecase : prefer casing for titles and headings (can be language dependent)
	TextInputContentHintTitlecase TextInputContentHint = 0x20
	// TextInputContentHintHiddenText : characters should be hidden
	TextInputContentHintHiddenText TextInputContentHint = 0x40
	// TextInputContentHintSensitiveData : typed text should not be stored
	TextInputContentHintSensitiveData TextInputContentHint = 0x80
	// TextInputContentHintLatin : just latin characters should be entered
	TextInputContentHintLatin TextInputContentHint = 0x100
	// TextInputContentHintMultiline : the text input is multiline
	TextInputContentHintMultiline TextInputContentHint = 0x200
)

TextInputContentHint : content hint

Content hint is a bitmask to allow to modify the behavior of the text input.

func (TextInputContentHint) Name

func (e TextInputContentHint) Name() string

func (TextInputContentHint) String

func (e TextInputContentHint) String() string

func (TextInputContentHint) Value

func (e TextInputContentHint) Value() string

type TextInputContentPurpose

type TextInputContentPurpose uint32
const (
	// TextInputContentPurposeNormal : default input, allowing all characters
	TextInputContentPurposeNormal TextInputContentPurpose = 0
	// TextInputContentPurposeAlpha : allow only alphabetic characters
	TextInputContentPurposeAlpha TextInputContentPurpose = 1
	// TextInputContentPurposeDigits : allow only digits
	TextInputContentPurposeDigits TextInputContentPurpose = 2
	// TextInputContentPurposeNumber : input a number (including decimal separator and sign)
	TextInputContentPurposeNumber TextInputContentPurpose = 3
	// TextInputContentPurposePhone : input a phone number
	TextInputContentPurposePhone TextInputContentPurpose = 4
	// TextInputContentPurposeUrl : input an URL
	TextInputContentPurposeUrl TextInputContentPurpose = 5
	// TextInputContentPurposeEmail : input an email address
	TextInputContentPurposeEmail TextInputContentPurpose = 6
	// TextInputContentPurposeName : input a name of a person
	TextInputContentPurposeName TextInputContentPurpose = 7
	// TextInputContentPurposePassword : input a password (combine with password or sensitive_data hint)
	TextInputContentPurposePassword TextInputContentPurpose = 8
	// TextInputContentPurposeDate : input a date
	TextInputContentPurposeDate TextInputContentPurpose = 9
	// TextInputContentPurposeTime : input a time
	TextInputContentPurposeTime TextInputContentPurpose = 10
	// TextInputContentPurposeDatetime : input a date and time
	TextInputContentPurposeDatetime TextInputContentPurpose = 11
	// TextInputContentPurposeTerminal : input for a terminal
	TextInputContentPurposeTerminal TextInputContentPurpose = 12
)

TextInputContentPurpose : content purpose

The content purpose allows to specify the primary purpose of a text input.

This allows an input method to show special purpose input panels with extra characters or to disallow some characters.

func (TextInputContentPurpose) Name

func (TextInputContentPurpose) String

func (e TextInputContentPurpose) String() string

func (TextInputContentPurpose) Value

func (e TextInputContentPurpose) Value() string

type TextInputCursorPositionEvent

type TextInputCursorPositionEvent struct {
	Index  int32
	Anchor int32
}

TextInputCursorPositionEvent : set cursor to new position

Notify when the cursor or anchor position should be modified.

This event should be handled as part of a following commit_string event.

type TextInputCursorPositionHandlerFunc

type TextInputCursorPositionHandlerFunc func(TextInputCursorPositionEvent)

type TextInputDeleteSurroundingTextEvent

type TextInputDeleteSurroundingTextEvent struct {
	Index  int32
	Length uint32
}

TextInputDeleteSurroundingTextEvent : delete surrounding text

Notify when the text around the current cursor position should be deleted.

Index is relative to the current cursor (in bytes). Length is the length of deleted text (in bytes).

This event should be handled as part of a following commit_string event.

type TextInputDeleteSurroundingTextHandlerFunc

type TextInputDeleteSurroundingTextHandlerFunc func(TextInputDeleteSurroundingTextEvent)

type TextInputEnterEvent

type TextInputEnterEvent struct {
	Surface *client.Surface
}

TextInputEnterEvent : enter event

Notify the text_input object when it received focus. Typically in response to an activate request.

type TextInputEnterHandlerFunc

type TextInputEnterHandlerFunc func(TextInputEnterEvent)

type TextInputInputPanelStateEvent

type TextInputInputPanelStateEvent struct {
	State uint32
}

TextInputInputPanelStateEvent : state of the input panel

Notify when the visibility state of the input panel changed.

type TextInputInputPanelStateHandlerFunc

type TextInputInputPanelStateHandlerFunc func(TextInputInputPanelStateEvent)

type TextInputKeysymEvent

type TextInputKeysymEvent struct {
	Serial    uint32
	Time      uint32
	Sym       uint32
	State     uint32
	Modifiers uint32
}

TextInputKeysymEvent : keysym

Notify when a key event was sent. Key events should not be used for normal text input operations, which should be done with commit_string, delete_surrounding_text, etc. The key event follows the wl_keyboard key event convention. Sym is an XKB keysym, state a wl_keyboard key_state. Modifiers are a mask for effective modifiers (where the modifier indices are set by the modifiers_map event)

type TextInputKeysymHandlerFunc

type TextInputKeysymHandlerFunc func(TextInputKeysymEvent)

type TextInputLanguageEvent

type TextInputLanguageEvent struct {
	Serial   uint32
	Language string
}

TextInputLanguageEvent : language

Sets the language of the input text. The "language" argument is an RFC-3066 format language tag.

type TextInputLanguageHandlerFunc

type TextInputLanguageHandlerFunc func(TextInputLanguageEvent)

type TextInputLeaveEvent

type TextInputLeaveEvent struct{}

TextInputLeaveEvent : leave event

Notify the text_input object when it lost focus. Either in response to a deactivate request or when the assigned surface lost focus or was destroyed.

type TextInputLeaveHandlerFunc

type TextInputLeaveHandlerFunc func(TextInputLeaveEvent)

type TextInputManager

type TextInputManager struct {
	client.BaseProxy
}

TextInputManager : text input manager

A factory for text_input objects. This object is a global singleton.

func NewTextInputManager

func NewTextInputManager(ctx *client.Context) *TextInputManager

NewTextInputManager : text input manager

A factory for text_input objects. This object is a global singleton.

func (*TextInputManager) CreateTextInput

func (i *TextInputManager) CreateTextInput() (*TextInput, error)

CreateTextInput : create text input

Creates a new text_input object.

func (*TextInputManager) Destroy

func (i *TextInputManager) Destroy() error

type TextInputModifiersMapEvent

type TextInputModifiersMapEvent struct {
	Map []byte
}

TextInputModifiersMapEvent : modifiers map

Transfer an array of 0-terminated modifier names. The position in the array is the index of the modifier as used in the modifiers bitmask in the keysym event.

type TextInputModifiersMapHandlerFunc

type TextInputModifiersMapHandlerFunc func(TextInputModifiersMapEvent)

type TextInputPreeditCursorEvent

type TextInputPreeditCursorEvent struct {
	Index int32
}

TextInputPreeditCursorEvent : pre-edit cursor

Sets the cursor position inside the composing text (as byte offset) relative to the start of the composing text. When index is a negative number no cursor is shown.

This event is handled as part of a following preedit_string event.

type TextInputPreeditCursorHandlerFunc

type TextInputPreeditCursorHandlerFunc func(TextInputPreeditCursorEvent)

type TextInputPreeditStringEvent

type TextInputPreeditStringEvent struct {
	Serial uint32
	Text   string
	Commit string
}

TextInputPreeditStringEvent : pre-edit

Notify when a new composing text (pre-edit) should be set around the current cursor position. Any previously set composing text should be removed.

The commit text can be used to replace the preedit text on reset (for example on unfocus).

The text input should also handle all preedit_style and preedit_cursor events occurring directly before preedit_string.

type TextInputPreeditStringHandlerFunc

type TextInputPreeditStringHandlerFunc func(TextInputPreeditStringEvent)

type TextInputPreeditStyle

type TextInputPreeditStyle uint32
const (
	// TextInputPreeditStyleDefault : default style for composing text
	TextInputPreeditStyleDefault TextInputPreeditStyle = 0
	// TextInputPreeditStyleNone : style should be the same as in non-composing text
	TextInputPreeditStyleNone      TextInputPreeditStyle = 1
	TextInputPreeditStyleActive    TextInputPreeditStyle = 2
	TextInputPreeditStyleInactive  TextInputPreeditStyle = 3
	TextInputPreeditStyleHighlight TextInputPreeditStyle = 4
	TextInputPreeditStyleUnderline TextInputPreeditStyle = 5
	TextInputPreeditStyleSelection TextInputPreeditStyle = 6
	TextInputPreeditStyleIncorrect TextInputPreeditStyle = 7
)

TextInputPreeditStyle :

func (TextInputPreeditStyle) Name

func (e TextInputPreeditStyle) Name() string

func (TextInputPreeditStyle) String

func (e TextInputPreeditStyle) String() string

func (TextInputPreeditStyle) Value

func (e TextInputPreeditStyle) Value() string

type TextInputPreeditStylingEvent

type TextInputPreeditStylingEvent struct {
	Index  uint32
	Length uint32
	Style  uint32
}

TextInputPreeditStylingEvent : pre-edit styling

Sets styling information on composing text. The style is applied for length bytes from index relative to the beginning of the composing text (as byte offset). Multiple styles can be applied to a composing text by sending multiple preedit_styling events.

This event is handled as part of a following preedit_string event.

type TextInputPreeditStylingHandlerFunc

type TextInputPreeditStylingHandlerFunc func(TextInputPreeditStylingEvent)

type TextInputTextDirection

type TextInputTextDirection uint32
const (
	// TextInputTextDirectionAuto : automatic text direction based on text and language
	TextInputTextDirectionAuto TextInputTextDirection = 0
	// TextInputTextDirectionLtr : left-to-right
	TextInputTextDirectionLtr TextInputTextDirection = 1
	// TextInputTextDirectionRtl : right-to-left
	TextInputTextDirectionRtl TextInputTextDirection = 2
)

TextInputTextDirection :

func (TextInputTextDirection) Name

func (e TextInputTextDirection) Name() string

func (TextInputTextDirection) String

func (e TextInputTextDirection) String() string

func (TextInputTextDirection) Value

func (e TextInputTextDirection) Value() string

type TextInputTextDirectionEvent

type TextInputTextDirectionEvent struct {
	Serial    uint32
	Direction uint32
}

TextInputTextDirectionEvent : text direction

Sets the text direction of input text.

It is mainly needed for showing an input cursor on the correct side of the editor when there is no input done yet and making sure neutral direction text is laid out properly.

type TextInputTextDirectionHandlerFunc

type TextInputTextDirectionHandlerFunc func(TextInputTextDirectionEvent)

Jump to

Keyboard shortcuts

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