mirror of
https://github.com/MeexReay/poshlostios.git
synced 2025-06-24 10:32:59 +03:00
add insert line mode
This commit is contained in:
parent
d0d3060a54
commit
4b7701110e
@ -27,6 +27,12 @@ async function printScreen(screen_length, start_cursor, pos, content, mode, pos,
|
|||||||
return [screen.length + status_line.length, status_line.length - 1]
|
return [screen.length + status_line.length, status_line.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function editLine(content, line, callback) {
|
||||||
|
let lines = content.split("\n")
|
||||||
|
lines[line] = callback(lines[line])
|
||||||
|
return lines.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
async function main(args) {
|
async function main(args) {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
writeStdout(`Usage: kfc <file>\n`)
|
writeStdout(`Usage: kfc <file>\n`)
|
||||||
@ -110,7 +116,8 @@ async function main(args) {
|
|||||||
mode = "insert"
|
mode = "insert"
|
||||||
}
|
}
|
||||||
} else if (mode == "insert") {
|
} else if (mode == "insert") {
|
||||||
|
content = editLine(content, pos[1], line => line.slice(0, pos[0]) + event.char + line.slice(pos[0]))
|
||||||
|
pos[0] += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user