/*--------------------------------------------------------------------------*/ void moveBackSingleWord(void) { reallocLineBuffer(); while ((cur_pos > 0) && (isspace(cur_line[cur_pos - 1]) )) { cur_pos -= 1; backSpace (); } while ((cur_pos > 0) && ( !isspace(cur_line[cur_pos - 1]) )) { cur_pos -= 1; backSpace (); } refreshLine(); }
/*--------------------------------------------------------------------------*/ void killLastWord(void) { reallocLineBuffer(); while ((cur_pos > 0) && (cur_line[cur_pos - 1] == VK_SPACE)) { cur_pos -= 1; backSpace (); } while ((cur_pos > 0) && (cur_line[cur_pos - 1] != VK_SPACE)) { cur_pos -= 1; backSpace (); } killCurrentPositionToEndLine(); }
/*--------------------------------------------------------------------------*/ void moveBeginningLine(void) { reallocLineBuffer(); while (cur_pos > 0) { cur_pos -= 1; backSpace(); } }
/*--------------------------------------------------------------------------*/ void killCurrentPositionToEndLine(void) { int i = 0; reallocLineBuffer(); for (i = cur_pos; i < max_pos; i++) cur_line[i] = '\0'; for (i = cur_pos; i < max_pos; i++) TerminalPutc(VK_SPACE); for (i = cur_pos; i < max_pos; i++) backSpace (); max_pos = cur_pos; }
/*--------------------------------------------------------------------------*/ void moveBackSingleChar(void) { reallocLineBuffer(); if (cur_pos > 0) { cur_pos -= 1; backSpace(); } }
/*--------------------------------------------------------------------------*/ void redrawLine(void) { int i =0; char *line = getCurrentLine(); displayPrompt(); for (i = max_pos; i > cur_pos; i--) backSpace (); if (line) { copyLine(line); FREE(line); line = NULL; } }
/*--------------------------------------------------------------------------*/ void deletePreviousChar(void) { reallocLineBuffer(); if (cur_pos > 0) { int i = 0; cur_pos -= 1; backSpace (); for (i = cur_pos; i < max_pos; i++) cur_line[i] = cur_line[i + 1]; max_pos -= 1; refreshLine(); } else TerminalBeep(); }
static void fetchCommand(char letra) { int i; if( letra == UP ) { for(i=0;i<index;i++) { backSpace(); } index = 0; if ( hist_pos == 0 ) hist_pos = MAX_COMMANDS_HIST; //write(STDIN,history[hist_pos-1],strlen(history[hist_pos-1])); //XXX hist_pos--; } if( letra == DOWN ) { for(i=0;i<index;i++) { backSpace(); } index=0; if(hist_pos == (MAX_COMMANDS_HIST -1)) hist_pos = -1; //write(STDIN,history[hist_pos+1],strlen(history[hist_pos+1])); //XXX hist_pos++; } }
void ATOM_Edit::onChar(ATOM_WidgetCharEvent *event) { ATOM_STACK_TRACE(ATOM_Edit::onChar); // 只读情况,不允许输入 if(EDITTYPE_READONLY & _editType) { return; } bool bSelect = false; unsigned short mbcc = event->mbcc; //if (mbcc == '\\') //{ // return; //} //ATOM_Edit不处理的键值 if( mbcc>= 0 && mbcc < 32 && mbcc != 8) { return; } if(_cusorOldPosition != _cusorNewPosition) { size_t s = 0,t = 0; _selectString = getSelectString(s,t); if(!_selectString.empty()) { deleteString(s,t); bSelect = true; } } //退格键 if (mbcc == 8) { if(!bSelect) backSpace(); return; } //处理 char *tc = reinterpret_cast<char*>(&mbcc); char tc2[3]; ZeroMemory(tc2, sizeof(tc2)); memcpy(tc2, tc, 2); insertText(tc2); }
size_t putchar(char c) { switch (c) { case '\n': breakLine(); return 0; case '\b': backSpace(); return 0; case '\t': tabulate(); return 0; default: return putc(c, STDOUT); break; } }
/*--------------------------------------------------------------------------*/ void refreshLine(void) { int i = 0; reallocLineBuffer(); /* write tail of string */ for (i = cur_pos; i < max_pos; i++) TerminalPutc(cur_line[i]); /* write a space at the end of the line in case we deleted one */ TerminalPutc(VK_SPACE); /* backup to original position */ for (i = max_pos + 1; i > cur_pos; i--) backSpace (); }
// Standard putchar void putchar(char c) { if (c == '\r') { backSpace(); } else if (c == '\n') { newLine(); } else if (c == 0x0f || c == '\t') { if (getCursorX() % 4 == 0) { int i = 0; for (i = 0; i < 4; ++i) { putChar(c); putC(' '); } } else while (getCursorX() % 4 != 0) { putChar(c); putC(' '); } } else if (c != 0) { putChar(c); putC(c); } }
void video_write_c(char * data) { make_atomic(); char a[] = { *data, defaultStyle }; char c = *data; if (c == '\r') { backSpace(); } else if (c == '\n') { newLine(); } else if (c == 0x0f || c == '\t') { if (getCursorX() % 4 == 0) { int i = 0; for (i = 0; i < 4; ++i) { putChar(' '); *a = ' '; video_write(a, 2); } } else while (getCursorX() % 4 != 0) { putChar(' '); *a = ' '; video_write(a,2); incrementCursor(); } } else if (c != 0) { putChar(c); if(current_video_mode->visible) { video_write(a,2); incrementCursor(); } else { setCursor(FALSE); incrementCursor(); setCursor(TRUE); } } release_atomic(); }
static int getCommand() { char letra; int i; for ( i= 0; i < SHELL_BUFFER_LENGTH; i++) { shellBuffer[i]=0x00; } index = 0; do{ kprintf("%s",PROMPT); kprintf("%s$ ",shellGetCWD()); do{ letra = getchar(); if( isArrow(letra)) { fetchCommand(letra); } else if ( letra == '\b') { if ( index > 0) { backSpace(); index--; } } else if( letra == '\t') { //autoFill(); } else { shellBuffer[index++] = letra; kprintf("%c",letra); } }while (letra != '\n' && index < MAX_COMM_LENGTH); /*Esta condicion se cumple si solo presiono enter * asi no muestro error y muestro el prompt otra vez */ if( index <= 1 ) index = 0; if(index >= (MAX_COMM_LENGTH - 1)) kprintf("\n"); }while( index == 0); /*Guarda el comando en el historial*/ commitCommand(); /*Recupero la primera palabra del shell y la trato como si fuera un comando*/ getCommandFromPrompt(shellBuffer); /*Recupero los flags, estos son de la forma * -flag * Si no hay flags, recupero los parametros */ if(getFlagsFromPrompt(shellBuffer) == 0) getParamsFromPrompt(shellBuffer,strlen(command)); for ( i = 0; i < COMM_QTY; i++ ) { if ( !strcmp(command,myCommands[i].command)) return myCommands[i].code; } return -1; }
//------------------------------------------------------------------------------ // onBackSpace() -- //------------------------------------------------------------------------------ bool Field::onBackSpace() { backSpace(); return true; }
int Edit::processEvent (const Event& event) { if (event.key > 0 && event.key < 256 && isprint (event.key)) { processText (event); return 1; } switch (event.key) { case KB_UP: case KB_KP_UP: up (); break; case KB_DOWN: case KB_KP_DOWN: down (); break; case KB_LEFT: case KB_KP_LEFT: left (); break; case KB_RIGHT: case KB_KP_RIGHT: right (); break; case KB_BKSPACE: backSpace (); break; case KB_TAB: tab (); break; case KB_HOME: case KB_KP_HOME: home (); break; case KB_END: case KB_KP_END: end (); break; case KB_INS: case KB_KP_INS: ins (); break; case KB_DEL: case KB_KP_DEL: del (); break; case KB_ESC: mExitKey = KB_ESC; postEvent (Event (EV_QUIT)); break; case KB_ENTER: strncpy (mpRealText, mpText, mLength); mpRealText[mLength] = '\0'; if (mpHist != 0) mpHist->add (mpText); mExitKey = KB_ENTER; postEvent (Event (EV_QUIT)); break; case EV_COLOR_CHANGE: draw (); return Popup::processEvent (event); default: return Popup::processEvent (event); } return 1; }
Calculator::Calculator(QWidget *parent) : QWidget(parent), ui(new Ui::Calculator), memory(0), result(0), currOperand(0), currOper("") { ui->setupUi(this); QSignalMapper *numberPressed = new QSignalMapper(this); { QObject::connect(ui->n0Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n1Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n2Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n3Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n4Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n5Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n6Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n7Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n8Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->n9Button, SIGNAL(clicked()), numberPressed, SLOT(map())); QObject::connect(ui->nDotButton, SIGNAL(clicked()), numberPressed, SLOT(map())); } { numberPressed->setMapping(ui->n0Button, "0"); numberPressed->setMapping(ui->n1Button, "1"); numberPressed->setMapping(ui->n2Button, "2"); numberPressed->setMapping(ui->n3Button, "3"); numberPressed->setMapping(ui->n4Button, "4"); numberPressed->setMapping(ui->n5Button, "5"); numberPressed->setMapping(ui->n6Button, "6"); numberPressed->setMapping(ui->n7Button, "7"); numberPressed->setMapping(ui->n8Button, "8"); numberPressed->setMapping(ui->n9Button, "9"); numberPressed->setMapping(ui->nDotButton, "."); } QObject::connect(numberPressed, SIGNAL(mapped(QString)), this, SLOT(appendToDisplayString(QString))); QObject::connect(this, SIGNAL(displayStringChanged(QString)), ui->lineEdit, SLOT(setText(QString))); QObject::connect(ui->cClearButton, SIGNAL(clicked()), this, SLOT(clearDisplayString())); QObject::connect(ui->cCEButton, SIGNAL(clicked()), this, SLOT(clearExpression())); QObject::connect(ui->cACButton, SIGNAL(clicked()), this, SLOT(clearAll())); QObject::connect(ui->cBackSpaceButton, SIGNAL(clicked()), this, SLOT(backSpace())); QSignalMapper *operatorPressed = new QSignalMapper; QObject::connect(ui->oDivButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); QObject::connect(ui->oMultButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); QObject::connect(ui->oPlusButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); QObject::connect(ui->oMinusButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); QObject::connect(ui->oEqButton, SIGNAL(clicked()), operatorPressed, SLOT(map())); operatorPressed->setMapping(ui->oDivButton, "/"); operatorPressed->setMapping(ui->oMultButton, "*"); operatorPressed->setMapping(ui->oPlusButton, "+"); operatorPressed->setMapping(ui->oMinusButton, "-"); operatorPressed->setMapping(ui->oEqButton, "="); QObject::connect(operatorPressed, SIGNAL(mapped(QString)), this, SLOT(operButtonPressed(QString))); QObject::connect(ui->nDotButton, SIGNAL(clicked(bool)), ui->nDotButton, SLOT(setEnabled(bool))); QObject::connect(ui->mClearButton, SIGNAL(clicked()), this, SLOT(clearMemory())); QObject::connect(ui->mReadButton, SIGNAL(clicked()), this, SLOT(memoryRead())); QObject::connect(ui->mPlusButton, SIGNAL(clicked()), this, SLOT(memoryAdd())); QObject::connect(ui->mMinusButton, SIGNAL(clicked()), this, SLOT(memoryDec())); }