@@ -6,48 +6,58 @@ import { textInput } from "./dom.ts";
6
6
import { isArray , isNumber , isString } from "../../is.ts" ;
7
7
import { sleep } from "../../sleep.ts" ;
8
8
9
- export function undo ( count = 1 ) {
9
+ export const undo = ( count = 1 ) : void => {
10
10
for ( const _ of range ( 0 , count ) ) {
11
11
press ( "z" , { ctrlKey : true } ) ;
12
12
}
13
- }
14
- export function redo ( count = 1 ) {
13
+ } ;
14
+ export const redo = ( count = 1 ) : void => {
15
15
for ( const _ of range ( 0 , count ) ) {
16
16
press ( "z" , { shiftKey : true , ctrlKey : true } ) ;
17
17
}
18
- }
18
+ } ;
19
19
20
- export function insertIcon ( count = 1 ) {
20
+ export const insertIcon = ( count = 1 ) : void => {
21
21
for ( const _ of range ( 0 , count ) ) {
22
22
press ( "i" , { ctrlKey : true } ) ;
23
23
}
24
- }
24
+ } ;
25
25
26
- export function insertTimestamp ( index = 1 ) {
26
+ export const insertTimestamp = ( index = 1 ) : void => {
27
27
for ( const _ of range ( 0 , index ) ) {
28
28
press ( "t" , { altKey : true } ) ;
29
29
}
30
- }
30
+ } ;
31
31
32
- export async function insertLine ( lineNo : number , text : string ) {
32
+ export const insertLine = async (
33
+ lineNo : number ,
34
+ text : string ,
35
+ ) : Promise < void > => {
33
36
await goLine ( lineNo ) ;
34
37
goHead ( ) ;
35
38
press ( "Enter" ) ;
36
39
press ( "ArrowUp" ) ;
37
40
await insertText ( text ) ;
38
- }
41
+ } ;
39
42
40
- export async function replaceLines ( start : number , end : number , text : string ) {
43
+ export const replaceLines = async (
44
+ start : number ,
45
+ end : number ,
46
+ text : string ,
47
+ ) : Promise < void > => {
41
48
await goLine ( start ) ;
42
49
goHead ( ) ;
43
50
for ( const _ of range ( start , end ) ) {
44
51
press ( "ArrowDown" , { shiftKey : true } ) ;
45
52
}
46
53
press ( "End" , { shiftKey : true } ) ;
47
54
await insertText ( text ) ;
48
- }
55
+ } ;
49
56
50
- export async function deleteLines ( from : number | string | string [ ] , count = 1 ) {
57
+ export const deleteLines = async (
58
+ from : number | string | string [ ] ,
59
+ count = 1 ,
60
+ ) : Promise < void > => {
51
61
if ( isNumber ( from ) ) {
52
62
if ( getLineCount ( ) === from + count ) {
53
63
await goLine ( from - 1 ) ;
@@ -78,74 +88,74 @@ export async function deleteLines(from: number | string | string[], count = 1) {
78
88
throw new TypeError (
79
89
`The type of value must be number | string | string[] but actual is "${ typeof from } "` ,
80
90
) ;
81
- }
91
+ } ;
82
92
83
- export function indentLines ( count = 1 ) {
93
+ export const indentLines = ( count = 1 ) : void => {
84
94
for ( const _ of range ( 0 , count ) ) {
85
95
press ( "ArrowRight" , { ctrlKey : true } ) ;
86
96
}
87
- }
88
- export function outdentLines ( count = 1 ) {
97
+ } ;
98
+ export const outdentLines = ( count = 1 ) : void => {
89
99
for ( const _ of range ( 0 , count ) ) {
90
100
press ( "ArrowLeft" , { ctrlKey : true } ) ;
91
101
}
92
- }
93
- export function moveLines ( count : number ) {
102
+ } ;
103
+ export const moveLines = ( count : number ) : void => {
94
104
if ( count > 0 ) {
95
105
downLines ( count ) ;
96
106
} else {
97
107
upLines ( - count ) ;
98
108
}
99
- }
109
+ } ;
100
110
// to行目の後ろに移動させる
101
- export function moveLinesBefore ( from : number , to : number ) {
111
+ export const moveLinesBefore = ( from : number , to : number ) : void => {
102
112
const count = to - from ;
103
113
if ( count >= 0 ) {
104
114
downLines ( count ) ;
105
115
} else {
106
116
upLines ( - count - 1 ) ;
107
117
}
108
- }
109
- export function upLines ( count = 1 ) {
118
+ } ;
119
+ export const upLines = ( count = 1 ) : void => {
110
120
for ( const _ of range ( 0 , count ) ) {
111
121
press ( "ArrowUp" , { ctrlKey : true } ) ;
112
122
}
113
- }
114
- export function downLines ( count = 1 ) {
123
+ } ;
124
+ export const downLines = ( count = 1 ) : void => {
115
125
for ( const _ of range ( 0 , count ) ) {
116
126
press ( "ArrowDown" , { ctrlKey : true } ) ;
117
127
}
118
- }
128
+ } ;
119
129
120
- export function indentBlocks ( count = 1 ) {
130
+ export const indentBlocks = ( count = 1 ) : void => {
121
131
for ( const _ of range ( 0 , count ) ) {
122
132
press ( "ArrowRight" , { altKey : true } ) ;
123
133
}
124
- }
125
- export function outdentBlocks ( count = 1 ) {
134
+ } ;
135
+ export const outdentBlocks = ( count = 1 ) : void => {
126
136
for ( const _ of range ( 0 , count ) ) {
127
137
press ( "ArrowLeft" , { altKey : true } ) ;
128
138
}
129
- }
130
- export function moveBlocks ( count : number ) {
139
+ } ;
140
+ export const moveBlocks = ( count : number ) : void => {
131
141
if ( count > 0 ) {
132
142
downBlocks ( count ) ;
133
143
} else {
134
144
upBlocks ( - count ) ;
135
145
}
136
- }
137
- export function upBlocks ( count = 1 ) {
146
+ } ;
147
+ export const upBlocks = ( count = 1 ) : void => {
138
148
for ( const _ of range ( 0 , count ) ) {
139
149
press ( "ArrowUp" , { altKey : true } ) ;
140
150
}
141
- }
142
- export function downBlocks ( count = 1 ) {
151
+ } ;
152
+ export const downBlocks = ( count = 1 ) : void => {
143
153
for ( const _ of range ( 0 , count ) ) {
144
154
press ( "ArrowDown" , { altKey : true } ) ;
145
155
}
146
- }
156
+ } ;
147
157
148
- export async function insertText ( text : string ) {
158
+ export const insertText = async ( text : string ) : Promise < void > => {
149
159
const cursor = textInput ( ) ;
150
160
if ( ! cursor ) {
151
161
throw Error ( "#text-input is not ditected." ) ;
@@ -156,4 +166,4 @@ export async function insertText(text: string) {
156
166
const event = new InputEvent ( "input" , { bubbles : true } ) ;
157
167
cursor . dispatchEvent ( event ) ;
158
168
await sleep ( 1 ) ; // 待ち時間は感覚で決めた
159
- }
169
+ } ;
0 commit comments