=== jasperredis / projects / pyenved ===

PyEnved Help Screen

This is the help screen from PyEnved. Although it is probably up-to-date, if it is not, or you suspect so, you may check the file here on the Codeberg repository, or locally on your PyEnved installation with ^A G S. If you do not have such an installation, then I am not sure why you are here.

Important note: The text below, unlike the rest of this website, is not licensed under the CC-BY-SA, but instead, it is licensed under the GNU Free Documentation License (or GFDL).

====== Help Screen ======

Welcome to the help screen!

This describes all of:
- How to use PyEnved
- All of the built-in functions
- Many of the keybinds (assuming you did not change them).

================================================================================

NOTE: PyEnved is still in Pre-Alpha, and the program and this text are
constantly changing. In fact, this is only written because I thought it'd be
fun to do it now.

Before you start: here are 2 notes about keybinds, because I do not know where
else to put them.
- Use ^Q if you do not want to finish entering a keybind, or you messed it up
  somewhere down the line.
- You cannot type in buffers while inputting a keybind. Use ^Q to cancel.


=== Helpful texts to see ===

You can see texts with ^A G X .

- keys : Lists all keybindings (including some not listed here).
- texts: List of all texts.
- funcs: Lists all functions. Actually, nevermind, this doesn't exist yet.
- modes: Lists all buffer modes.


=== Tips ===

- You may close PyEnved with ^A C.
- If you mess up the UI somehow, you can re-initialise it with ^F U.

================================================================================

=== 1. What is PyEnved? ===

You may skip past this if you already know the answer to that question.
PyEnved is a Python-based TUI (terminal user interface) text editor with:

- Freely executable, non-sandboxed Python for powerful text manipulation
- A (heavily work-in-progress) detailed set of built-in functions
- A tree-like keybindings system (e.g., ^A ^F to open a file)
- Buffers, which can be managed, switched between, and have "modes" (determine
  how you can interact with the buffer)
- More, eventually


=== 2. Basics of PyEnved ===

Every action in PyEnved is done through one of its functions. Even moving your
cursor right now is done through the move() function, which is bound to your
arrow keys.
There are two ways to run a function:
- A keybind (e.g., ^A F to run open_file())
- Directly naming it in execs()

Now, you may wonder: what is execs()?
execs() is a function that directly runs any Python code that you type into it.
That's it.

You can try execs now with ^X, but before you do so, take this important
warning:

EXECS IS NOT SANDBOXED.
You can run ANY arbitrary Python code with it.
Normally, you should only be using PyEnved functions or anything that helps you
manipulate text.
It is a very bad idea to attempt to use os.system or bare file I/O (non-PyEnved
functions) with execs.

If you want a REPL, you may also use the repls() function. This can be done
either through ^R N or ^X repls().
execs() and repls() will be considered one of the same in this text.

Execs has the ability to run all functions in PyEnved. If you cannot run it with
a keybind, you can with execs.
You also have the variables "buf" and "bufs"; "buf" is your current buffer, and
"bufs" is the list of all buffers.
For how buffers work, see 3. Basics of buffers.


=== 3. Basics of buffers ===

PyEnved manipulates text through buffers. Buffers are named items containing
text and modes.

Mode is how you can interact with a buffer; here are some
examples of modes.
- ED: The buffer can be edited.
- OW: The buffer is in overwrite mode.
- NX: The cursor cannot move in the X axis on this buffer.

TIP: You can see the mode of a buffer in the mode line at the bottom of the
screen. A buffer with modes PT and ED would show as "PT-ED". See this buffer?
Assuming you opened it with help_text (^A G S / ^A G X), the mode should be
"BIT-PT-ED". See ^A G X modes to see all buffer modes.

You can reference any given buffer in execs bufs via its title (e.g.,
bufs["Splash"]). To effectively manipulate buffers, you must first learn how
the buffer object works.

A buffer is a type of dataclass. It has 3 main fields (some may have more, we
will get to that later.):

- title  : The title of a buffer. Assuming you did not rename this one, it
           should be called "Help Text: screen". This is a string, though
           manipulating it is useless, as you may use retitle_buffer().
- mode   : The mode of the buffer. This is a set, and you may manipulate it as
           such, though I do not recommend doing that.
- content: The text content of the buffer; the most important field to
           manipulate. It is a string, and its lines are separated by newlines.

Try manipulating this buffer; press ^X, and copy this:
  buf.content = ("x" + buf.content)

Now scroll to the top of this buffer. Saw an "x"? Congrats!
Note: This is a BIT, or built-in text view: Changes made here are temporary and
      will be reset once you re-open the view. See ^A G X bits for more.


=== 4. Basic text manipulation ===

Great, you're 4 chapters in, and you're finally getting to basic text
manipulation. Wooohoo!
Considering you've scrolled down here, you probably have realised by now that
you can move your cursor around via your arrow keys.
Now, try placing your cursor below me and typing:
>>>
Did you do it?

TIP: That is done by calling insert_char_at_cursor(), which is a wrapper around
insert_char_at_position(). You can try ^X on insert_char_at_cursor(), if you
want; it takes one argument, and that is the character that you want to insert.

Now try overwrite mode. Start by pressing Insert.
You should see "OW" appear in the buffer mode. That means that you are now in
overwrite mode.
Place your cursor at the start of this next line, and type anything.
>>> I am text.
You can turn overwrite mode off now by pressing Insert again.


=== 5. Managing buffers ===

There are 4 commands for managing buffers and 6 keybinds to trigger them (we
will get to that mismatch later). Note that these are for MANAGING buffers, not
MANIPULATING them.

1. go_to_buffer()
This, as the name implies, takes you to a buffer. You can try it with ^B G and
typing, say, "Splash", but before you do that, don't forget that this buffer is
titled "Help Text: screen". Now, go ahead and try it.
The keybind is ^B G, and it runs this function with no argument. This defaults
to that input prompt at the bottom of your screen that you may have noticed. If
you want to run it with an argument, you can try doing so with execs; it takes
the buffer title as its optional argument.

2. list_buffers()
This function creates a buffer called "Buffers list", containing a list of all
of your buffers at the time you ran the command. It then takes you to this
buffer automagically. Try it by pressing ^B L, and then return here with
go_to_buffer() (^B G).
TIP: This function takes no args.

3. kill_buffer()
This function kills a buffer. You can use it with ^B K, and you will then type
in the name of the buffer that you want to kill. Consider using it to kill that
buffers list you made before.
Now, make that buffer list again to demonstrate this. Go to the buffer list, and
enter ^B X. It kills the active buffer and returns you to the buffer that was
opened before it.
TIP: kill_buffer() has an optional argument. If left empty, it will do the input
behaviour you are familiar with from ^B K. If you set it to "active", it will
kill the active buffer like in ^B X. In execs, if you input a buffer by title,
it will kill that specific buffer. Try it on Splash!

4. retitle_buffer()
This function changes a buffer's title. You can try retitling this buffer with
^B R A; it will assume the active buffer. Give it a pretty name.
If you want to retitle a buffer that is not the active buffer, try pressing
^B R O; it will give you 2 prompts, the first expecting you to name the buffer
that you want to retitle by title, and then another asking for the name that you
want to set it to.
There is nothing stopping you from titling a buffer "active", but please do not
do it, it will cause bugs.
TIP: retitle_buffer() has two arguments, both optional. The first is the buffer
that you want to retitle, as in its old name, by name. If left empty, it will
use the input prompt. If set to "active", it will use the currently active
buffer. Otherwise, you can give it a buffer by title.


=== 6. File management ===

6 chapters in, and we're finally at file management. Wooohoo.
"This is taking really long" I'M GETTING TO IT.

I would recommend opening another PyEnved window and keeping this one open, so
that you can continue reading this. Split panes don't exist yet, sorry, I plan
on it one day.

As of now, you have yet to have any files to edit. Let's change that.
Make a file somewhere, it doesn't matter where.

Now, once you have done that, press ^A F. It will ask you to enter the file
path. Do so. (Yes, you can use ~, though I don't know how it works on Windows
and I don't care either).

Typing works just like any standard text editor, but if you truly do not know
how that works, you can type anything and use backspace to get rid of stuff.
You may also use the Home, End, Page Up, and Page Down keys as you would expect.

Once you have typed something satisfactory enough to you, you may save it via
^A S. This calls the save_file() function.

TIP: open_file() takes one optional argument. If left empty, it will use the
input prompt behaviour. You may put this arg as the file path that you want to
open. save_file() works differently; it still has an optional arg that you can
use the same, though you can also enter "active" to save the active buffer.
This, however, is redundant, as that is already what it defaults to.

That is all; there will eventually be more to explain.


=== 7. Cursor functions ===

Cursor functions are called by your keybinds (arrow keys, home/end), though I
may as well document them here.

- move(): Takes one argument; a tuple, formatted as (y, x). Set these values to
  how much you want the cursor to move on that axis (positive y = down, positive
  x = right). Do not worry about NX/NY restrictions, goal column semantics, etc;
  this function handles it all for you.

- set_yx(): This directly sets the Y or X position, completely bypassing NX/NY
  restrictions and ignoring goal columns. Instead of a tuple, this uses kwargs;
  use y for the y position, and x for the x position. You may also set x to
  "end" to go to the end of a line (this is how the End key works), or set y to
  "end" to go to the end of the buffer. The Home key sets x to 0.

- move_by_screen(): This moves the cursor's y position by your buffer window
  height. It is how Page Up and Page Down work. It has one optional argument;
  direction. It defaults to "forward", which scrolls down, though it may be set
  to "back" to scroll up.


=== 8. End ===

That was the help screen for PyEnved! Have fun using this barely finished
program.
You are welcome to contribute, if you want to. The GitHub repository is at
this link:
> https://github.com/Jasperredis/PyEnved
The README has not much information, though it has information.

If the website is up at the time you are reading this, you can go to it here:
> https://www.jasperredis.net/projects/pyenved/index.html

That is all. Have fun, and goodbye! :3


================================================================================

Copyright (C)  2026  jasperredis.
Permission is granted to copy, distribute and/or modify this document under the
terms of the GNU Free Documentation License, Version 1.3 or any later version
published by the Free Software Foundation; with no Invariant Sections, no
Front-Cover Texts, and no Back-Cover Texts.
A copy of the license can be found in texts/license-gfdl.txt, or via
read_text("license-gfdl") in this program. (< ^A G X license-gfdl >).
For more information, see texts/licensing.txt or run read_text("licensing")
in this program. (< ^A G X licensing >).
If none of these are available, the license can be found at
https://www.gnu.org/licenses/fdl-1.3.html