Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flickering of menu (?) #62

Closed
GiorgosXou opened this issue Jan 5, 2023 · 27 comments
Closed

Flickering of menu (?) #62

GiorgosXou opened this issue Jan 5, 2023 · 27 comments
Labels
bug Something isn't working Solved

Comments

@GiorgosXou
Copy link
Owner

GiorgosXou commented Jan 5, 2023

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 GiorgosXou added the bug Something isn't working label Jan 5, 2023
@GiorgosXou
Copy link
Owner Author

THAT"S SO WIERD

@GiorgosXou
Copy link
Owner Author

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

@GiorgosXou GiorgosXou added the help wanted Extra attention is needed label Jan 5, 2023
@GiorgosXou
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

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
Copy link
Owner Author

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
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

... 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 ???

def __try_open_file_with(self, directory: str, open_with: Optional[str]) -> None:

@GiorgosXou
Copy link
Owner Author

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

@GiorgosXou
Copy link
Owner Author

(or anyone else lol)

@GiorgosXou
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

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
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

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
Copy link
Owner Author

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
Copy link
Owner Author

Sometimes it just works without flickering and some times it doesn't

image

@GiorgosXou GiorgosXou changed the title Flickering of menu Flickering of menu (?) Jan 5, 2023
@Sigmanificient
Copy link
Contributor

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
Copy link
Contributor

Sigmanificient commented Jan 5, 2023

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
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

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
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

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

@Sigmanificient
Copy link
Contributor

Oh well i didn't know that

@Sigmanificient
Copy link
Contributor

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

I need to check

@Sigmanificient
Copy link
Contributor

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

image
image

@GiorgosXou
Copy link
Owner Author

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

@Sigmanificient
Copy link
Contributor

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
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

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

@Sigmanificient
Copy link
Contributor

Base size:
image

Bigger:
image

@GiorgosXou
Copy link
Owner Author

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
Copy link
Owner Author

maybe a smaller menu might be great

@GiorgosXou
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

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
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

Here's the bad implementation of the positioning of the menu :P

if self.y + self.height > parent_height: self.y -= self.height

@GiorgosXou
Copy link
Owner Author

GiorgosXou commented Jan 5, 2023

Here you go, now it's better hehe

73f0d4c

@GiorgosXou GiorgosXou added Solved and removed help wanted Extra attention is needed unknown labels Oct 11, 2024
GiorgosXou added a commit that referenced this issue Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Solved
Projects
None yet
Development

No branches or pull requests

2 participants