[][src]Trait glk::traits::Base

pub trait Base {
    fn exit(&mut self) -> !;
fn set_interrupt_handler(&mut self, func: Option<unsafe extern "C" fn()>);
fn tick(&mut self);
fn gestalt(&mut self, sel: gestalt, val: u32, arr: &mut [u32]) -> u32;
fn char_to_lower(&mut self, ch: u8) -> u8;
fn char_to_upper(&mut self, ch: u8) -> u8;
fn window_get_root(&mut self) -> winid_t;
fn window_open(
        &mut self,
        split: winid_t,
        method: winmethod,
        size: u32,
        wtype: wintype,
        rock: u32
    ) -> winid_t;
fn window_close(&mut self, win: winid_t) -> stream_result_t;
fn window_get_size(&mut self, win: winid_t) -> (u32, u32);
fn window_set_arrangement(
        &mut self,
        win: winid_t,
        method: winmethod,
        size: u32,
        keywin: winid_t
    );
fn window_get_arrangement(&mut self, win: winid_t) -> (u32, u32, winid_t);
fn window_iterate(&mut self, win: winid_t) -> (winid_t, u32);
fn window_get_rock(&mut self, win: winid_t) -> u32;
fn window_get_type(&mut self, win: winid_t) -> wintype;
fn window_get_parent(&mut self, win: winid_t) -> winid_t;
fn window_get_sibling(&mut self, win: winid_t) -> winid_t;
fn window_clear(&mut self, win: winid_t);
fn window_move_cursor(&mut self, win: winid_t, xpos: u32, ypos: u32);
fn window_get_stream(&mut self, win: winid_t) -> strid_t;
fn window_set_echo_stream(&mut self, win: winid_t, str: strid_t);
fn window_get_echo_stream(&mut self, win: winid_t) -> strid_t;
fn set_window(&mut self, win: winid_t);
fn stream_open_file(
        &mut self,
        fileref: frefid_t,
        fmode: filemode,
        rock: u32
    ) -> strid_t;
fn stream_open_memory(
        &mut self,
        buf: &mut RetainableBuffer<u8>,
        fmode: filemode,
        rock: u32
    ) -> strid_t;
fn stream_close(&mut self, str: strid_t) -> stream_result_t;
fn stream_iterate(&mut self, str: strid_t) -> (strid_t, u32);
fn stream_get_rock(&mut self, str: strid_t) -> u32;
fn stream_set_position(&mut self, str: strid_t, pos: i32, mode: seekmode);
fn stream_get_position(&mut self, str: strid_t) -> u32;
fn stream_set_current(&mut self, str: strid_t);
fn stream_get_current(&mut self) -> strid_t;
fn put_char(&mut self, ch: u8);
fn put_char_stream(&mut self, str: strid_t, ch: u8);
fn put_buffer(&mut self, buf: &[u8]);
fn put_buffer_stream(&mut self, str: strid_t, buf: &[u8]);
fn set_style(&mut self, styl: style);
fn set_style_stream(&mut self, str: strid_t, styl: style);
fn get_char_stream(&mut self, str: strid_t) -> i32;
fn get_line_stream(&mut self, str: strid_t, buf: &mut [u8]) -> u32;
fn get_buffer_stream(&mut self, str: strid_t, buf: &mut [u8]) -> u32;
fn stylehint_set(
        &mut self,
        wtype: wintype,
        styl: style,
        hint: stylehint,
        val: i32
    );
fn stylehint_clear(&mut self, wtype: wintype, styl: style, hint: stylehint);
fn style_distinguish(
        &mut self,
        win: winid_t,
        styl1: style,
        styl2: style
    ) -> u32;
fn style_measure(
        &mut self,
        win: winid_t,
        styl: style,
        hint: stylehint
    ) -> Option<u32>;
fn fileref_create_temp(&mut self, usage: fileusage, rock: u32) -> frefid_t;
fn fileref_create_by_name(
        &mut self,
        usage: fileusage,
        name: &[u8],
        rock: u32
    ) -> frefid_t;
fn fileref_create_by_prompt(
        &mut self,
        usage: fileusage,
        fmode: filemode,
        rock: u32
    ) -> frefid_t;
fn fileref_create_from_fileref(
        &mut self,
        usage: fileusage,
        fref: frefid_t,
        rock: u32
    ) -> frefid_t;
fn fileref_destroy(&mut self, fref: frefid_t);
fn fileref_iterate(&mut self, fref: frefid_t) -> (frefid_t, u32);
fn fileref_get_rock(&mut self, fref: frefid_t) -> u32;
fn fileref_delete_file(&mut self, fref: frefid_t);
fn fileref_does_file_exist(&mut self, fref: frefid_t) -> u32;
fn select(&mut self) -> event_t;
fn select_poll(&mut self) -> event_t;
fn request_timer_events(&mut self, millisecs: u32);
fn request_line_event(
        &mut self,
        win: winid_t,
        buf: &mut RetainableBuffer<u8>,
        initlen: u32
    );
fn request_char_event(&mut self, win: winid_t);
fn request_mouse_event(&mut self, win: winid_t);
fn cancel_line_event(&mut self, win: winid_t) -> event_t;
fn cancel_char_event(&mut self, win: winid_t);
fn cancel_mouse_event(&mut self, win: winid_t); }

Mandatory Glk API functions.

Required methods

fn exit(&mut self) -> !

Shut down program. Does not return to the caller.

fn set_interrupt_handler(&mut self, func: Option<unsafe extern "C" fn()>)

Set interrupt handler (this is called before process shutdown).

  • @note Cannot be invoked through the dispatch layer, and is never called by glulxe.

fn tick(&mut self)

Tick handler. This is intended to be called often by the Glk program,

  • for example between every opcode for a VM interpreter.

fn gestalt(&mut self, sel: gestalt, val: u32, arr: &mut [u32]) -> u32

Query Glk API capabilities. This lets the Glk program knows which functionality is

  • implemented by the library. See gestalt documentation for a list of specific
  • capabilitites.

fn char_to_lower(&mut self, ch: u8) -> u8

Convert one Latin-1 character to lowercase.

fn char_to_upper(&mut self, ch: u8) -> u8

Convert one Latin-1 character to uppercase.

fn window_get_root(&mut self) -> winid_t

This returns the root window. If there are no windows, this returns NULL.

fn window_open(
    &mut self,
    split: winid_t,
    method: winmethod,
    size: u32,
    wtype: wintype,
    rock: u32
) -> winid_t

Open a new window, returning an opaque handle to the window. If no new window could be

  • opened, return NULL.

fn window_close(&mut self, win: winid_t) -> stream_result_t

Close a window.

fn window_get_size(&mut self, win: winid_t) -> (u32, u32)

Get dimensions of a window. May be inexact for text buffers, but not for text grids.

  • Returns (width, height).

fn window_set_arrangement(
    &mut self,
    win: winid_t,
    method: winmethod,
    size: u32,
    keywin: winid_t
)

Change arrangement of windows.

fn window_get_arrangement(&mut self, win: winid_t) -> (u32, u32, winid_t)

Get arrangement of windows. Returns (method, size, keywin)

fn window_iterate(&mut self, win: winid_t) -> (winid_t, u32)

Iterate over windows. Returns (winid, rock)

fn window_get_rock(&mut self, win: winid_t) -> u32

Get rock value for a window.

fn window_get_type(&mut self, win: winid_t) -> wintype

Get the type of a window.

fn window_get_parent(&mut self, win: winid_t) -> winid_t

Get the parent of a window.

fn window_get_sibling(&mut self, win: winid_t) -> winid_t

Get next sibling of a window.

fn window_clear(&mut self, win: winid_t)

Erase the window contents. The meaning of this depends on the window type.

fn window_move_cursor(&mut self, win: winid_t, xpos: u32, ypos: u32)

Set the current cursor position (for text grids).

fn window_get_stream(&mut self, win: winid_t) -> strid_t

Return the stream which is associated with the window.

fn window_set_echo_stream(&mut self, win: winid_t, str: strid_t)

Set the echo stream for a window. The echo stream gets a copy of everything

  • printed to the window.

fn window_get_echo_stream(&mut self, win: winid_t) -> strid_t

Get the echo stream for a window.

fn set_window(&mut self, win: winid_t)

Set current window. This is a shortcut for stream_set_current(window_get_stream(win)).

fn stream_open_file(
    &mut self,
    fileref: frefid_t,
    fmode: filemode,
    rock: u32
) -> strid_t

Open a file as a stream.

fn stream_open_memory(
    &mut self,
    buf: &mut RetainableBuffer<u8>,
    fmode: filemode,
    rock: u32
) -> strid_t

Open a buffer in memory as a stream.

fn stream_close(&mut self, str: strid_t) -> stream_result_t

Close a stream. This does not work for window streams.

fn stream_iterate(&mut self, str: strid_t) -> (strid_t, u32)

Iterate over all streams. Returns (strid, rock).

fn stream_get_rock(&mut self, str: strid_t) -> u32

Get the rock value for a stream.

fn stream_set_position(&mut self, str: strid_t, pos: i32, mode: seekmode)

Move the position of the file pointer in a stream.

fn stream_get_position(&mut self, str: strid_t) -> u32

Get the current position of the file pointer in a stream.

fn stream_set_current(&mut self, str: strid_t)

Set current stream. This is where stream-less commands such as

  • put_char will go.

fn stream_get_current(&mut self) -> strid_t

Get current stream.

fn put_char(&mut self, ch: u8)

Write one character to the current stream.

fn put_char_stream(&mut self, str: strid_t, ch: u8)

Write one character to the specified stream.

fn put_buffer(&mut self, buf: &[u8])

Write a buffer of unicode characters to current stream.

  • @note put_string ends up at this call too.

fn put_buffer_stream(&mut self, str: strid_t, buf: &[u8])

Write a buffer of characters in the specified stream.

  • @note put_string_stream ends up at this call too.

fn set_style(&mut self, styl: style)

Set printing style for current stream.

fn set_style_stream(&mut self, str: strid_t, styl: style)

Set printing style for specified stream.

fn get_char_stream(&mut self, str: strid_t) -> i32

Read a character from the specified stream.

fn get_line_stream(&mut self, str: strid_t, buf: &mut [u8]) -> u32

Read a line of characters from the specified stream.

fn get_buffer_stream(&mut self, str: strid_t, buf: &mut [u8]) -> u32

Read a buffer of characters from the specified stream.

fn stylehint_set(
    &mut self,
    wtype: wintype,
    styl: style,
    hint: stylehint,
    val: i32
)

Set a style hint (per window type). This requests a style to have a certain

  • style property.

fn stylehint_clear(&mut self, wtype: wintype, styl: style, hint: stylehint)

Clear style hint (per window type). This requests a property on the style to be reset to

  • the default.

fn style_distinguish(&mut self, win: winid_t, styl1: style, styl2: style) -> u32

Return whether two styles can be distinguished visually.

fn style_measure(
    &mut self,
    win: winid_t,
    styl: style,
    hint: stylehint
) -> Option<u32>

Return a style property for a style. Returns Some(result) if the value is available, None

  • otherwise.

fn fileref_create_temp(&mut self, usage: fileusage, rock: u32) -> frefid_t

Create a temporary file.

fn fileref_create_by_name(
    &mut self,
    usage: fileusage,
    name: &[u8],
    rock: u32
) -> frefid_t

Create a named file.

fn fileref_create_by_prompt(
    &mut self,
    usage: fileusage,
    fmode: filemode,
    rock: u32
) -> frefid_t

Create a file, prompting the user interactively for the name.

fn fileref_create_from_fileref(
    &mut self,
    usage: fileusage,
    fref: frefid_t,
    rock: u32
) -> frefid_t

Create a new file reference from an existing file reference, but with (possibly) different

  • usage.

fn fileref_destroy(&mut self, fref: frefid_t)

Destroy a file reference.

fn fileref_iterate(&mut self, fref: frefid_t) -> (frefid_t, u32)

Iterate over all file references. Returns (fref, rock).

fn fileref_get_rock(&mut self, fref: frefid_t) -> u32

Get rock for a file reference.

fn fileref_delete_file(&mut self, fref: frefid_t)

Delete a file by reference.

fn fileref_does_file_exist(&mut self, fref: frefid_t) -> u32

Check whether a file exists.

fn select(&mut self) -> event_t

Wait for next event and return it.

fn select_poll(&mut self) -> event_t

Poll (non-blocking) for next event. Return evtype None if

  • there is no event available.
  • The function only checks for Timer, and possibly Arrange and SoundNotify events, not
  • for user input of any kind.

fn request_timer_events(&mut self, millisecs: u32)

Request timer events to be sent every millisecs milliseconds, or cancel

  • if 0.

fn request_line_event(
    &mut self,
    win: winid_t,
    buf: &mut RetainableBuffer<u8>,
    initlen: u32
)

Request a line input event to be sent.

fn request_char_event(&mut self, win: winid_t)

Request a character event to be sent.

fn request_mouse_event(&mut self, win: winid_t)

Request a mouse event to be sent.

fn cancel_line_event(&mut self, win: winid_t) -> event_t

Cancel requested line event.

fn cancel_char_event(&mut self, win: winid_t)

Cancel requested character input event.

fn cancel_mouse_event(&mut self, win: winid_t)

Cancel requested mouse event.

Loading content...

Implementors

Loading content...