package core:text/edit

⌘K
Ctrl+K
or
/

    Types

    Command ¶

    Command :: enum u32 {
    	None, 
    	Undo, 
    	Redo, 
    	New_Line,          // multi-lines
    	Cut, 
    	Copy, 
    	Paste, 
    	Select_All, 
    	Backspace, 
    	Delete, 
    	Delete_Word_Left, 
    	Delete_Word_Right, 
    	Left, 
    	Right, 
    	Up,                // multi-lines
    	Down,              // multi-lines
    	Word_Left, 
    	Word_Right, 
    	Start, 
    	End, 
    	Line_Start, 
    	Line_End, 
    	Select_Left, 
    	Select_Right, 
    	Select_Up,         // multi-lines
    	Select_Down,       // multi-lines
    	Select_Word_Left, 
    	Select_Word_Right, 
    	Select_Start, 
    	Select_End, 
    	Select_Line_Start, 
    	Select_Line_End, 
    }
    Related Procedures With Parameters

    Command_Set ¶

    Command_Set :: distinct bit_set[Command; u32]

    State ¶

    State :: struct {
    	selection:           [2]int,
    	line_start,
    	line_end:            int,
    	// initialized each "frame" with `begin`
    	builder:             ^strings.Builder,
    	// let the caller store the text buffer data
    	up_index,
    	down_index:          int,
    	// undo
    	undo:                [dynamic]^Undo_State,
    	redo:                [dynamic]^Undo_State,
    	undo_text_allocator: runtime.Allocator,
    	id:                  u64,
    	// Timeout information
    	current_time:        time.Tick,
    	last_edit_time:      time.Tick,
    	undo_timeout:        time.Duration,
    	// Set these if you want cut/copy/paste functionality
    	set_clipboard:       proc(user_data: rawptr, text: string) -> (ok: bool),
    	get_clipboard:       proc(user_data: rawptr) -> (text: string, ok: bool),
    	clipboard_user_data: rawptr,
    }
    Related Procedures With Parameters

    Translation ¶

    Translation :: enum u32 {
    	Start, 
    	End, 
    	Left, 
    	Right, 
    	Up, 
    	Down, 
    	Word_Left, 
    	Word_Right, 
    	Word_Start, 
    	Word_End, 
    	Soft_Line_Start, 
    	Soft_Line_End, 
    }
    Related Procedures With Parameters

    Undo_State ¶

    Undo_State :: struct {
    	selection: [2]int,
    	len:       int,
    	text:      [0]u8,
    }

    Constants

    DEFAULT_UNDO_TIMEOUT ¶

    DEFAULT_UNDO_TIMEOUT: time.Duration : 300 * time.Millisecond

    MULTILINE_COMMANDS ¶

    MULTILINE_COMMANDS :: Command_Set{.New_Line, .Up, .Down, .Select_Up, .Select_Down}

    Variables

    This section is empty.

    Procedures

    begin ¶

    begin :: proc(s: ^State, id: u64, builder: ^strings.Builder) {…}
     

    Call at the beginning of each frame

    copy ¶

    copy :: proc(s: ^State) -> bool {…}

    current_selected_text ¶

    current_selected_text :: proc(s: ^State) -> string {…}

    cut ¶

    cut :: proc(s: ^State) -> bool {…}

    delete_to ¶

    delete_to :: proc(s: ^State, t: Translation) {…}

    destroy ¶

    destroy :: proc(s: ^State) {…}

    end ¶

    end :: proc(s: ^State) {…}
     

    Call at the end of each frame

    has_selection ¶

    has_selection :: proc(s: ^State) -> bool {…}

    init ¶

    init :: proc(s: ^State, undo_text_allocator, undo_state_allocator: runtime.Allocator, undo_timeout: time.Duration = DEFAULT_UNDO_TIMEOUT) {…}

    input_runes ¶

    input_runes :: proc(s: ^State, text: []rune) {…}

    input_text ¶

    input_text :: proc(s: ^State, text: string) {…}

    insert ¶

    insert :: proc(s: ^State, at: int, text: string) {…}

    move_to ¶

    move_to :: proc(s: ^State, t: Translation) {…}

    paste ¶

    paste :: proc(s: ^State) -> bool {…}

    perform_command ¶

    perform_command :: proc(s: ^State, cmd: Command) {…}

    remove ¶

    remove :: proc(s: ^State, lo, hi: int) {…}

    select_to ¶

    select_to :: proc(s: ^State, t: Translation) {…}

    selection_delete ¶

    selection_delete :: proc(s: ^State) {…}

    set_text ¶

    set_text :: proc(s: ^State, text: string) {…}

    sorted_selection ¶

    sorted_selection :: proc(s: ^State) -> (lo, hi: int) {…}

    translate_position ¶

    translate_position :: proc(s: ^State, pos: int, t: Translation) -> int {…}

    undo ¶

    undo :: proc(s: ^State, undo, redo: ^[dynamic]^Undo_State) {…}

    undo_check ¶

    undo_check :: proc(s: ^State) {…}

    undo_clear ¶

    undo_clear :: proc(s: ^State, undo: ^[dynamic]^Undo_State) {…}

    undo_state_push ¶

    undo_state_push :: proc(s: ^State, undo: ^[dynamic]^Undo_State) -> runtime.Allocator_Error {…}

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2023-10 (vendor "odin") Windows_amd64 @ 2023-10-03 21:09:46.938592600 +0000 UTC