Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
api:term:zh [2022/08/11 10:47]
fight_xing created
api:term:zh [2023/10/20 06:44]
hfsr
Line 1: Line 1:
-Term API+Term(终端) ​API
 ======= =======
- +此API提供了向屏幕输出内容和读取用户输入的简便方法因此你无需再手动操作GPU API实现这些功能。
-**本篇文章的部分/​全部内容还没有进行翻译** +
- +
-Provides a simplified way of writing text to screens and reading user input, so you don't have to manually interact with the GPU API for these cases.+
  
 - `term.isAvailable():​ boolean`  ​ - `term.isAvailable():​ boolean`  ​
-  Returns whether the term API is available for use, i.e. whether a primary ​GPU and screen are present. In other words, whether ​`term.read` ​and `term.write` ​will actually do something.+返回term API是否可用,即是否存在主GPU和屏幕。换言之,`term.read``term.write`函数能否起到实际作用。
 - `term.getViewport():​ number, number, number, number, number, number`  ​ - `term.getViewport():​ number, number, number, number, number, number`  ​
-  ​(new in OpenOS 1.6) +(OpenOS 1.6新加入
-   +获取宽度、高度、x偏移量、y偏移量、x相对坐标、y相对坐标。
-  Gets the width, height, ​offset, ​offset, relative ​x, and relative ​values.+
 - `term.gpu():​ table`  ​ - `term.gpu():​ table`  ​
-  ​(new in OpenOS 1.6) +(OpenOS 1.6新加入
-   +获取term API使用的GPU代理。
-  Gets the gpu proxy used by the term api.+
 - `term.pull([...]):​ ...`  ​ - `term.pull([...]):​ ...`  ​
-  ​(new in OpenOS 1.6) +(OpenOS 1.6新加入
-   +`event.pull`的作用完全一致,接收同样的参数,返回同样的结果。此方法用于在等待事件结果时令光标闪烁。
-  Acts exactly like `event.pull` ​taking the same parameters and returning the same results. This method is used to blink the cursor while waiting for an event result.+
 - `term.getCursor():​ number, number`  ​ - `term.getCursor():​ number, number`  ​
-  Gets the current position of the cursor.+获取光标的当前位置。
 - `term.setCursor(col:​ number, row: number)`  ​ - `term.setCursor(col:​ number, row: number)`  ​
-  Sets the cursor position to the specified coordinates.+将光标位置设定为给定坐标。
 - `term.getCursorBlink():​ boolean`  ​ - `term.getCursorBlink():​ boolean`  ​
-  Gets whether the cursor blink is currently enabled, i.e whether the cursor alternates between the actual ​"pixel" ​displayed at the cursor position and a fully white block every half second.+获取光标闪烁是否启用,即光标是否每隔半秒在其位置实际显示的"像素"和纯白色方块间来回变换。
 - `term.setCursorBlink(enabled:​ boolean)`  ​ - `term.setCursorBlink(enabled:​ boolean)`  ​
-  Sets whether cursor blink should be enabled or not.+设定光标闪烁功能是否启用。
 - `term.clear()`  ​ - `term.clear()`  ​
-  Clears the complete screen and resets the cursor position to (1, 1).+清空整个屏幕,并将光标位置重置为(1, 1)
 - `term.clearLine()`  ​ - `term.clearLine()`  ​
-  Clears the line the cursor is currently on and resets the cursor'​s horizontal position to 1.+清空光标所在的行,并将光标的横坐标重置为1
 - `term.read([history:​ table[, dobreak:​boolean[,​ hint:table or function[, pwchar:​string]]]]):​ string`  ​ - `term.read([history:​ table[, dobreak:​boolean[,​ hint:table or function[, pwchar:​string]]]]):​ string`  ​
-  Read some text from the terminal, i.e. allow the user to input some text. For example, this is used by the shell and Lua interpreter to read user input. This will make the rest of the current line, starting at the current cursor position, an editable area. It allows input, deletion and navigating to the left and right via the arrow keys and home/​end ​keys.  ​+从终端读取一些文本,即让用户能够输入一些文本。例如,此函数被shellLua解释器用来读取用户输入。此函数会使当前行从光标位置算起的剩余部分变为可编辑区域。在此区域中可以输入、删除文字,还可以使用左右方向键和home/end键移动光标。
   ​   ​
-  ***since OpenOS 1.6** the parameter list as specified here is considered deprecated. The first parameter is an `optionsargument. The indexed array values are treated as `history`, named keys take the place of legacy arguments. For compatibility, ​OpenOS 1.6 will respect the previous usage, i.e. parameter list. +  ***OpenOS 1.6** 此处指定的参数列表已被视为过时。第一个参数为`option`(选项)参数。其索引值被作为`histroy`(历史)对待,命名键取代了旧的参数。出于兼容性考虑,OpenOS 1.6仍然支持以前的用法,即参数列表。 
-  *The new `ops` parameter supports a new key, `nowrap`. The default behavior of term.read ​wrap the cursor and input vertically. Legacy behavior scrolled the input horizontally,​ i.e. `term.read({nowrap=true})`+  *新的 ​`ops` 参数支持新键:`nowrap`。`term.read`的默认行为(`nowrap`为`false`)垂直绑定了光标和输入。先前的行为模式下会水平滚动输入,即现在的 ​`term.read({nowrap=true})`
  
   The optional `history` table can be used to provide predefined text that can be cycled through via the up and down arrow keys. It must be a sequence (i.e. the keys must be a gap-less integral interval starting at 1). This is used for the command history in shell and Lua interpreter,​ for example. If text is entered and confirmed with enter, it will be added to the end of this table.  ​   The optional `history` table can be used to provide predefined text that can be cycled through via the up and down arrow keys. It must be a sequence (i.e. the keys must be a gap-less integral interval starting at 1). This is used for the command history in shell and Lua interpreter,​ for example. If text is entered and confirmed with enter, it will be added to the end of this table.  ​