Skip to main content

rl_lang/interpreter/stdlib/terminal/
mod.rs

1//! `std::term` - full terminal control via crossterm.
2
3mod attr;
4mod clear;
5mod clear_line;
6mod common;
7mod cursor_col;
8mod cursor_row;
9mod enter;
10mod flush;
11mod hide_cursor;
12mod leave;
13mod mouse;
14mod move_cursor;
15mod move_rel;
16mod named_color;
17mod poll;
18mod print;
19mod read_key;
20mod reset_color;
21mod restore_cursor;
22mod save_cursor;
23mod scroll;
24mod set_bg;
25mod set_fg;
26mod set_title;
27mod show_cursor;
28mod size;
29mod sync_output;
30mod wrap;
31
32use crate::interpreter::native::Module;
33
34pub const KEYWORDS: &[&str] = &[
35    "term_enter",
36    "term_leave",
37    "term_clear",
38    "term_clear_line",
39    "term_move",
40    "term_move_up",
41    "term_move_down",
42    "term_move_left",
43    "term_move_right",
44    "term_move_to_col",
45    "term_move_to_row",
46    "term_next_line",
47    "term_prev_line",
48    "term_save_cursor",
49    "term_restore_cursor",
50    "term_hide_cursor",
51    "term_show_cursor",
52    "term_get_size",
53    "term_set_size",
54    "term_set_title",
55    "term_scroll_up",
56    "term_scroll_down",
57    "term_print",
58    "term_flush",
59    "term_set_fg",
60    "term_set_bg",
61    "term_reset_color",
62    "term_fg",
63    "term_bg",
64    "term_bold",
65    "term_dim",
66    "term_italic",
67    "term_underline",
68    "term_blink",
69    "term_reverse",
70    "term_crossed_out",
71    "term_reset_attr",
72    "term_enable_wrap",
73    "term_disable_wrap",
74    "term_begin_sync",
75    "term_end_sync",
76    "term_enable_mouse",
77    "term_disable_mouse",
78    "term_read_key",
79    "term_poll",
80];
81
82pub fn module() -> Module {
83    Module::new("term")
84        // enter / leave
85        .with_function("term_enter", enter::func)
86        .with_function("term_leave", leave::func)
87        // clear
88        .with_function("term_clear", clear::func)
89        .with_function("term_clear_line", clear_line::func)
90        // absolute cursor
91        .with_function("term_move", move_cursor::func)
92        .with_function("term_move_to_col", cursor_col::func)
93        .with_function("term_move_to_row", cursor_row::func)
94        // relative cursor
95        .with_function("term_move_up", move_rel::std_term_move_up)
96        .with_function("term_move_down", move_rel::std_term_move_down)
97        .with_function("term_move_left", move_rel::std_term_move_left)
98        .with_function("term_move_right", move_rel::std_term_move_right)
99        .with_function("term_next_line", move_rel::std_term_next_line)
100        .with_function("term_prev_line", move_rel::std_term_prev_line)
101        // save / restore
102        .with_function("term_save_cursor", save_cursor::func)
103        .with_function("term_restore_cursor", restore_cursor::func)
104        // show / hide
105        .with_function("term_hide_cursor", hide_cursor::func)
106        .with_function("term_show_cursor", show_cursor::func)
107        // size / title
108        .with_function("term_get_size", size::std_term_get_size)
109        .with_function("term_set_size", size::std_term_set_size)
110        .with_function("term_set_title", set_title::func)
111        // scroll
112        .with_function("term_scroll_up", scroll::std_term_scroll_up)
113        .with_function("term_scroll_down", scroll::std_term_scroll_down)
114        // output
115        .with_function("term_print", print::func)
116        .with_function("term_flush", flush::func)
117        // rgb color
118        .with_function("term_set_fg", set_fg::func)
119        .with_function("term_set_bg", set_bg::func)
120        .with_function("term_reset_color", reset_color::func)
121        // named color
122        .with_function("term_fg", named_color::std_term_fg)
123        .with_function("term_bg", named_color::std_term_bg)
124        // attributes
125        .with_function("term_bold", attr::std_term_bold)
126        .with_function("term_dim", attr::std_term_dim)
127        .with_function("term_italic", attr::std_term_italic)
128        .with_function("term_underline", attr::std_term_underline)
129        .with_function("term_blink", attr::std_term_blink)
130        .with_function("term_reverse", attr::std_term_reverse)
131        .with_function("term_crossed_out", attr::std_term_crossed_out)
132        .with_function("term_reset_attr", attr::std_term_reset_attr)
133        // line wrap
134        .with_function("term_enable_wrap", wrap::std_term_enable_wrap)
135        .with_function("term_disable_wrap", wrap::std_term_disable_wrap)
136        // synchronized output
137        .with_function("term_begin_sync", sync_output::std_term_begin_sync)
138        .with_function("term_end_sync", sync_output::std_term_end_sync)
139        // mouse
140        .with_function("term_enable_mouse", mouse::std_term_enable_mouse)
141        .with_function("term_disable_mouse", mouse::std_term_disable_mouse)
142        // input
143        .with_function("term_read_key", read_key::func)
144        .with_function("term_poll", poll::func)
145}