Пример #1
0
void SelectFromHistory()
{
  // Change the view
      // Go to the right
      while((input.e - input.f) > 0)
      {
        input.f++;
        cgaputc(KEY_RT);
      }
      // Delete Current line
      while(input.e > input.w)
      {
        cgaputc(BACKSPACE);
        ++input.w; // Here also change the logic
      }
      input.e = input.w;
      input.f = input.w;
      input.r = input.w;

      // Insert command from History
      char Newc;
      int j;
      for(j = 0;  History[HistoryPos][j] != '\0'; ++j)
      {
        Newc = History[HistoryPos][j];

        input.buf[input.f++ % INPUT_BUF] = Newc;
        ++input.e;
        consputc(Newc);
      } 
}
Пример #2
0
void
putc(int c)
{
	cgaputc(c);
	if(uart != -1)
		uartputc(uart, c);
}
Пример #3
0
void
cgaconsputs(char* s, int n)
{
	ilock(&cgalock);
	while(n-- > 0)
		cgaputc(*s++);
	iunlock(&cgalock);
}
Пример #4
0
void
consputc(int c)
{
  if(c == BACKSPACE){
    uartputc('\b'); uartputc(' '); uartputc('\b');
  } else
    uartputc(c);
  cgaputc(c);
}
Пример #5
0
void
consputc(int c)
{
  if(panicked){
    cli();
    for(;;)
      ;
  }

  cgaputc(c);
}
Пример #6
0
static void
cgaputc(int c)
{
	int i;
	uchar *cga, *p;

	cga = CGA;

	if(c == '\n'){
		cgapos = cgapos/Width;
		cgapos = (cgapos+1)*Width;
	}
	else if(c == '\t'){
		i = 8 - ((cgapos/2)&7);
		while(i-- > 0)
			cgaputc(' ');
	}
	else if(c == '\b'){
		if(cgapos >= 2)
			cgapos -= 2;
		cgaputc(' ');
		cgapos -= 2;
	}
	else{
		cga[cgapos++] = c;
		cga[cgapos++] = Attr;
	}
	if(cgapos >= (Width*Height)-Postlen*2){
		memmove(cga, &cga[Width], Width*(Height-1));
		p = &cga[Width*(Height-1)-Postlen*2];
		for(i = 0; i < Width/2; i++){
			*p++ = ' ';
			*p++ = Attr;
		}
		cgapos -= Width;
	}
	cgacursor();
}
Пример #7
0
void
consputc(int c)
{
  if(panicked){
    cli();
    for(;;)
      ;
  }

  if(c == BACKSPACE){
    uartputc('\b'); uartputc(' '); uartputc('\b');
  } else
    uartputc(c);
  cgaputc(c);
}
Пример #8
0
void consputc(int c) {
	if (panicked) {
		cli();
		for (;;)
			;
	}

	if (c == BACKSPACE) {
		uartputc('\b');
		uartputc(' ');
		uartputc('\b');

	} else if (c != KEY_LEFT && c != KEY_RIGHT)
		uartputc(c);
	cgaputc(c);
}
Пример #9
0
void
consoleintr(int (*getc)(void))
{
  int c;

  acquire(&input.lock);
  while((c = getc()) >= 0){
    switch(c){
    case C('P'):  // Process listing.
      procdump();
      break;
    case C('U'):  // Kill line.
      while(input.e != input.w &&
            input.buf[(input.e-1) % INPUT_BUF] != '\n'){
        input.e--;
        consputc(BACKSPACE);
      }
      break;
    case C('H'): case '\x7f':  // Backspace
      if(input.f != input.w){
        input.e--;
        input.f--;
        consputc(BACKSPACE);
      }
      break;
    case KEY_LF: // Key Left
    {
      if(input.f != input.w)
      {
        input.f--;
        cgaputc(KEY_LF);
        
      }

      break;
    }
    case KEY_RT: // Key Right
    {
      int IsCanRight = input.e - input.f;
      if(IsCanRight > 0)
      {
        input.f++;
        cgaputc(KEY_RT);
        
      }

      break;
    }
    case KEY_UP: // Key Up
    {
      int NextHistoryPos = (HistoryPos + MAX_HISTORY_LENGTH - 1) % MAX_HISTORY_LENGTH;
      if(NextHistoryPos < MaxHistoryPos)
      {
        HistoryPos = NextHistoryPos;
        SelectFromHistory();
      }
      
      break;
    }
    case KEY_DN: // Key Down
    {
      if(HistoryPos < MaxHistoryPos)
      {
        HistoryPos = (HistoryPos + 1) % MAX_HISTORY_LENGTH;
        SelectFromHistory();
      }
      break;
    }
    default:
      if(c != 0 && input.e-input.r < INPUT_BUF)
      {
        c = (c == '\r') ? '\n' : c;
       
        if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF)
        {
          // Insert Command To History
          if(input.e > input.w) // if command exist
          {
            int j;
            for(j = 0; input.w+j<input.e; ++j)
            {
              History[HistoryWrite][j] = input.buf[(input.w +j) % INPUT_BUF];
            }
            History[HistoryWrite][j] = '\0';
            HistoryWrite = (HistoryWrite + 1) % MAX_HISTORY_LENGTH;
            MaxHistoryPos = (MaxHistoryPos == MAX_HISTORY_LENGTH) ? MAX_HISTORY_LENGTH : (MaxHistoryPos + 1);
            HistoryPos = HistoryWrite;
          }  

          input.buf[input.e++ % INPUT_BUF] = c;
          input.f = input.e;

          consputc(c);

          input.w = input.e;

          wakeup(&input.r);
        }
        else
        {
          input.buf[input.f++ % INPUT_BUF] = c;

          if(input.f > input.e)
          { 
            input.e = input.f;
          }

          consputc(c);
        }
      }
      break;
    }
   // cprintf("buf %s, read %d, write %d, edit %d\n final %d\n",input.buf,input.r,input.w,input.e, input.f);
  }
  release(&input.lock);
}
Пример #10
0
void
consputc(int c)
{
  cgaputc	(c);		//向显存写字符
}