Sergio00166/pBTE

Some question to your Project ;)

Opened this issue · 5 comments

Hello, great project, great job. I have a question in which part of the code should be changed so that the text displayed on the screen is cut into frames the length of the screen. Now, if a paragraph is long, it can be moved to the right. And if I want the text to always be the length of the screen frame and, additionally, not to be cut at the end, but to display the entire word and, if it is too large, to move to the next line. Can this be done?
I try to create simple text editor like a small laptop :)
20240915_145116
Best regards
Mateusz ;)

to do that, It will need to change some a lot of things on how the screen is rendered.
Or to make it symply create one function that executes on each iteration on the main pBTE.py file that checks and modifies the arr to do avoid the line use more space that the screen line lenght by inserting new entries below that one.

For example this will be a basic example for the thing you asked for, but it still does not not take into account the full words, it just breaks and adds it to another line

def no_split_lines(columns,arr):
    new_arr = []
    for x in arr:
        new_arr += wrap(x, columns)
    return new_arr


if __name__=="__main__":  

    from sys import path
    from os import sep
    # Add the folder to import from here
    path.append(path[0]+sep+"bin")
    from init import *
    from functions import wrap`
    
    # Run the update Thread
    update_thr=Thread(target=updscr_thr)
    run_thread=True; kill=False
    update_thr.start()
    
    while True:
        try:
            # Fix arr when empty
            if len(arr)==0: arr=[""]
            # If status flag is 0 set save text to blank
            if status_st==False: status=saved_df 
            # Get the terminal size
            rows,columns=get_size()
            # Avoid splitting to blocks
            arr = no_split_lines(columns,arr)
            # Call screen updater function

Ooo thx ;) i will try to add function to check if word is cut.

In which section should I add the battery status function so that it is displayed all the time, not in response to the user's click? for now I placed it in upd_screen, but the function depends on the user's reaction.

You can remove the lock from the updscr_thr() in pBTE.py , and change the polling rate to update it automatically and remove the check for if the screen size has changed. And it should be changed also for all files in bin/menus.
I dont know, better keep trying stuff until it works.