@@ -6,48 +6,58 @@ import { textInput } from "./dom.ts";
66import { isArray , isNumber , isString } from "../../is.ts" ;
77import { sleep } from "../../sleep.ts" ;
88
9- export function undo ( count = 1 ) {
9+ export const undo = ( count = 1 ) : void => {
1010 for ( const _ of range ( 0 , count ) ) {
1111 press ( "z" , { ctrlKey : true } ) ;
1212 }
13- }
14- export function redo ( count = 1 ) {
13+ } ;
14+ export const redo = ( count = 1 ) : void => {
1515 for ( const _ of range ( 0 , count ) ) {
1616 press ( "z" , { shiftKey : true , ctrlKey : true } ) ;
1717 }
18- }
18+ } ;
1919
20- export function insertIcon ( count = 1 ) {
20+ export const insertIcon = ( count = 1 ) : void => {
2121 for ( const _ of range ( 0 , count ) ) {
2222 press ( "i" , { ctrlKey : true } ) ;
2323 }
24- }
24+ } ;
2525
26- export function insertTimestamp ( index = 1 ) {
26+ export const insertTimestamp = ( index = 1 ) : void => {
2727 for ( const _ of range ( 0 , index ) ) {
2828 press ( "t" , { altKey : true } ) ;
2929 }
30- }
30+ } ;
3131
32- export async function insertLine ( lineNo : number , text : string ) {
32+ export const insertLine = async (
33+ lineNo : number ,
34+ text : string ,
35+ ) : Promise < void > => {
3336 await goLine ( lineNo ) ;
3437 goHead ( ) ;
3538 press ( "Enter" ) ;
3639 press ( "ArrowUp" ) ;
3740 await insertText ( text ) ;
38- }
41+ } ;
3942
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 > => {
4148 await goLine ( start ) ;
4249 goHead ( ) ;
4350 for ( const _ of range ( start , end ) ) {
4451 press ( "ArrowDown" , { shiftKey : true } ) ;
4552 }
4653 press ( "End" , { shiftKey : true } ) ;
4754 await insertText ( text ) ;
48- }
55+ } ;
4956
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 > => {
5161 if ( isNumber ( from ) ) {
5262 if ( getLineCount ( ) === from + count ) {
5363 await goLine ( from - 1 ) ;
@@ -78,74 +88,74 @@ export async function deleteLines(from: number | string | string[], count = 1) {
7888 throw new TypeError (
7989 `The type of value must be number | string | string[] but actual is "${ typeof from } "` ,
8090 ) ;
81- }
91+ } ;
8292
83- export function indentLines ( count = 1 ) {
93+ export const indentLines = ( count = 1 ) : void => {
8494 for ( const _ of range ( 0 , count ) ) {
8595 press ( "ArrowRight" , { ctrlKey : true } ) ;
8696 }
87- }
88- export function outdentLines ( count = 1 ) {
97+ } ;
98+ export const outdentLines = ( count = 1 ) : void => {
8999 for ( const _ of range ( 0 , count ) ) {
90100 press ( "ArrowLeft" , { ctrlKey : true } ) ;
91101 }
92- }
93- export function moveLines ( count : number ) {
102+ } ;
103+ export const moveLines = ( count : number ) : void => {
94104 if ( count > 0 ) {
95105 downLines ( count ) ;
96106 } else {
97107 upLines ( - count ) ;
98108 }
99- }
109+ } ;
100110// to行目の後ろに移動させる
101- export function moveLinesBefore ( from : number , to : number ) {
111+ export const moveLinesBefore = ( from : number , to : number ) : void => {
102112 const count = to - from ;
103113 if ( count >= 0 ) {
104114 downLines ( count ) ;
105115 } else {
106116 upLines ( - count - 1 ) ;
107117 }
108- }
109- export function upLines ( count = 1 ) {
118+ } ;
119+ export const upLines = ( count = 1 ) : void => {
110120 for ( const _ of range ( 0 , count ) ) {
111121 press ( "ArrowUp" , { ctrlKey : true } ) ;
112122 }
113- }
114- export function downLines ( count = 1 ) {
123+ } ;
124+ export const downLines = ( count = 1 ) : void => {
115125 for ( const _ of range ( 0 , count ) ) {
116126 press ( "ArrowDown" , { ctrlKey : true } ) ;
117127 }
118- }
128+ } ;
119129
120- export function indentBlocks ( count = 1 ) {
130+ export const indentBlocks = ( count = 1 ) : void => {
121131 for ( const _ of range ( 0 , count ) ) {
122132 press ( "ArrowRight" , { altKey : true } ) ;
123133 }
124- }
125- export function outdentBlocks ( count = 1 ) {
134+ } ;
135+ export const outdentBlocks = ( count = 1 ) : void => {
126136 for ( const _ of range ( 0 , count ) ) {
127137 press ( "ArrowLeft" , { altKey : true } ) ;
128138 }
129- }
130- export function moveBlocks ( count : number ) {
139+ } ;
140+ export const moveBlocks = ( count : number ) : void => {
131141 if ( count > 0 ) {
132142 downBlocks ( count ) ;
133143 } else {
134144 upBlocks ( - count ) ;
135145 }
136- }
137- export function upBlocks ( count = 1 ) {
146+ } ;
147+ export const upBlocks = ( count = 1 ) : void => {
138148 for ( const _ of range ( 0 , count ) ) {
139149 press ( "ArrowUp" , { altKey : true } ) ;
140150 }
141- }
142- export function downBlocks ( count = 1 ) {
151+ } ;
152+ export const downBlocks = ( count = 1 ) : void => {
143153 for ( const _ of range ( 0 , count ) ) {
144154 press ( "ArrowDown" , { altKey : true } ) ;
145155 }
146- }
156+ } ;
147157
148- export async function insertText ( text : string ) {
158+ export const insertText = async ( text : string ) : Promise < void > => {
149159 const cursor = textInput ( ) ;
150160 if ( ! cursor ) {
151161 throw Error ( "#text-input is not ditected." ) ;
@@ -156,4 +166,4 @@ export async function insertText(text: string) {
156166 const event = new InputEvent ( "input" , { bubbles : true } ) ;
157167 cursor . dispatchEvent ( event ) ;
158168 await sleep ( 1 ) ; // 待ち時間は感覚で決めた
159- }
169+ } ;
0 commit comments