Comments (20)
Hi @flagarde, thanks for your answer.
I have this currently:
(Yeah, colors are horrible, but they will be configurable 😂 )
I'm waiting to input with Term::Platform::read_raw()
, then update things accordingly, create the string with Window::render()
and show it with std::cout + std::flush
. Wait 100ms and start again.
With flickering I mean that whole screen was blinking, some frames were drawn black, or the screen filling was noticeable. That was happening until I pulled cpp-terminal
code from master
yesterday, now it does not blink at all, even if I don't do the 100ms waiting. So I guess the problem is solved, but my question was that cpp-terminal
being used the way I use it, should not blink/flicker at all, shouldn't it?
When I change the size of the terminal strange artifacts occur and also some blinking, but this doesn't bother me, it's normal even in graphical applications. After I stop resizing everything works perfectly. I didn't try the new way provided in the link you mention, I use the Window
class for the moment.
from cpp-terminal.
@iganinja nice Turbo Pascal style menus. :) It would be nice to have them as widgets in cpp-terminal eventually.
from cpp-terminal.
@iganinja Hello, thanks for your nice words. Some changes has been done related to resizing and maybe this create new issues. Would you mind give some codes to test ? What do you call flickering
, something like redrawing (sorry my english is not so good)?
Does this happen when you change the size of your terminal? have you tried to use the new way provided by #234 (in https://github.com/jupyter-xeus/cpp-terminal/blob/master/examples/menu.cpp). The API has changed quite a lot and it is still not fixed; pulling gives you the new features but would need to change your code too, that's why there is not official new version. I'm just proposing some change and @MCWertGaming is the maintainer of the package
from cpp-terminal.
@iganinja I know they were some bug before the last merge in windows. Please note that key can be NO_KEY so you should add a test case for this. The reason is that read_raw return Event that can be other things than Key. But it is allowed to cast Event to Key and in the case the event is not a key, the key is then NO_KEY.
I recommend you to use the same trick than in menu.cpp in the example. Maybe you don't have to do the wait by yourself. You could use read_event
that return only when it received event (key, change screen size ...). read_raw is more an internal function
from cpp-terminal.
@iganinja This is fixed ?
from cpp-terminal.
Hi!
I tested it with my program in Windows: it flickers a little bit in a line. In Linux it seems rock solid, no flickering at all.
from cpp-terminal.
@iganinja thx for the feedback. We can let this open then.. Not sure if it's a problem from the library of from Window$. Maybe there is some hack we could use I remember some discussion about this.
Are you using cout or Term::terminal<< ?
from cpp-terminal.
std::cout
. Perhaps I have somewhat older version? I didn't touch it in weeks.
from cpp-terminal.
I noticed flickering too in my application as you described on Windows but not on Linux. I figured it was probably an issue with the frame rate of the console or when the console triggers a new redraw of the screen. I guessed that the Windows console maybe has a higher frame rate so it is more likely to trigger a redraw just after the ClearScreen
command. So I got rid of ClearScreen
and rewrote the rendering of my screen elements so that they do not need a clear screen before printing.
Maybe that helps
from cpp-terminal.
I wonder if it's not the contrary the console in windows is poorly optimized. Are you using Term::terminal or cout. I heard somewhere cout is not buffered or things like this in windows or a very small buffer
from cpp-terminal.
I notized it with both. but part of my change from not using ClearScreen
anymore also involves of just rendering and printing the few characters that actually change instead of re-rendering and drawing the whole screen. So maybe because my newer solution needs less memory or buffer space as you suggest fixed it.
from cpp-terminal.
@TobiasWallner Your solution is general or a bit hacky? If it's a general one I think this could be incorporated into this library as it would be a very nice addition 😀
from cpp-terminal.
it is general to my application but probably specific in terms of your library.
It is only applies to the design elemts of my projet like grids, labels, editable text fields, comman lines and the like.
The idea is that each element has functions that change something, like inserting a character or moveing the cursor. They will do that + give you a render of the changes which is just a move to the one character and the new value.
from cpp-terminal.
I see, so it seems the problem is the clearscreen ?
from cpp-terminal.
yes I think so
from cpp-terminal.
@TobiasWallner I'm trying to implement a more system base API to wrtite to console. I have been told the C C++ Windows is quite buggy and not so efficient sometimes. I already did a first step with file.hpp but need to improve it. Maybe this will improve performance. I have seen an other way to improve performance I will do a PR for this
I didn't benchmark as i'm doind on virtualbox so the results it's maybe not what one should expect but I can see it by eyes so lets implement and check on other system
from cpp-terminal.
I could run a benchmark natively if you want me too.
from cpp-terminal.
@TobiasWallner Would be great or to have a program with benching on this repo :)
from cpp-terminal.
Your solution is general or a bit hacky? If it's a general one I think this could be incorporated into this library as it would be a very nice addition
I was wondering, you do have a class that stores one frame, the window class, right?
Could we calculate the difference of of two windows? - which is then a map of all things that changed? and then just print that to reduce the ammount of data that gets printed every time?
could look like this:
newFrame = render();
diff = newFrame - prevFrame;
Term::cout << diff;
prevFrame = newFrame;
from cpp-terminal.
We already do the diff, although the diff is quite "primitive":
cpp-terminal/cpp-terminal/window.cpp
Line 199 in a40326c
However, the demos that we have don't seem to flicker for me.
from cpp-terminal.
Related Issues (20)
- Windows terminal can be turned into `legacy mode` and so crash our ANSII support detection
- example 'kilo' does not support special characters HOT 7
- exception leaking destructor is dangerous HOT 10
- build as shared library, error adding symbols: DSO missing from command line HOT 12
- Compiling the examples with GCC results in errors HOT 7
- Create a list of projects that are using this library HOT 3
- Bug: cpp-terminal crashes if two utf8 are inserted simultaneously HOT 42
- Multiline prompt stopped working on macOS
- Ctrl + I and Tab HOT 6
- Bug: Text Wrap Incompatibility HOT 6
- Bring back the list of other similar libraries HOT 4
- Pressing Ctrl, Alt, Shift creates a copy paste event on windows? HOT 3
- Addition of Metakey and Key results in warning of deprecation HOT 1
- Bug in key + metakey arithmetic HOT 7
- Exception thrown at this line when typeing to fast HOT 7
- mouse sending random characters to the terminal after examples/minimal ends HOT 8
- `std::cin` doesn't read pipe redirection HOT 8
- Issue with file headers HOT 3
- Doctest.h needs to be updated to the latest version - compile error on Ubuntu 22.04 HOT 2
- Error linking with CMake HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpp-terminal.