flat assembler
Message board for the users of flat assembler.

Index > Windows > Way to draw a fast terminal emulator type text window?

Author
Thread Post new topic Reply to topic
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 25 Nov 2011, 18:27
What is a fast way to draw a monospaced text window with cursor?

I currently single-bufferly TextOutW one cell at a time. Not very fast, but it supports fonts that are not strictly monospace. Is there a better way?

_________________
This is a block of text that can be added to posts you make.
Post 25 Nov 2011, 18:27
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4347
Location: Now
edfed 25 Nov 2011, 18:56
look at the tinypad example in fasmw package, and you will have your answer for a little part of your problem. Smile
Post 25 Nov 2011, 18:56
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 27 Nov 2011, 04:00
You are saying that I should use a built-in window class like a RichEdit or something? Somehow I doubt that would be very fast. And I have no idea how to work with those.
Post 27 Nov 2011, 04:00
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 27 Nov 2011, 04:18
I'm thinking of dumping the idea of a gui and just going for a cui solution. What is the best way of drawing to the console? Perhaps it's as slow to draw?
Post 27 Nov 2011, 04:18
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 27 Nov 2011, 22:22
Seems like the way to go is WriteConsoleOutput and ReadConsoleInput. Instead of simulating a console with gui, I'm going to see how you can do the opposite Smile
Post 27 Nov 2011, 22:22
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 27 Nov 2011, 22:57
it;s actually very easy to implement.

Just paint the background to black.

And start at the top with a static(will work best) or edit control.

On each return you append another one but keeping the size and disabling the previous one.

Use EM_KEYDOWN / (specifically WM_CHAR : http://msdn.microsoft.com/en-us/library/aa932721.aspx ) to handle the keypress.

For history you can "cache" the input to a file or just have like 3 or X amount char * buffers to keep your history.

Very easy huh Very Happy
Post 27 Nov 2011, 22:57
View user's profile Send private message Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 27 Nov 2011, 23:01
Well, i suppose a control matrix would have been a solution too. Somehow it sounds a bit resource ineffective though Smile
Post 27 Nov 2011, 23:01
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 28 Nov 2011, 21:29
If you're dealing with monospace fonts, you can prerender all the glyphs you need (to a single) bitmap, and then do simple & insanely fast BitBlt's from that to your surface area.
Post 28 Nov 2011, 21:29
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 28 Nov 2011, 23:31
That would actually be quite nice. The fonts needn't even be monospaced.

Still, I'm going for a no-frills KISS design. I'm new to serious console programming, so it'll be an adventure!
Post 28 Nov 2011, 23:31
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 28 Nov 2011, 23:42
BitBlt is pretty simple and KISS Smile

If you want to look at how other people do it, you could take a look at the PuTTY source code - haven't looked at it myself, but my guess is it that (at least the screen drawing) should be straightforward to follow.

As for textmode console, WriteConsoleOutput should be fast enough for anything "normal". Haven't tried 60fps "video" playback with it, but I wouldn't classify that as "normal" Smile
Post 28 Nov 2011, 23:42
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 28 Nov 2011, 23:44
I thought that if there are scene demos getting a good framerate out of the console, it's fast enough for me Smile
Post 28 Nov 2011, 23:44
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 01 Nov 2012, 21:54
Yeah, working with the console at higher resolution turned out to be a pain, so I will probably scrap this idea. Turns out you only have 64k total for console buffers and console buffer character buffers Sad

Think I'm going back to something I tried in this unfinished project, CUI in GUI with mouse-draggable 'flap windows' and context menus:

http://files.sys5.se/mieulwkh.exe

_________________
This is a block of text that can be added to posts you make.
Post 01 Nov 2012, 21:54
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 01 Dec 2012, 17:51
I have made two terminals. The first one I used GDI+ for the first one and the second one I used GDI for. Do not underestimate the work involved. Both supports full screen.

You want to avoid edit controls at all cost. They are slow as hell when they start to fill up. I coded both of mine using custom code from scratch and it's very fast.

ExtTextOut is the fastest text drawing function, all others are wrappers of this.

http://i.imgur.com/UVRKq.png?1

You can customize font settings and different stuff in an ini file, here I go full screen by issuing the command 'full' and changed font size to a larger font.

http://i.imgur.com/kr42U.png

It supports unlimited amount of text and terminal does not slow down anything whether the buffer is full or empty, speed stays the same.

When you resize the window, it resizes by characters and not by pixels just like cmd.exe does. It supports scrolling, using customized scroll functions and dib sections.

ini file supports different colors for input text and for output echo text so that it is easier to see what you typed and what is echo back.

It also supports setting maximum MB of memory dedicated for the buffer.

You can easily create commands by using a sophisticated macro, creating new commands is very easy.

When you type something and press enter, what you typed will be remembered in a history buffer that you can scroll through using up and down arrow keys. In cmd.exe it will remember everything you type but in my editor it will only remember unique input text, if you type 1 and 1 after one another, it will only remember one instance of that since it has been repeated. You can set maximum lines in the history buffer in the ini file, it is set to 100 by default.

Editor uses many lookup buffers like character width and height are in lookup buffers. Positions and stuff like that are also pre-buffered, the same goes for resizing your window, it looks up precalculated position values instead of calculating it on the run.

Again, do not underestimate the work involved by creating a terminal from scratch. My terminal is 5040 lines of assembly code, but it is highly optimized and has far better viewing and readability than the crappy cmd.exe

Compared to putty, my terminal is about up to 10 times faster.
Post 01 Dec 2012, 17:51
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.