Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Console decoration for DOS (windows)
Console decoration for DOS (windows) [message #36418] Fri, 25 May 2012 17:28 Go to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hello all,

I share you a modified Stream version to allow
- text coloration (foreground and background)
- cursor positionning
for DOS operating system.

I added these functions to Stream.h

void GetConsoleCursorPos(COORD& posCur)
void SetConsoleCursorPos(const COORD& posCur)
void Colorize(int foreground,int background)

Re: Console decoration for DOS (windows) [message #36419 is a reply to message #36418] Fri, 25 May 2012 17:31 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Here is a sample test
Quote:


#include <Core/Core.h>

using namespace Upp;

COORD coord1, coord2;
Stream& s1 = Cout();
Stream& s2 = Cout();
StaticMutex mutex1, mutex2;

class multithread
{
public :

typedef multithread CLASSNAME;

Thread th1, th2;

void thr_1()
{
for(int i=0; i<=10; i++)
{
th2.Sleep(100);
s1.SetConsoleCursorPos(coord1);
s1 << i;
}
}

void thr_2()
{
for(int i=0; i<=15; i++)
{
th1.Sleep(100);
s2.SetConsoleCursorPos(coord2);
s2 << i;
}
}

void Test()
{

s1 << "\n\tTHREAD 1 ...";
s1.GetConsoleCursorPos(coord1);


s2 << "\n\tTHREAD 2 ...";
s2.GetConsoleCursorPos(coord2);

th1.Run(THISBACK(thr_1));
th2.Run(THISBACK(thr_2));

th1.Wait();
th2.Wait();
}
};

CONSOLE_APP_MAIN
{
Stream& s = Cout();

s.PutEol();
s.PutEol();
s << "\t";

s.Colorize(1,14);
s << " THIS IS A CONSOLE DECORATION TEST ";
s.Colorize();
s.PutEol();
s.PutEol();

multithread mt;
mt.Test();

s.PutEol();
s.PutEol();
}




and the result
index.php?t=getfile&id=3757&private=0

Wish it will be usefull for you.

Ratah
  • Attachment: console.jpg
    (Size: 14.08KB, Downloaded 545 times)

[Updated on: Fri, 25 May 2012 17:33]

Report message to a moderator

Re: Console decoration for DOS (windows) [message #36424 is a reply to message #36419] Fri, 25 May 2012 21:46 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hello Ratah,

Nice decoration!

Do you plan to add some other features as the possibility to use semi-graphic characters ? I know that it brings me back to the old times of Turbo Pascal running in extended DOS. But I remember my first projects in Pascal using DOS. Rolling Eyes

You should be too young for that, should you Smile ?

Regards

Biobytes
Re: Console decoration for DOS (windows) [message #36747 is a reply to message #36418] Sun, 01 July 2012 02:08 Go to previous message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Interesting.
Borland C++ compiler used to have a conio.h library for this stuff.
Turbo Pascal had this too.

You should take a look at the ncurses library that does this on Linux.

I think this is a cool feature request here:
Why not make .lay files GUI create console widgets when we set a flag? That would be very useful to have consistent GUIs for GUI environments and text mode.

If U++ produces GUI from the same layouts for:
Windows GUI
Linux GUI (GTK)
Mac OS X GUI (Cocoa)
Web (HTML)
Android
Text Mode GUI (DOS and unix text mode)

Then it would be pretty universal.
Previous Topic: Web framework - Skylark - first taste
Next Topic: CodeEditor with user-definable syntax highlighting
Goto Forum:
  


Current Time: Thu Mar 28 09:41:23 CET 2024

Total time taken to generate the page: 0.01738 seconds