Skip to content

Commit 8572daa

Browse files
committed
feat: Add italic/bold/strikethrough, etc. functions
1 parent 7b6b459 commit 8572daa

File tree

2 files changed

+81
-43
lines changed

2 files changed

+81
-43
lines changed

docs/bash-term.md

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,109 @@
11
## Index
22

3-
- [term.cursor_to()](#termcursor_to)
4-
- [term.cursor_moveto()](#termcursor_moveto)
5-
- [term.cursor_up()](#termcursor_up)
6-
- [term.cursor_down()](#termcursor_down)
7-
- [term.cursor_forward()](#termcursor_forward)
8-
- [term.cursor_backward()](#termcursor_backward)
9-
- [term.cursor_line_next()](#termcursor_line_next)
10-
- [term.cursor_line_prev()](#termcursor_line_prev)
11-
- [term.cursor_horizontal()](#termcursor_horizontal)
12-
- [term.cursor_savepos()](#termcursor_savepos)
13-
- [term.cursor_restorepos()](#termcursor_restorepos)
14-
- [term.cursor_save()](#termcursor_save)
15-
- [term.cursor_restore()](#termcursor_restore)
16-
- [term.cursor_hide()](#termcursor_hide)
17-
- [term.cursor_show()](#termcursor_show)
18-
- [term.cursor_getpos()](#termcursor_getpos)
19-
- [term.erase_line_end()](#termerase_line_end)
20-
- [term.erase_line_start()](#termerase_line_start)
21-
- [term.erase_line()](#termerase_line)
22-
- [term.erase_screen_end()](#termerase_screen_end)
23-
- [term.erase_screen_start()](#termerase_screen_start)
24-
- [term.erase_screen()](#termerase_screen)
25-
- [term.erase_saved_lines()](#termerase_saved_lines)
26-
- [term.scroll_down()](#termscroll_down)
27-
- [term.scroll_up()](#termscroll_up)
28-
- [term.tab_set()](#termtab_set)
29-
- [term.tab_clear()](#termtab_clear)
30-
- [term.tab_clearall()](#termtab_clearall)
31-
- [term.beep()](#termbeep)
32-
- [term.hyperlink()](#termhyperlink)
3+
* [term.cursor_to()](#termcursor_to)
4+
* [term.cursor_moveto()](#termcursor_moveto)
5+
* [term.cursor_up()](#termcursor_up)
6+
* [term.cursor_down()](#termcursor_down)
7+
* [term.cursor_forward()](#termcursor_forward)
8+
* [term.cursor_backward()](#termcursor_backward)
9+
* [term.cursor_line_next()](#termcursor_line_next)
10+
* [term.cursor_line_prev()](#termcursor_line_prev)
11+
* [term.cursor_horizontal()](#termcursor_horizontal)
12+
* [term.cursor_savepos()](#termcursor_savepos)
13+
* [term.cursor_restorepos()](#termcursor_restorepos)
14+
* [term.cursor_save()](#termcursor_save)
15+
* [term.cursor_restore()](#termcursor_restore)
16+
* [term.cursor_hide()](#termcursor_hide)
17+
* [term.cursor_show()](#termcursor_show)
18+
* [term.cursor_getpos()](#termcursor_getpos)
19+
* [term.erase_line_end()](#termerase_line_end)
20+
* [term.erase_line_start()](#termerase_line_start)
21+
* [term.erase_line()](#termerase_line)
22+
* [term.erase_screen_end()](#termerase_screen_end)
23+
* [term.erase_screen_start()](#termerase_screen_start)
24+
* [term.erase_screen()](#termerase_screen)
25+
* [term.erase_saved_lines()](#termerase_saved_lines)
26+
* [term.scroll_down()](#termscroll_down)
27+
* [term.scroll_up()](#termscroll_up)
28+
* [term.tab_set()](#termtab_set)
29+
* [term.tab_clear()](#termtab_clear)
30+
* [term.tab_clearall()](#termtab_clearall)
31+
* [term.beep()](#termbeep)
32+
* [term.hyperlink()](#termhyperlink)
3333

3434
### term.cursor_to()
3535

3636
Move the cursor position to a supplied row and column. Both default to `0` if not supplied
3737

3838
#### Arguments
3939

40-
- **$1** (int): row
41-
- **$1** (int): column
40+
* **$1** (int): row
41+
* **$1** (int): column
4242

4343
### term.cursor_moveto()
4444

4545
Moves cursor position to a supplied _relative_ row and column. Both default to `0` if not supplied (FIXME: implement)
4646

4747
#### Arguments
4848

49-
- **$1** (int): row
50-
- **$1** (int): column
49+
* **$1** (int): row
50+
* **$1** (int): column
5151

5252
### term.cursor_up()
5353

5454
Moves the cursor up. Defaults to `1` if not supplied
5555

5656
#### Arguments
5757

58-
- **$1** (int): count
58+
* **$1** (int): count
5959

6060
### term.cursor_down()
6161

6262
Moves the cursor down. Defaults to `1` if not supplied
6363

6464
#### Arguments
6565

66-
- **$1** (int): count
66+
* **$1** (int): count
6767

6868
### term.cursor_forward()
6969

7070
Moves the cursor forward. Defaults to `1` if not supplied
7171

7272
#### Arguments
7373

74-
- **$1** (int): count
74+
* **$1** (int): count
7575

7676
### term.cursor_backward()
7777

7878
Moves the cursor backwards. Defaults to `1` if not supplied
7979

8080
#### Arguments
8181

82-
- **$1** (int): count
82+
* **$1** (int): count
8383

8484
### term.cursor_line_next()
8585

8686
Moves the cursor to the next line. Defaults to `1` if not supplied
8787

8888
#### Arguments
8989

90-
- **$1** (int): count
90+
* **$1** (int): count
9191

9292
### term.cursor_line_prev()
9393

9494
Moves the cursor to the previous line. Defaults to `1` if not supplied
9595

9696
#### Arguments
9797

98-
- **$1** (int): count
98+
* **$1** (int): count
9999

100100
### term.cursor_horizontal()
101101

102102
Moves the cursor ?
103103

104104
#### Arguments
105105

106-
- **$1** (int): count
106+
* **$1** (int): count
107107

108108
### term.cursor_savepos()
109109

@@ -219,5 +219,6 @@ Construct hyperlink
219219

220220
#### Arguments
221221

222-
- **$1** (string): text
223-
- **$2** (string): url
222+
* **$1** (string): text
223+
* **$2** (string): url
224+

pkg/src/public/bash-term.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,40 @@ term.hyperlink() {
306306

307307
printf -v REPLY '\e]8;;%s\a%s\e]8;;\a' "$url" "$text"
308308
}
309+
310+
# @description Construct bold
311+
# @arg $1 string text
312+
term.bold() {
313+
unset -v REPLY
314+
local text="$1"
315+
316+
printf -v REPLY '\e[1m%s\e0m' "$text"
317+
}
318+
319+
# @description Construct italic
320+
# @arg $1 string text
321+
term.italic() {
322+
unset -v REPLY
323+
local text="$1"
324+
325+
printf -v REPLY '\e[3m%s\e0m' "$text"
326+
}
327+
328+
# @description Construct underline
329+
# @arg $1 string text
330+
term.underline() {
331+
unset -v REPLY
332+
local text="$1"
333+
334+
printf -v REPLY '\e[4m%s\e0m' "$text"
335+
}
336+
337+
# @description Construct strikethrough
338+
# @arg $1 string text
339+
term.strikethrough() {
340+
unset -v REPLY
341+
local text="$1"
342+
343+
printf -v REPLY '\e[9m%s\e0m' "$text"
344+
}
345+

0 commit comments

Comments
 (0)