Skip to content

Commit

Permalink
Fix less, man and update modules
Browse files Browse the repository at this point in the history
  • Loading branch information
bill88t committed Feb 27, 2024
1 parent 026d4ad commit 1336561
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 85 deletions.
162 changes: 81 additions & 81 deletions Beryllium/bin/less.py
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
rename_process("less")
try:
with be.api.fopen(be.based.user_vars["argj"].split()[1]) as f:
vr("lines_tmp", f.readlines())
vr("opts", be.api.xarg())
be.api.setvar("return", "1")
if len(vr("opts")["w"]):
with be.api.fopen(vr("opts")["w"][0]) as pv[get_pid()]["f"]:
if vr("f") is not None:
vr("lines_tmp", vr("f").readlines())

vr("lines", [])
for pv[get_pid()]["i"] in vr("lines_tmp"):
vra(
"lines",
pv[get_pid()]["i"].replace("\n", "")
if pv[get_pid()]["i"] != "\n"
else pv[get_pid()]["i"],
vr("lines", [])
for pv[get_pid()]["i"] in vr("lines_tmp"):
vra(
"lines",
pv[get_pid()]["i"].replace("\n", "")
if pv[get_pid()]["i"] != "\n"
else pv[get_pid()]["i"],
)
vrd("lines_tmp")
be.based.command.fpexec(
pv[0]["root"] + "/bin/stringproccessing/line_wrap.py"
)
vrd("lines_tmp")
be.based.command.fpexec(pv[0]["root"] + "/bin/stringproccessing/line_wrap.py")
# Now our lines has been formatted
# Now our lines have been formatted

if not len(vr("lines")):
raise OSError
vr("sizee", term.detect_size())

pv[get_pid()]["sizee"] = term.detect_size()
term.trigger_dict = {
"ctrlC": 1,
"q": 1,
"up": 2,
"down": 3,
"pgup": 4,
"pgdw": 5,
"home": 6,
"end": 7,
"rest": "ignore",
"echo": "none",
}

term.trigger_dict = {
"ctrlC": 1,
"q": 1,
"up": 2,
"down": 3,
"pgup": 4,
"pgdw": 5,
"home": 6,
"end": 7,
"rest": "ignore",
"echo": "none",
}
vr("lc", len(vr("lines")))
vr(
"target",
(vr("sizee")[0] - 1) if (vr("lc") > vr("sizee")[0] - 1) else vr("lc"),
) # no of lines per screen
vr("pos", 0) # scroll offset
vr("ctl", [0, None])
vr("endt", " (END)")
vr("carry", "\n")

vr("lc", len(vr("lines")))
vr(
"target",
(vr("sizee")[0] - 1) if (vr("lc") > vr("sizee")[0] - 1) else vr("lc"),
) # no of lines per screen
vr("pos", 0) # scroll offset
vr("ctl", [0, None])
vr("endt", " (END)")
vr("carry", "\n")

term.clear()
while vr("ctl")[0] != 1:
term.trigger_dict["prefix"] = "{}lines {}-{}/{} {}%{}{}".format(
colors.white_bg_black_bg,
vr("pos"),
vr("target") + vr("pos"),
vr("lc"),
int(float(vr("target") + vr("pos")) * 100 / float(vr("lc"))),
vr("endt") if vr("pos") == vr("lc") - vr("target") else "",
colors.endc,
)
for pv[get_pid()]["i"] in range(0, vr("target")):
vr("l", vr("lines")[vr("i") + vr("pos")])
term.nwrite(vr("l") + (vr("carry") if vr("l") != vr("carry") else ""))
vr("ctl", term.program())
if vr("ctl")[0] == 2:
if vr("pos"):
pv[get_pid()]["pos"] -= 1
elif vr("ctl")[0] == 3:
if vr("pos") < vr("lc") - vr("target"):
pv[get_pid()]["pos"] += 1
elif vr("ctl")[0] == 4:
if vr("pos") > vr("target"):
pv[get_pid()]["pos"] -= vr("target")
else:
vr("pos", 0)
elif vr("ctl")[0] == 5:
if vr("pos") < vr("lc") - 2 * vr("target"):
pv[get_pid()]["pos"] += vr("target")
else:
vr("pos", vr("lc") - vr("target"))
elif vr("ctl")[0] == 6:
vr("pos", 0) # ez -- blade 2020
elif vr("ctl")[0] == 7:
vr("pos", vr("lc") - vr("target"))
term.clear()
be.api.setvar("return", "0")

except OSError:
be.based.error(4, be.based.user_vars["argj"].split()[1])
be.api.setvar("return", "1")

except IndexError:
while vr("ctl")[0] != 1:
term.trigger_dict["prefix"] = "{}lines {}-{}/{} {}%{}{}".format(
colors.white_bg_black_bg,
vr("pos"),
vr("target") + vr("pos"),
vr("lc"),
int(float(vr("target") + vr("pos")) * 100 / float(vr("lc"))),
vr("endt") if vr("pos") == vr("lc") - vr("target") else "",
colors.endc,
)
for pv[get_pid()]["i"] in range(0, vr("target")):
vr("l", vr("lines")[vr("i") + vr("pos")])
term.nwrite(
vr("l") + (vr("carry") if vr("l") != vr("carry") else "")
)
vr("ctl", term.program())
if vr("ctl")[0] == 2:
if vr("pos"):
pv[get_pid()]["pos"] -= 1
elif vr("ctl")[0] == 3:
if vr("pos") < vr("lc") - vr("target"):
pv[get_pid()]["pos"] += 1
elif vr("ctl")[0] == 4:
if vr("pos") > vr("target"):
pv[get_pid()]["pos"] -= vr("target")
else:
vr("pos", 0)
elif vr("ctl")[0] == 5:
if vr("pos") < vr("lc") - 2 * vr("target"):
pv[get_pid()]["pos"] += vr("target")
else:
vr("pos", vr("lc") - vr("target"))
elif vr("ctl")[0] == 6:
vr("pos", 0) # ez -- blade 2020
elif vr("ctl")[0] == 7:
vr("pos", vr("lc") - vr("target"))
term.clear()
be.api.setvar("return", "0")
else:
be.based.error(4, be.based.user_vars["argj"].split()[1])
else:
be.based.error(1)
be.api.setvar("return", "1")
5 changes: 2 additions & 3 deletions Beryllium/bin/man.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
vr("manpages", set())
for pv[get_pid()]["manpage"] in vr("manls"):
if vr("manpage").endswith(".man"):
pv[get_pid()]["manpages"].add(vr("manpage")[:-4])
vr("manpages").add(vr("manpage")[:-4])

vr("opts", be.api.xarg())

if len(vr("opts")["w"]) is 1:
vr("page_dayo", vr("opts")["w"][0])
if vr("page_dayo") in vr("manpages"):
be.based.run(
"less",
[pv[0]["root"] + "/usr/share/man/{}.man".format(vr("page_dayo"))],
"less /usr/share/man/{}.man".format(vr("page_dayo")),
)
else:
term.write(
Expand Down
2 changes: 1 addition & 1 deletion other/CircuitPython_FTP_Server

0 comments on commit 1336561

Please sign in to comment.