GiorgosXou / TUIFIManager

A cross-platform terminal-based termux-oriented file manager (and component), meant to be used with a Uni-Curses project or as is.
GNU General Public License v3.0
684 stars 13 forks source link

Flickering of menu (?) #62

Open GiorgosXou opened 1 year ago

GiorgosXou commented 1 year ago

For some very wierd reason, the issue gets solved the momment I open a file to an external app (it doesn't matter if the external app is a TUI or not), I'm guessing this has to do with the print(BEGIN_MOUSE) in main

\r vs \n vs \r\n etc.

tuifi_Peek 2023-01-05 11-53

GiorgosXou commented 1 year ago

THAT"S SO WIERD

GiorgosXou commented 1 year ago

Ha... there's might be a need of reinitialization (BEGIN...END_MOUSE) when a new pad (like the menu) is created

GiorgosXou commented 1 year ago

I think it has to do with the ncurses itself, thinking that the mouse escape sequences are part of a change to the stdscr, forcing it to redraw itself again and again (?)

GiorgosXou commented 1 year ago

I need to make a minimal reproducible example before I post the issue and i don't know if I have the time to do so... but I have to do so...

GiorgosXou commented 1 year ago

... forcing it to redraw itself again and again (?)

But if this is true, then why it gets fixed the momment I END_MOUSE > suspend the app > open a subprocess > wait until it closes > BEGIN_MOUSE ???

https://github.com/GiorgosXou/TUIFIManager/blob/dcc17d820f565cb70df5c1719dda423c0af09809/TUIFIManager/__init__.py#L251

GiorgosXou commented 1 year ago

May the lord of ncurses Thomas E. Dickey , saves me 🙏

GiorgosXou commented 1 year ago

(or anyone else lol)

GiorgosXou commented 1 year ago

Ok ok... I'll try to make a minimal reproducible example in c\c++ when i find the time (or I'll ask GPT-chat to do so, for me xD )

GiorgosXou commented 1 year ago

WTF somehow without changing anything in the source code, now it doesn't flicker... the last thing I remember doing was just to xset r rate 250 30 and play around with kbdrate which I don't think that they have any anything to do with the issue itself... something more wierd is happening and I can't figure it out

GiorgosXou commented 1 year ago

The Issue is completly random, I can't pinpoint when it is happening besides that when it is happening, it gets solved by doing what i've said in the first comment

GiorgosXou commented 1 year ago
Sometimes it just works without flickering and some times it doesn't
image
Sigmanificient commented 1 year ago

I guess we could have some kind of drawing pipeline, where the context menu would be drawn on top, such that other items below it would be partially drawn, to only have 1 update per char location?

Sigmanificient commented 1 year ago
from dataclasses import dataclass
from typing import List

@dataclass
class Rect:
    x: int
    y: int
    width: int
    height: int

@dataclass
class Drawable:
    rect: Rect
    z_index: int
    content: List[str]
    # instead of having a single string with line feeds, 
    # a list containing each line for easier manipulation.

    def render(self, screen, ...):
        # Compute whether this intersect with other element,
        # Draw the strings to make sure it doesn't replace character
        # And don't overdraw a other item with an higher z_index
        ...
GiorgosXou commented 1 year ago

Intersections and redrawing is something that ncurses handles by itself during refresh (really efficiently actually), it's not that much of our business to handle them. Also even if we wanted, this issue kinda prevents as at the momment

Rect and Drawable are somewhat equivalent to the ncurses-WINDOW\pad [...] This issue apears from nowhere and I don't really know what is causing it really, besides that when it (randomly) appears on startup it gets solved the momment I do what i've said at the first comment

GiorgosXou commented 1 year ago

Do you expirience the same issue too? (just to make sure)

Sigmanificient commented 1 year ago

Oh well i didn't know that

Sigmanificient commented 1 year ago

Do you expirience the same issue too? (just to make sure)

I need to check

Sigmanificient commented 1 year ago

Do you expirience the same issue too? It doesn't seem to flicker, but it something isn't properly rendered

image image

GiorgosXou commented 1 year ago

could you post a full terminal screenshot, because this seems to be that you just have a really small sized window

Sigmanificient commented 1 year ago

I guess having a rendering pipeline (without checking for collision) could be a good idea, so that everything is indexed properly, and the ui part is extracted

GiorgosXou commented 1 year ago

on those images you posted is you terminal smaller than 20 rows?

Sigmanificient commented 1 year ago

Base size: image

Bigger: image

GiorgosXou commented 1 year ago

This is another issue, it is related to the fact that when you right click, the terminal is too small to either open the menu on top or at the bottom of the position where you clicked, and such it crops it

GiorgosXou commented 1 year ago

maybe a smaller menu might be great

GiorgosXou commented 1 year ago

if you click on one of the upper icons or expand\unzoom the terminal even more this issue disapears, this is just a bad implementation i did, it is easilly improvable, the real issue is with the flickering though

GiorgosXou commented 1 year ago

Here's the bad implementation of the positioning of the menu :P https://github.com/GiorgosXou/TUIFIManager/blob/5b45e00ba4902318b75586a49e3dfeb1b3ce568d/TUIFIManager/TUIMenu.py#L54

GiorgosXou commented 1 year ago

Here you go, now it's better hehe

https://github.com/GiorgosXou/TUIFIManager/commit/73f0d4c00c5f298a40e9404e46f06d01219604e4