Aug 23, 2013 at 4:31pm UTC
Hey I'm on a linux and I want help with deleting text... clear the screen no system();
Then color screen red...
Also how can the programmer tell how big the screen is(How many lines)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#include <stdio.h>
#define BG "\033[7;31m"
#define TXT "\033[0;37m"
#define CLEAR "\033[2k"
#define UP "\033[A"
void help();
void stupid();
void version();
int main(int argc, char * argv[])
{
if (argc!=2)
{
stupid();
return 1;
}
if (argv[1][0]=='-' )
{
switch (argv[1][1])
{
case 'h' :
help();
break ;
case 'v' :
version();
break ;
case 'e' :
return 1;
default :
stupid();
return 1;
}
}
else
{
int i=0;
while (i<30)
{
printf(UP);
printf(CLEAR);
printf(UP);
i++;
}
printf( BG "Hello, " );
printf( argv[1]);
printf( BG "!\n" );
}
return 0;
}
void help()
{
printf("Usage:\n./hello [NAME] [-hv]\n" );
printf("\t-h\tHelp\n" );
printf("\t-v\tVersion\n" );
}
void stupid()
{
printf("STUPID!\n" );
printf("TYPE THE NAME OF THE PROGRAM THEN YOUR NAME.\n" );
printf("IT ISN'T COMPLICATED!\n" );
}
void version()
{
printf("Hello (C) 2013 Tim Palmer\n" );
printf("Version: 0.0.2\n" );
}
Last edited on Aug 23, 2013 at 4:33pm UTC
Aug 23, 2013 at 4:34pm UTC
Search these forums please.
Aug 23, 2013 at 4:40pm UTC
I have that's how I got this far... But the CLEAR doesn't seem to work... it just takes cursor to the place up specifies
Aug 23, 2013 at 5:37pm UTC
Last edited on Aug 23, 2013 at 5:39pm UTC
Aug 23, 2013 at 5:37pm UTC
If you have to, print 100 newlines, then CLEAR.
Last edited on Aug 23, 2013 at 5:38pm UTC
Aug 23, 2013 at 5:49pm UTC
About indent I indent when on graphical ide but I'm using vi so it makes it harder
And I saw this before in a search
The link to cross platform escape codes... how do I use it?
About the comment
>You could just print 100 \n then CLEAR
How do I clear?
Last edited on Aug 23, 2013 at 6:10pm UTC
Aug 24, 2013 at 2:03am UTC
thank you I got everything except how big is the screen id like to clear only as many lines as the screen is tall...
Aug 24, 2013 at 2:15am UTC
You can indent just as easily in vim as any other text editor.
Ask stty size for the number of rows and columns. Some systems maintain $ROWS and $COLS as well.
If you are using the VT-100/ANSI escape codes to manipulate the screen, you don't need to care how many lines it has to clear it.
Aug 24, 2013 at 2:43am UTC
I found stty size... but if I want to find it in a program not at the shell...?
Aug 24, 2013 at 2:53am UTC
Thank you about ncurses I've tried but it doesn't work on android...
I think I've got every thing so thanks I saw on another post that you made a
PressAnyKey function where is it I couldn't find it...
Aug 24, 2013 at 3:20am UTC
Thanks I think everythings good
Aug 24, 2013 at 3:32am UTC
Hey
@duoas
On ncurses if I just have the .h files will that be fine? Do I need to install?
What .hpp???
Last edited on Aug 24, 2013 at 3:45am UTC
Aug 24, 2013 at 5:12am UTC
sudo apt-get install ncurses-devel
I think... I don't use Android -- or Debian, for that matter.
Last edited on Aug 24, 2013 at 5:13am UTC