• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

refresh screen

How I can refresh screen when i start my program.
0
JBURGHARDT
Asked:
JBURGHARDT
  • 2
  • 2
  • 2
  • +2
1 Solution
 
ramaswamysCommented:
You can use 'xrefresh' - a standard application that ships with most Unix and Linux distributions.

Ramaswamy
0
 
JBURGHARDTAuthor Commented:
well I want to know this using c++ since this is programing question
how to use clrscr(); refresh(),
0
 
ramaswamysCommented:
Oops, Sorry ! Well if you want to clear a terminal please refer to the curses library documentation or If you are doing X-windows programming you have calls like XClearArea(), XClearWindow(), etc.

Good Luck
Ramaswamy
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
paitreCommented:
There are also the generic terminal escape sequences that may or may not work (it really depends on the terminal).
ie: ESC[2J (\x1B[2J) is used to clear the screen and it's also supposed to home the cursor.  I've used this particular sequnce a lot and it generally works (both in C and C++).
0
 
serena77Commented:
Here are some macros you could use as paitre sugested below:

#define CCLR "\033\143\x1B[2J" /* reset and clear screen */

Also if you're interested:

#define CUDL  "\x1B[4m" /* underline */
#define CFSH  "\x1B[5m" /* flashing (mihgt not work, depending on your  term) */
#define CRVS  "\x1B[7m" /* reverse video */
#define CNRM  "\x1B[0;0m" /* normal (disable special attributes) */
0
 
pessoaCommented:
using ansi escape sequences is extremely evil and unportable
one should definately use a terminal capability database
such as termcap or terminfo
this is comfortably done by using a library
such as ncurses or slang , both easily found on freshmeat
for small manipulations, such a library is too much of an
overhead, so termcap or terminfo should be consulted
directly.
0
 
pessoaCommented:
Here's a very minimal solution using the ncurses library
#include <curses.h>
int main {
initscr();clear();refresh();
/*everything interesting goes here */
endwin ();}
initscr () checks the terminal's abilities and size, it has to be called before doing anything that manipulates the terminal, with a few rarely useful exceptions. in programs using multiple terminals, newterm () is used instead of initscr ().
clear () copies blanks into every position of the virtual screen. refresh copies the virtual screen into the physical screen, i.e. it's after successfully calling this function that the screen appears cleared.
endwin() should be called before leaving a program using curses to clean the terminal up. Otherwise it may stay in a mess. Use endwin religiously in signal handlers and atexit() instructions.
it is not recommended to use ncurses just for this one operation. i can present a solution using the GNU termcap library instead, later on. ncurses is not part of the (g)libc, but has to be linked explicitely by e.g -lncurses on the gcc commandline.
0
 
JBURGHARDTAuthor Commented:
Adjusted points to 400
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now