示例#1
0
文件: clrline.c 项目: TijmenW/FreeDOS
void clrcmdline(char * const str, const unsigned orgx, const unsigned orgy)
{
	if(str) {
		goxy(orgx, orgy);
		fputmc(' ', strlen(str) + 1, stdout);
		strset(str, 0);
	}
	goxy(orgx, orgy);
}
示例#2
0
void clrcmdline(char * const str, const int maxlen
 , const unsigned orgx, const unsigned orgy)
{
	assert(str);

	goxy(orgx, orgy);
	fputmc(' ', strlen(str) + 1, stdout);
	memset(str, 0, maxlen);
	goxy(orgx, orgy);
}
示例#3
0
文件: main.c 项目: super-1943/MCU
//**************************Ö÷º¯Êý********************************
void main()
{

	init_1602();

	//initDisplay();

	delay(500);

	goxy(1,0);
	write_cmd(0x01);
	show("zhaoyongke");
	goxy(2,0);
	show(" www.ysu.edu.cn ");
	delay(4000);
	while(1);
}
示例#4
0
文件: cls.c 项目: FDOS/freecom
int cmd_cls (char * param) {
    (void)param;
    outc( '\xc' ); /* ^L Form feed */

	/* Output stream is neither a file nor NUL nor CLOCK$ */
	if(((fdattr(1) ^ 0x80) & (0x80 | 0x08 | 0x04)) == 0) {
		/* Now roll the screen */
		IREGS r;
		r.r_ax = 0x0600;	/* Scroll window up // entire window */
		r.r_bx = 0x0700;	/* Attribute to write */
		r.r_cx = 0x0000;	/* Upper left */
		r.r_dx = ((SCREEN_ROWS - 1) << 8) | (SCREEN_COLS - 1); /* Lower right */
		intrpt(0x10, &r);
		goxy(1, 1);			/* home the cursor */
	}

	return 0;
}
示例#5
0
/* read in a command line */
void readcommandEnhanced(char * const str, const int maxlen)
{
        unsigned char insert = 1;
        unsigned ch;
#ifdef FEATURE_FILENAME_COMPLETION
        unsigned lastch = 0;
#endif
#ifdef FEATURE_HISTORY
        int histLevel = 0;
        char prvLine[MAX_INTERNAL_COMMAND_SIZE];
#endif
        unsigned curx;
        unsigned cury;
        int count;
        unsigned current = 0;
        unsigned charcount = 0;

        assert(str);
        assert(maxlen <= MAX_INTERNAL_COMMAND_SIZE);

        /* if echo off, don't print prompt */
        if(echo)
                printprompt();

        orgx = wherex();
        orgy = wherey();
        memset(str, 0, maxlen);

        _setcursortype(_NORMALCURSOR);

#ifdef FEATURE_HISTORY
        histGet(histLevel - 1, prvLine, sizeof(prvLine));
#endif

        do {
                ch = cgetchar();

                if(cbreak)
                        ch = KEY_CTL_C;

                switch(ch) {
                case KEY_BS:               /* delete character to left of cursor */

                        if(current > 0 && charcount > 0) {
                          if(current == charcount) {     /* if at end of line */
                                str[current - 1] = 0;
                                if (wherex() != 1)
                                  outs("\b \b");
                                else
                                {
                                  goxy(MAX_X, wherey() - 1);
                                  outblank();
                                  goxy(MAX_X, wherey() - 1);
                                }
                          }
                          else
                          {
                                for (count = current - 1; count < charcount; count++)
                                  str[count] = str[count + 1];
                                if (wherex() != 1)
                                  goxy(wherex() - 1, wherey());
                                else
                                  goxy(MAX_X, wherey() - 1);
                                curx = wherex();
                                cury = wherey();
                                outsblank(&str[current - 1]);
                                goxy(curx, cury);
                          }
                          charcount--;
                          current--;
                        }
                        break;

                case KEY_INSERT:           /* toggle insert/overstrike mode */
                        insert ^= 1;
                        if (insert)
                          _setcursortype(_NORMALCURSOR);
                        else
                          _setcursortype(_SOLIDCURSOR);
                        break;

                case KEY_DELETE:           /* delete character under cursor */

                        if (current != charcount && charcount > 0)
                        {
                          for (count = current; count < charcount; count++)
                                str[count] = str[count + 1];
                          charcount--;
                          curx = wherex();
                          cury = wherey();
                          outsblank(&str[current]);
                          goxy(curx, cury);
                        }
                        break;

                case KEY_HOME:             /* goto beginning of string */

                        if (current != 0)
                        {
                          goxy(orgx, orgy);
                          current = 0;
                        }
                        break;

                case KEY_END:              /* goto end of string */

                        if (current != charcount)
                        {
                          goxy(orgx, orgy);
                          outs(str);
                          current = charcount;
                        }
                        break;

#ifdef FEATURE_FILENAME_COMPLETION
                case KEY_TAB:            /* expand current file name */
                        if(current == charcount) {      /* only works at end of line */
                          if(lastch != KEY_TAB) { /* if first TAB, complete filename */
                                complete_filename(str, charcount);
                                charcount = strlen(str);
                                current = charcount;

                                goxy(orgx, orgy);
                                outs(str);
                                if ((strlen(str) > (MAX_X - orgx)) && (orgy == MAX_Y + 1))
                                  orgy--;
                          } else {                 /* if second TAB, list matches */
                                if (show_completion_matches(str, charcount))
                                {
                                  printprompt();
                                  orgx = wherex();
                                  orgy = wherey();
                                  outs(str);
                                }
                          }
                        }
                        else
                          beep();
                        break;
#endif

                case KEY_ENTER:            /* end input, return to main */

#ifdef FEATURE_HISTORY
                        if(str[0])
                          histSet(0, str);      /* add to the history */
#endif

                        outc('\n');
                        break;

                case KEY_CTL_C:                 /* ^C */
                case KEY_ESC:              /* clear str  Make this callable! */

                        clrcmdline(str, maxlen, orgx, orgy);
                        current = charcount = 0;

                        if(ch == KEY_CTL_C && !echo) {
                          /* enable echo to let user know that's this
                                is the command line */
                          echo = 1;
                          printprompt();
                        }
                        break;

                case KEY_RIGHT:            /* move cursor right */

                        if (current != charcount)
                        {
                          current++;
                          if (wherex() == MAX_X)
                                goxy(1, wherey() + 1);
                          else
                                goxy(wherex() + 1, wherey());
                                break;
                        }
                        /* cursor-right at end of string grabs the next character
                                from the previous line */
                        /* FALL THROUGH */

#ifndef FEATURE_HISTORY
                        break;
#else
                case KEY_F1:       /* get character from last command buffer */
                          if (current < strlen(prvLine)) {
                                 outc(str[current] = prvLine[current]);
                                 charcount = ++current;
                          }
                          break;

                case KEY_F3:               /* get previous command from buffer */
                        if(charcount < strlen(prvLine)) {
                                outs(strcpy(&str[charcount], &prvLine[charcount]));
                           current = charcount = strlen(str);
                   }
                   break;

                case KEY_UP:               /* get previous command from buffer */
                        if(!histGet(--histLevel, prvLine, sizeof(prvLine)))
                                ++histLevel;            /* failed -> keep current command line */
                        else {
                                clrcmdline(str, maxlen, orgx, orgy);
                                strcpy(str, prvLine);
                                current = charcount = strlen(str);
                                outs(str);
                                histGet(histLevel - 1, prvLine, sizeof(prvLine));
                        }
                        break;

                case KEY_DOWN:             /* get next command from buffer */
                        if(histLevel) {
                                clrcmdline(str, maxlen, orgx, orgy);
                                strcpy(prvLine, str);
                                histGet(++histLevel, str, maxlen);
                                current = charcount = strlen(str);
                                outs(str);
                        }
                        break;

                case KEY_F5: /* keep cmdline in F3/UP buffer and move to next line */
                        strcpy(prvLine, str);
                        clrcmdline(str, maxlen, orgx, orgy);
                        outc('@');
                        if(orgy >= MAX_Y) {
                                outc('\n');                     /* Force scroll */
                                orgy = MAX_Y;
                        } else {
                                ++orgy;
                        }
                        goxy(orgx, orgy);
                        current = charcount = 0;

                        break;

#endif

                case KEY_LEFT:             /* move cursor left */
                        if(current > 0) {
                          current--;
                          if (wherex() == 1)
                                goxy(MAX_X, wherey() - 1);
                          else
                                goxy(wherex() - 1, wherey());
                        }
                        break;


                case KEY_CTRL_LEFT:     /* move cursor left to begin of word */
                        while(current > 0) {
                          current--;
                          if (wherex() == 1)
                                goxy(MAX_X, wherey() - 1);
                          else
                                goxy(wherex() - 1, wherey());

                          if(isworddelimiter(str[current-1])    /* ignore current == 0 */
                           && !isworddelimiter(str[current]))
                             break;
                        }
                        break;

                case KEY_CTRL_RIGHT:    /* move cursor right to begin of word */
                        while(current < charcount) {
                          current++;
                          if (wherex() == MAX_X)
                                goxy(1, wherey() + 1);
                          else
                                goxy(wherex() + 1, wherey());

                          if(isworddelimiter(str[current-1])
                           && !isworddelimiter(str[current]))
                             break;
                        }
                        break;

                default:                 /* insert character into string... */

                        if ((ch >= 32 && ch <= 255) && (charcount != (maxlen - 2)))
                        {
                          if (insert && current != charcount)
                          {
                                for (count = charcount; count > current; count--)
                                  str[count] = str[count - 1];
                                str[current++] = ch;
                                curx = wherex() + 1;
                                cury = wherey();
                                outs(&str[current - 1]);
                                if ((strlen(str) > (MAX_X - orgx)) && (orgy == MAX_Y + 1))
                                  cury--;
                                goxy(curx, cury);
                                charcount++;
                          }
                          else
                          {
                                if (current == charcount)
                                  charcount++;
                                str[current++] = ch;
                                outc(ch);
                          }
                          if ((strlen(str) > (MAX_X - orgx)) && (orgy == MAX_Y + 1))
                                orgy--;
                        }
                        else
                          beep();
                        break;
                }
#ifdef FEATURE_FILENAME_COMPLETION
                lastch = ch;
#endif
        } while(ch != KEY_ENTER);

        _setcursortype(_NORMALCURSOR);
}
示例#6
0
int main()
{
	int KeyPress=0;
	int CharX; int CharY; int xt; int yt;
	int x; int y; int i;
	int Tabla[25][15];
 
	for (x=0; x<25; x++) {
		for (y=0; y<15; y++) {
			Tabla[x][y]=1;
		}
	}
 
	//Dibujamo una linea superior horizontal
	for (i=0; i<25; i++) {
		Tabla[i][0]=2;
	}
	//Dibujamo una linea inferior horizontal
	for (i=0; i<25; i++) {
		Tabla[i][14]=2;


	}
	//Dibujamo una linea superior vertical
	for (i=0; i<15; i++) {
		Tabla[0][i]=2;
	}
	//Dibujamo una linea inferior vertical
	for (i=0; i<15; i++) {
		Tabla[24][i]=2;
	}
 
	//Dibujamo una linea inferior horizontal en medio de la consola
	for (i=5; i<19; i++) {
		Tabla[i][7]=2;
	}
 
	//Definimos la posición inicial de la "x"
	Tabla[4][3]=3;
	CharX=4;
	CharY=3;
 
	printf("Press Key...");
	while (KeyPress!=27)
	{
		KeyPress = getch();
		goxy(0,0);
		if (KeyPress==72) { //Arriba
			yt = CharY - 1;
			if (Tabla[CharX][yt]==1) {
				Tabla[CharX][CharY]=1;
				CharY=yt;
				Tabla[CharX][yt]=3;
			}
		}
		if (KeyPress==80) { //Abajo
			yt = CharY + 1;
			if (Tabla[CharX][yt]==1) {
				Tabla[CharX][CharY]=1;
				CharY=yt;
				Tabla[CharX][yt]=3;
			}
		}
		if (KeyPress==75) { //Izquierda
			xt = CharX - 1;
			if (Tabla[xt][CharY]==1) {
				Tabla[CharX][CharY]=1;
				CharX=xt;
				Tabla[xt][CharY]=3;
			}
		}
		if (KeyPress==77) { //Derecha
			xt = CharX + 1;
			if (Tabla[xt][CharY]==1) {
				Tabla[CharX][CharY]=1;
				CharX=xt;
				Tabla[xt][CharY]=3;
			}
		}
		for (y=0; y<15; y++) {
			for (x=0; x<25; x++) {
				if (Tabla[x][y]==1) {
					printf(" ");
				} else if (Tabla[x][y]==2) {
					printf("#");
				} else if (Tabla[x][y]==3) {
					printf("x");
				}
			}
			printf("\n");
		}
	}
}