mirror of
https://github.com/MeexReay/poshlostios.git
synced 2025-06-24 10:32:59 +03:00
kfs sdfsdf
This commit is contained in:
parent
fe03d8ab53
commit
19ceb7a9bf
@ -1,3 +1,21 @@
|
||||
async function cropToScreen(text, x, y, width, height) {
|
||||
let screen = []
|
||||
let i = y
|
||||
for (const line of text.split("\n")) {
|
||||
if (i <= 0) {
|
||||
screen.push(line.slice(x, width + x))
|
||||
if (screen.length == height) {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
i--
|
||||
}
|
||||
}
|
||||
for (let i = screen.length; i < height; i++) {
|
||||
screen.push("~")
|
||||
}
|
||||
return screen.join("\n")
|
||||
}
|
||||
|
||||
async function main(args) {
|
||||
if (args.length != 2) {
|
||||
@ -5,10 +23,14 @@ async function main(args) {
|
||||
return 1
|
||||
}
|
||||
|
||||
let [terminal_width, terminal_height] = getTerminalSize()
|
||||
|
||||
let content = readFile(args[1])
|
||||
|
||||
let pos = getCursor()
|
||||
|
||||
await writeStdout(cropToScreen(content, 0, 0, terminal_width, terminal_height - 1))
|
||||
|
||||
setStdinFlag(ENABLE_STDIN)
|
||||
setStdinFlag(SILENT_STDIN)
|
||||
|
||||
@ -29,6 +51,9 @@ async function main(args) {
|
||||
}
|
||||
|
||||
setStdinFlag(RENDER_STDIN)
|
||||
setStdinFlag(DISABLE_STDIN)
|
||||
|
||||
await writeStdout("\n")
|
||||
|
||||
return 0
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user