跳转到内容

std.os.uefi.protocol.simple_text_output

标准库Zig 0.17.0官方原文
源码std/os/uefi/protocol/simple_text_output.zig

第 1 行

std.os.uefi.protocol.simple_text_output.cc

别名

第 5 行

别名目标 std.os.uefi.cc

std.os.uefi.protocol.simple_text_output.Guid

别名

第 3 行

别名目标 std.os.uefi.Guid

std.os.uefi.protocol.simple_text_output.SimpleTextOutput

容器

第 8 行

字符输出设备

字段

_reset: *const fn (*SimpleTextOutput, bool) callconv(cc) Status
_output_string: *const fn (*SimpleTextOutput, [*:0]const u16) callconv(cc) Status
_test_string: *const fn (*const SimpleTextOutput, [*:0]const u16) callconv(cc) Status
_query_mode: *const fn (*const SimpleTextOutput, usize, *usize, *usize) callconv(cc) Status
_set_mode: *const fn (*SimpleTextOutput, usize) callconv(cc) Status
_set_attribute: *const fn (*SimpleTextOutput, usize) callconv(cc) Status
_clear_screen: *const fn (*SimpleTextOutput) callconv(cc) Status
_set_cursor_position: *const fn (*SimpleTextOutput, usize, usize) callconv(cc) Status
_enable_cursor: *const fn (*SimpleTextOutput, bool) callconv(cc) Status
mode: *Mode

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.arrow_down

常量

第 198 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.arrow_up

常量

第 197 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.Attribute

容器

第 200 行

字段

foreground: ForegroundColor = .white
background: BackgroundColor = .black

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.Attribute.BackgroundColor

容器

第 223 行

字段

black
blue
green
cyan
red
magenta
brown
lightgray

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.Attribute.ForegroundColor

容器

第 204 行

字段

black
blue
green
cyan
red
magenta
brown
lightgray
darkgray
lightblue
lightgreen
lightcyan
lightred
lightmagenta
yellow
white

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.blockelement_full_block

常量

第 191 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.blockelement_light_shade

常量

第 192 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_down_horizontal

常量

第 184 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_down_left

常量

第 169 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_down_right

常量

第 166 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_horizontal

常量

第 162 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_up_horizontal

常量

第 187 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_up_left

常量

第 175 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_up_right

常量

第 172 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_vertical

常量

第 163 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_vertical_horizontal

常量

第 190 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_vertical_left

常量

第 181 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_double_vertical_right

常量

第 178 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_down_double_horizontal

常量

第 183 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_down_double_left

常量

第 168 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_down_double_right

常量

第 165 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_down_horizontal

常量

第 159 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_down_horizontal_double

常量

第 182 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_down_left

常量

第 154 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_down_left_double

常量

第 167 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_down_right

常量

第 153 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_down_right_double

常量

第 164 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_horizontal

常量

第 151 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_up_double_horizontal

常量

第 186 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_up_double_left

常量

第 174 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_up_double_right

常量

第 171 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_up_horizontal

常量

第 160 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_up_horizontal_double

常量

第 185 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_up_left

常量

第 156 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_up_left_double

常量

第 173 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_up_right

常量

第 155 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_up_right_double

常量

第 170 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical

常量

第 152 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical_double_horizontal

常量

第 189 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical_double_left

常量

第 180 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical_double_right

常量

第 177 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical_horizontal

常量

第 161 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical_horizontal_double

常量

第 188 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical_left

常量

第 158 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical_left_double

常量

第 179 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical_right

常量

第 157 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.boxdraw_vertical_right_double

常量

第 176 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.clearScreen

函数

第 110 行

将输出设备的显示内容清除为当前选定的背景色。

pub fn clearScreen(self: *SimpleTextOutput) ClearScreenError!void

参数

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.ClearScreenError

错误集合

第 34 行

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.enableCursor

函数

第 134 行

显示或隐藏光标。

pub fn enableCursor(self: *SimpleTextOutput, visible: bool) EnableCursorError!void

参数

self: *SimpleTextOutput
visible: bool

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.EnableCursorError

错误集合

第 42 行

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.geometricshape_down_triangle

常量

第 195 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.geometricshape_left_triangle

常量

第 196 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.geometricshape_right_triangle

常量

第 194 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.geometricshape_up_triangle

常量

第 193 行

u16

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.Geometry

容器

第 244 行

字段

columns: usize
rows: usize

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.guid

常量

第 143 行

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.Mode

容器

第 235 行

字段

max_mode: u32
mode: u32
attribute: i32
cursor_column: i32
cursor_row: i32
cursor_visible: bool

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.outputString

函数

第 59 行

向输出设备写入字符串。

成功写入字符串时返回 true,遇到未知字形时返回 false。

pub fn outputString(self: *SimpleTextOutput, msg: [*:0]const u16) OutputStringError!bool

参数

self: *SimpleTextOutput
msg: [*:0]const u16

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.OutputStringError

错误集合

第 21 行

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.queryMode

函数

第 79 行

返回输出设备支持的可用文本模式信息。

pub fn queryMode(self: *const SimpleTextOutput, mode_number: usize) QueryModeError!Geometry

参数

self: *const SimpleTextOutput
mode_number: usize

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.QueryModeError

错误集合

第 25 行

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.reset

函数

第 48 行

重置文本输出设备硬件。

pub fn reset(self: *SimpleTextOutput, verify: bool) ResetError!void

参数

self: *SimpleTextOutput
verify: bool

错误

DeviceError
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.ResetError

错误集合

第 20 行

错误

DeviceError
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.setAttribute

函数

第 100 行

设置 outputString() 和 clearScreen() 函数使用的背景色与前景色。

pub fn setAttribute(self: *SimpleTextOutput, attribute: Attribute) SetAttributeError!void

参数

self: *SimpleTextOutput
attribute: Attribute

错误

DeviceError
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.SetAttributeError

错误集合

第 33 行

错误

DeviceError
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.setCursorPosition

函数

第 120 行

设置光标位置的当前坐标。

pub fn setCursorPosition( self: *SimpleTextOutput, column: usize, row: usize, ) SetCursorPositionError!void

参数

self: *SimpleTextOutput
column: usize
row: usize

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.SetCursorPositionError

错误集合

第 38 行

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.setMode

函数

第 90 行

将输出设备设置为指定模式。

pub fn setMode(self: *SimpleTextOutput, mode_number: usize) SetModeError!void

参数

self: *SimpleTextOutput
mode_number: usize

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.SetModeError

错误集合

第 29 行

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_output.SimpleTextOutput.testString

函数

第 70 行

验证字符串中的所有字符均可输出到目标设备。

pub fn testString(self: *const SimpleTextOutput, msg: [*:0]const u16) uefi.UnexpectedError!bool

参数

self: *const SimpleTextOutput
msg: [*:0]const u16

错误

Unexpected

std.os.uefi.protocol.simple_text_output.Status

别名

第 4 行

别名目标 std.os.uefi.Status

std.os.uefi.protocol.simple_text_output.std

别名

第 1 行

别名目标 std

std.os.uefi.protocol.simple_text_output.uefi

别名

第 2 行

别名目标 std.os.uefi

源码

std/os/uefi/protocol/simple_text_output.zig

const std = @import("std");
const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;

/// 字符输出设备
pub const SimpleTextOutput = extern struct {
    _reset: *const fn (*SimpleTextOutput, bool) callconv(cc) Status,
    _output_string: *const fn (*SimpleTextOutput, [*:0]const u16) callconv(cc) Status,
    _test_string: *const fn (*const SimpleTextOutput, [*:0]const u16) callconv(cc) Status,
    _query_mode: *const fn (*const SimpleTextOutput, usize, *usize, *usize) callconv(cc) Status,
    _set_mode: *const fn (*SimpleTextOutput, usize) callconv(cc) Status,
    _set_attribute: *const fn (*SimpleTextOutput, usize) callconv(cc) Status,
    _clear_screen: *const fn (*SimpleTextOutput) callconv(cc) Status,
    _set_cursor_position: *const fn (*SimpleTextOutput, usize, usize) callconv(cc) Status,
    _enable_cursor: *const fn (*SimpleTextOutput, bool) callconv(cc) Status,
    mode: *Mode,

    pub const ResetError = uefi.UnexpectedError || error{DeviceError};
    pub const OutputStringError = uefi.UnexpectedError || error{
        DeviceError,
        Unsupported,
    };
    pub const QueryModeError = uefi.UnexpectedError || error{
        DeviceError,
        Unsupported,
    };
    pub const SetModeError = uefi.UnexpectedError || error{
        DeviceError,
        Unsupported,
    };
    pub const SetAttributeError = uefi.UnexpectedError || error{DeviceError};
    pub const ClearScreenError = uefi.UnexpectedError || error{
        DeviceError,
        Unsupported,
    };
    pub const SetCursorPositionError = uefi.UnexpectedError || error{
        DeviceError,
        Unsupported,
    };
    pub const EnableCursorError = uefi.UnexpectedError || error{
        DeviceError,
        Unsupported,
    };

    /// 重置文本输出设备硬件。
    pub fn reset(self: *SimpleTextOutput, verify: bool) ResetError!void {
        switch (self._reset(self, verify)) {
            .success => {},
            .device_error => return error.DeviceError,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 向输出设备写入字符串。
    ///
    /// 成功写入字符串时返回 `true`,遇到未知字形时返回 `false`。
    pub fn outputString(self: *SimpleTextOutput, msg: [*:0]const u16) OutputStringError!bool {
        switch (self._output_string(self, msg)) {
            .success => return true,
            .warn_unknown_glyph => return false,
            .device_error => return error.DeviceError,
            .unsupported => return error.Unsupported,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 验证字符串中的所有字符均可输出到目标设备。
    pub fn testString(self: *const SimpleTextOutput, msg: [*:0]const u16) uefi.UnexpectedError!bool {
        switch (self._test_string(self, msg)) {
            .success => return true,
            .unsupported => return false,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 返回输出设备支持的可用文本模式信息。
    pub fn queryMode(self: *const SimpleTextOutput, mode_number: usize) QueryModeError!Geometry {
        var geo: Geometry = undefined;
        switch (self._query_mode(self, mode_number, &geo.columns, &geo.rows)) {
            .success => return geo,
            .device_error => return error.DeviceError,
            .unsupported => return error.Unsupported,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 将输出设备设置为指定模式。
    pub fn setMode(self: *SimpleTextOutput, mode_number: usize) SetModeError!void {
        switch (self._set_mode(self, mode_number)) {
            .success => {},
            .device_error => return error.DeviceError,
            .unsupported => return error.Unsupported,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 设置 outputString() 和 clearScreen() 函数使用的背景色与前景色。
    pub fn setAttribute(self: *SimpleTextOutput, attribute: Attribute) SetAttributeError!void {
        const attr_as_num: u8 = @bitCast(attribute);
        switch (self._set_attribute(self, @intCast(attr_as_num))) {
            .success => {},
            .device_error => return error.DeviceError,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 将输出设备的显示内容清除为当前选定的背景色。
    pub fn clearScreen(self: *SimpleTextOutput) ClearScreenError!void {
        switch (self._clear_screen(self)) {
            .success => {},
            .device_error => return error.DeviceError,
            .unsupported => return error.Unsupported,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 设置光标位置的当前坐标。
    pub fn setCursorPosition(
        self: *SimpleTextOutput,
        column: usize,
        row: usize,
    ) SetCursorPositionError!void {
        switch (self._set_cursor_position(self, column, row)) {
            .success => {},
            .device_error => return error.DeviceError,
            .unsupported => return error.Unsupported,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 显示或隐藏光标。
    pub fn enableCursor(self: *SimpleTextOutput, visible: bool) EnableCursorError!void {
        switch (self._enable_cursor(self, visible)) {
            .success => {},
            .device_error => return error.DeviceError,
            .unsupported => return error.Unsupported,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    pub const guid align(8) = Guid{
        .time_low = 0x387477c2,
        .time_mid = 0x69c7,
        .time_high_and_version = 0x11d2,
        .clock_seq_high_and_reserved = 0x8e,
        .clock_seq_low = 0x39,
        .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
    };
    pub const boxdraw_horizontal: u16 = 0x2500;
    pub const boxdraw_vertical: u16 = 0x2502;
    pub const boxdraw_down_right: u16 = 0x250c;
    pub const boxdraw_down_left: u16 = 0x2510;
    pub const boxdraw_up_right: u16 = 0x2514;
    pub const boxdraw_up_left: u16 = 0x2518;
    pub const boxdraw_vertical_right: u16 = 0x251c;
    pub const boxdraw_vertical_left: u16 = 0x2524;
    pub const boxdraw_down_horizontal: u16 = 0x252c;
    pub const boxdraw_up_horizontal: u16 = 0x2534;
    pub const boxdraw_vertical_horizontal: u16 = 0x253c;
    pub const boxdraw_double_horizontal: u16 = 0x2550;
    pub const boxdraw_double_vertical: u16 = 0x2551;
    pub const boxdraw_down_right_double: u16 = 0x2552;
    pub const boxdraw_down_double_right: u16 = 0x2553;
    pub const boxdraw_double_down_right: u16 = 0x2554;
    pub const boxdraw_down_left_double: u16 = 0x2555;
    pub const boxdraw_down_double_left: u16 = 0x2556;
    pub const boxdraw_double_down_left: u16 = 0x2557;
    pub const boxdraw_up_right_double: u16 = 0x2558;
    pub const boxdraw_up_double_right: u16 = 0x2559;
    pub const boxdraw_double_up_right: u16 = 0x255a;
    pub const boxdraw_up_left_double: u16 = 0x255b;
    pub const boxdraw_up_double_left: u16 = 0x255c;
    pub const boxdraw_double_up_left: u16 = 0x255d;
    pub const boxdraw_vertical_right_double: u16 = 0x255e;
    pub const boxdraw_vertical_double_right: u16 = 0x255f;
    pub const boxdraw_double_vertical_right: u16 = 0x2560;
    pub const boxdraw_vertical_left_double: u16 = 0x2561;
    pub const boxdraw_vertical_double_left: u16 = 0x2562;
    pub const boxdraw_double_vertical_left: u16 = 0x2563;
    pub const boxdraw_down_horizontal_double: u16 = 0x2564;
    pub const boxdraw_down_double_horizontal: u16 = 0x2565;
    pub const boxdraw_double_down_horizontal: u16 = 0x2566;
    pub const boxdraw_up_horizontal_double: u16 = 0x2567;
    pub const boxdraw_up_double_horizontal: u16 = 0x2568;
    pub const boxdraw_double_up_horizontal: u16 = 0x2569;
    pub const boxdraw_vertical_horizontal_double: u16 = 0x256a;
    pub const boxdraw_vertical_double_horizontal: u16 = 0x256b;
    pub const boxdraw_double_vertical_horizontal: u16 = 0x256c;
    pub const blockelement_full_block: u16 = 0x2588;
    pub const blockelement_light_shade: u16 = 0x2591;
    pub const geometricshape_up_triangle: u16 = 0x25b2;
    pub const geometricshape_right_triangle: u16 = 0x25ba;
    pub const geometricshape_down_triangle: u16 = 0x25bc;
    pub const geometricshape_left_triangle: u16 = 0x25c4;
    pub const arrow_up: u16 = 0x2591;
    pub const arrow_down: u16 = 0x2593;

    pub const Attribute = packed struct(u8) {
        foreground: ForegroundColor = .white,
        background: BackgroundColor = .black,

        pub const ForegroundColor = enum(u4) {
            black,
            blue,
            green,
            cyan,
            red,
            magenta,
            brown,
            lightgray,
            darkgray,
            lightblue,
            lightgreen,
            lightcyan,
            lightred,
            lightmagenta,
            yellow,
            white,
        };

        pub const BackgroundColor = enum(u4) {
            black,
            blue,
            green,
            cyan,
            red,
            magenta,
            brown,
            lightgray,
        };
    };

    pub const Mode = extern struct {
        max_mode: u32, // 指定为有符号数
        mode: u32, // 指定为有符号数
        attribute: i32,
        cursor_column: i32,
        cursor_row: i32,
        cursor_visible: bool,
    };

    pub const Geometry = struct {
        columns: usize,
        rows: usize,
    };
};