Exemplo n.º 1
0
void TESession::clearHistory()
{
  if (history().isOn()) {
    int histSize = history().getSize();
    setHistory(HistoryTypeNone());
    if (histSize)
      setHistory(HistoryTypeBuffer(histSize));
    else
      setHistory(HistoryTypeFile());
  }
}
Exemplo n.º 2
0
//Reset the console
void pConsole::reset()
{
	clear();
	
	setTextInteractionFlags( Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard | Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard | Qt::TextEditable );
	setUndoRedoEnabled( false );
	setTabStopWidth( 30 );
	
	QFont font = QFont( "Bitstream Vera Sans Mono", 11 );
	font.setBold( true );
	setFont( font );
	
	QPalette pal = viewport()->palette();
	pal.setColor( viewport()->backgroundRole(), QColor( Qt::black ) );
	pal.setColor( viewport()->foregroundRole(), QColor( Qt::white ) );
	viewport()->setPalette( pal );
	
	mColors[ ctCommand ] = Qt::white;
	mColors[ ctError ] = Qt::red;
	mColors[ ctOutput ] = Qt::blue;
	mColors[ ctCompletion ] = Qt::green;
	
	mRecordedScript.clear();
	mTypedCommand.clear();
	
	setHistory( QStringList() );
	setPromptVisible( true );
	setPrompt( "@:/> " );
}
Exemplo n.º 3
0
// The function deletes the histories for the transient analysis.
void circuit::deleteHistory (void) {
  if (histories != NULL) {
    delete[] histories;
    histories = NULL;
  }
  setHistory (false);
}
Exemplo n.º 4
0
void vcvs::initTR (void) {
  nr_double_t t = getPropertyDouble ("T");
  initDC ();
  deleteHistory ();
  if (t > 0.0) {
    setHistory (true);
    initHistory (t);
    setC (VSRC_1, NODE_1, 0.0); setC (VSRC_1, NODE_4, 0.0);
  }
}
Exemplo n.º 5
0
void vccs::initTR (void) {
  nr_double_t t = getPropertyDouble ("T");
  initDC ();
  deleteHistory ();
  if (t > 0.0) {
    setISource (true);
    setHistory (true);
    initHistory (t);
    clearY ();
  }
}
Exemplo n.º 6
0
// Initialize transient analysis.
void digital::initTR (void) {
  nr_double_t t = getPropertyDouble ("t");
  initDC ();
  deleteHistory ();
  if (t > 0.0) {
    delay = true;
    setHistory (true);
    initHistory (t);
    setC (VSRC_1, NODE_OUT, 1);
  }
}
Exemplo n.º 7
0
void cccs::initTR (void) {
  nr_double_t t = getPropertyDouble ("T");
  initDC ();
  deleteHistory ();
  if (t > 0.0) {
    setISource (true);
    setHistory (true);
    initHistory (t);
    setB (NODE_1, VSRC_1, +1.0); setB (NODE_2, VSRC_1, +0.0);
    setB (NODE_3, VSRC_1, -0.0); setB (NODE_4, VSRC_1, -1.0);
  }
}
Exemplo n.º 8
0
bool Gesture::analyse(Finger *fingers, int count) {

	int historySize = history.size();

	if (iteration < minimalIterationCount * pow((float)minimalIterationFactor/100, historySize + 1)) {
		iteration++;
		return false;
	}

	bool minDistance = false;

	if (historySize > 0) {

		for (int i = 0; i < historySize && !minDistance; i++) {
			float dist = distance(fingers[i], history[i]);
			//WacomTrace("%d | %f, %f, %f, %f | %f \n", i, fingers[i].X, history[i].X, fingers[i].Y, history[i].Y, dist);
			if (dist > (float)minimalDistance/1000)
				minDistance = true;
		}

		if (!minDistance)
			return false;

	}

	//cout << "hS: " << historySize << endl;

	for (int i = 0; i < count && i < historySize; i++) {
		float theta = atan2(-fingers[i].pos.y + history[i].pos.y, fingers[i].pos.x - history[i].pos.x);
		Move zone = getZone(theta);
		if (movements[i].size() == 0 || zone != movements[i].back()) {
			movements[i].push_back(zone);
		}
	}

	setHistory(fingers, count);
	iteration = 0;

	if (monitor()) {
		reset();
	}

	return true;

}
Exemplo n.º 9
0
void tline::initTR (void) {
  nr_double_t l = getPropertyDouble ("L");
  nr_double_t z = getPropertyDouble ("Z");
  deleteHistory ();
  if (l > 0.0) {
    setVoltageSources (2);
    allocMatrixMNA ();
    setHistory (true);
    initHistory (l / C0);
    setB (NODE_1, VSRC_1, +1); setB (NODE_2, VSRC_2, +1);
    setC (VSRC_1, NODE_1, +1); setC (VSRC_2, NODE_2, +1);
    setD (VSRC_1, VSRC_1, -z); setD (VSRC_2, VSRC_2, -z); 
  } else {
    setVoltageSources (1);
    allocMatrixMNA ();
    voltageSource (VSRC_1, NODE_1, NODE_2);
  }
}
Exemplo n.º 10
0
void
CNameCache::apply (const CNameCache& cache)
{
  for (EntryMap::const_iterator i = cache.entries.begin ();
       i != cache.entries.end (); ++i)
    set (i->first, i->second);

  for (std::set<valtype>::const_iterator i = cache.deleted.begin ();
       i != cache.deleted.end (); ++i)
    remove (*i);

  for (std::map<valtype, CNameHistory>::const_iterator i
        = cache.history.begin (); i != cache.history.end (); ++i)
    setHistory (i->first, i->second);

  for (std::map<ExpireEntry, bool>::const_iterator i
        = cache.expireIndex.begin (); i != cache.expireIndex.end (); ++i)
    expireIndex[i->first] = i->second;
}
Exemplo n.º 11
0
void JobHistoryView::setJobs( JobList jobs )
{
	setHistory(jobs.jobHistories());
	mJobs = jobs;
}
Exemplo n.º 12
0
HistoryLineEdit::HistoryLineEdit(QWidget* parent): QLineEdit(parent), m_completer(nullptr), m_model(nullptr)
{
    setHistory(QStringList());
}
Exemplo n.º 13
0
void HistoryManager::load()
{
    loadSettings();

    QFile historyFile(QStandardPaths::writableLocation(QStandardPaths::DataLocation)
        + QLatin1String("/history"));
    if (!historyFile.exists())
        return;
    if (!historyFile.open(QFile::ReadOnly)) {
        qWarning() << "Unable to open history file" << historyFile.fileName();
        return;
    }

    QList<HistoryItem> list;
    QDataStream in(&historyFile);
    // Double check that the history file is sorted as it is read in
    bool needToSort = false;
    HistoryItem lastInsertedItem;
    QByteArray data;
    QDataStream stream;
    QBuffer buffer;
    stream.setDevice(&buffer);
    while (!historyFile.atEnd()) {
        in >> data;
        buffer.close();
        buffer.setBuffer(&data);
        buffer.open(QIODevice::ReadOnly);
        quint32 ver;
        stream >> ver;
        if (ver != HISTORY_VERSION)
            continue;
        HistoryItem item;
        stream >> item.url;
        stream >> item.dateTime;
        stream >> item.title;

        if (!item.dateTime.isValid())
            continue;

        if (item == lastInsertedItem) {
            if (lastInsertedItem.title.isEmpty() && !list.isEmpty())
                list[0].title = item.title;
            continue;
        }

        if (!needToSort && !list.isEmpty() && lastInsertedItem < item)
            needToSort = true;

        list.prepend(item);
        lastInsertedItem = item;
    }
    if (needToSort)
        qSort(list.begin(), list.end());

    setHistory(list, true);

    // If we had to sort re-write the whole history sorted
    if (needToSort) {
        m_lastSavedUrl = QString();
        m_saveTimer->changeOccurred();
    }
}
Exemplo n.º 14
0
int main(int argc, char * argv[], char **envp)
{
    //The following two functions catch and process the interrupt and stop signals
    //AKA signals sent by the Ctrl-C and Ctrl-Z commands
    if (signal(SIGINT,signal_catcher)==SIG_ERR)
    {
        perror("Sigset cannot set SIGINT");
        exit(SIGINT);
    }
    if (signal(SIGTSTP, signal_catcher)==SIG_ERR)
    {
        perror("Sigset can not set SIGTSTP");
        exit(SIGTSTP);
    }
    
    //Declaring and initializing variables to be used later
    initHistory();
    initAlias();
    int this_input = 0;
    
    char * input = (char *) malloc(sizeof(char)*64);
    strcpy (input, "noexit");
    char *shellname = (char *) malloc(sizeof(char)*32);
    strcpy (shellname, "myshell");
    
    setShellName(shellname);
    
    printf ("[%s]%% ", shellname);
    input = getLine(input, 100);
    
    //Making sure the program does not crash if the input simply the return key
    while (strcmp(input,"\0") == 0)
    {
        printf ("[%s]%% ", shellname);
        input = getLine(input, 100);
    }
    
    setHistory(input);
    breakLine (input);
    this_input = whichInput();
    
    char ** argrv = getargrv();
    int argrc = getargrc();
    
    int loop = 1;
    
    while (loop != 0)
    {
        //Loop and process commands until the exist command is entered
        if(this_input==4) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                //printf("Before forking PID:%d\n", getpid());
                int pid = fork();
                if(pid==0)
                {
                    //sleep(2); //putting a delay in to emphasize background process
                    //printf("\nchild PID: %d\n", getpid());
                    decrargrc();
                    list();
                    //printf("\nIn the child process - ended.\n\n");
                    return 0;
                } else
                {
                    //printf("PPID:%d\n", getpid());
                    //printf("In the parent process.\n");
                    printf("%s process running in background", argrv[0]);
                }
            } else
                list();
            
        } else if(this_input==3) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    pwd();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                pwd();
        } else if(this_input==6) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    prompt();
                    shellname = getShellName();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
            {
                prompt();
                shellname = getShellName();
            }
        } else if(this_input==2) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    dirChange();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                dirChange();
        } else if(this_input==5) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    mypid();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                mypid();
        } else if(this_input==1) {
            if (getargrc() == 1)
            {
                loop = 0;
                free (input);
                free (shellname);
                
                input = NULL;
                shellname = NULL;
                
                freeDynamicMem();
                return 0;
            } else {
                printf("%s: Arguments not valid.", argrv[0]);
            }
        } else if(this_input==7) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    printHistory();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                printHistory();
        } else if(this_input==8) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    printf("\n***I've put a 3 second delay in to emphasize this background process\n");
                    sleep(3); //putting a delay in to emphasize background proces
                    decrargrc();
                    printEnv(envp);
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                printEnv(envp);
        }else if(this_input==9) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    alias();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                alias();
        }else if(this_input==10) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    murder();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                murder();
        }else {
            nocmd(input);
        }
        printf ("\n[%s]%% ", shellname);
        input = getLine(input, 100);
        while (strcmp(input,"\0") == 0)
        {
            printf ("[%s]%% ", shellname);
            input = getLine(input, 100);
        }
        setHistory(input);
        breakLine (input);
        this_input = whichInput();
        argrv = getargrv();
        argrc = getargrc();
    }
    return 0;
}
Exemplo n.º 15
0
void JsonEngine::processEvent(Event &event)
{
	setHistory(event.at<TreeModelItem>(0));
}
Exemplo n.º 16
0
bool QgsLayerMetadata::readMetadataXml( const QDomElement &metadataElement )
{
  QDomNode mnl;
  QDomElement mne;

  // set identifier
  mnl = metadataElement.namedItem( QStringLiteral( "identifier" ) );
  mIdentifier = mnl.toElement().text();

  // set parent identifier
  mnl = metadataElement.namedItem( QStringLiteral( "parentidentifier" ) );
  mParentIdentifier = mnl.toElement().text();

  // set language
  mnl = metadataElement.namedItem( QStringLiteral( "language" ) );
  mLanguage = mnl.toElement().text();

  // set type
  mnl = metadataElement.namedItem( QStringLiteral( "type" ) );
  mType = mnl.toElement().text();

  // set title
  mnl = metadataElement.namedItem( QStringLiteral( "title" ) );
  mTitle = mnl.toElement().text();

  // set abstract
  mnl = metadataElement.namedItem( QStringLiteral( "abstract" ) );
  mAbstract = mnl.toElement().text();

  // set keywords
  QDomNodeList keywords = metadataElement.elementsByTagName( QStringLiteral( "keywords" ) );
  mKeywords.clear();
  for ( int i = 0; i < keywords.size(); i++ )
  {
    QStringList keywordsList;
    mnl = keywords.at( i );
    mne = mnl.toElement();

    QDomNodeList el = mne.elementsByTagName( QStringLiteral( "keyword" ) );
    for ( int j = 0; j < el.size(); j++ )
    {
      keywordsList.append( el.at( j ).toElement().text() );
    }
    addKeywords( mne.attribute( QStringLiteral( "vocabulary" ) ), keywordsList );
  }

  // set fees
  mnl = metadataElement.namedItem( QStringLiteral( "fees" ) );
  mFees = mnl.toElement().text();

  // constraints
  QDomNodeList constraintsList = metadataElement.elementsByTagName( QStringLiteral( "constraints" ) );
  mConstraints.clear();
  for ( int i = 0; i < constraintsList.size(); i++ )
  {
    mnl = constraintsList.at( i );
    mne = mnl.toElement();
    addConstraint( QgsLayerMetadata::Constraint( mne.text(), mne.attribute( QStringLiteral( "type" ) ) ) );
  }

  // rights
  QDomNodeList rightsNodeList = metadataElement.elementsByTagName( QStringLiteral( "rights" ) );
  QStringList rightsList;
  for ( int i = 0; i < rightsNodeList.size(); i++ )
  {
    mnl = rightsNodeList.at( i );
    mne = mnl.toElement();
    rightsList.append( mne.text() );
  }
  setRights( rightsList );

  // licenses
  QDomNodeList licensesNodeList = metadataElement.elementsByTagName( QStringLiteral( "license" ) );
  QStringList licensesList;
  for ( int i = 0; i < licensesNodeList.size(); i++ )
  {
    mnl = licensesNodeList.at( i );
    mne = mnl.toElement();
    licensesList.append( mne.text() );
  }
  setLicenses( licensesList );

  // encoding
  mnl = metadataElement.namedItem( QStringLiteral( "encoding" ) );
  mEncoding = mnl.toElement().text();

  // crs
  mnl = metadataElement.namedItem( QStringLiteral( "crs" ) );
  if ( !mCrs.readXml( mnl ) )
    mCrs = QgsCoordinateReferenceSystem();

  // extent
  mnl = metadataElement.namedItem( QStringLiteral( "extent" ) );
  QgsLayerMetadata::Extent metadataExtent;

  // spatial extent
  QDomNodeList spatialList = mnl.toElement().elementsByTagName( QStringLiteral( "spatial" ) );
  QList< QgsLayerMetadata::SpatialExtent > metadataSpatialExtents;
  for ( int i = 0; i < spatialList.size(); i++ )
  {
    mnl = spatialList.at( i );
    mne = mnl.toElement();
    QgsLayerMetadata::SpatialExtent se = QgsLayerMetadata::SpatialExtent();
    se.extentCrs = QgsCoordinateReferenceSystem( mne.attribute( QStringLiteral( "crs" ) ) );
    se.bounds = QgsBox3d();
    se.bounds.setXMinimum( mne.attribute( QStringLiteral( "minx" ) ).toDouble() );
    se.bounds.setYMinimum( mne.attribute( QStringLiteral( "miny" ) ).toDouble() );
    se.bounds.setZMinimum( mne.attribute( QStringLiteral( "minz" ) ).toDouble() );
    se.bounds.setXMaximum( mne.attribute( QStringLiteral( "maxx" ) ).toDouble() );
    se.bounds.setYMaximum( mne.attribute( QStringLiteral( "maxy" ) ).toDouble() );
    se.bounds.setZMaximum( mne.attribute( QStringLiteral( "maxz" ) ).toDouble() );
    metadataSpatialExtents.append( se );
  }
  metadataExtent.setSpatialExtents( metadataSpatialExtents );

  // temporal extent
  mnl = metadataElement.namedItem( QStringLiteral( "extent" ) );
  QDomNodeList temporalList = mnl.toElement().elementsByTagName( QStringLiteral( "temporal" ) );
  QList<QgsDateTimeRange> metadataDates;
  for ( int j = 0; j < temporalList.size(); j++ )
  {
    mnl = temporalList.at( j );
    QDomNodeList instantList = mnl.toElement().elementsByTagName( QStringLiteral( "instant" ) );
    for ( int i = 0; i < instantList.size(); i++ )
    {
      mnl = instantList.at( i );
      QDateTime d = QDateTime().fromString( mnl.toElement().text(), Qt::ISODate );
      QgsDateTimeRange date = QgsDateTimeRange( d, d );
      metadataDates << date;
    }
    QDomNodeList periodList = mnl.toElement().elementsByTagName( QStringLiteral( "period" ) );
    for ( int i = 0; i < periodList.size(); i++ )
    {
      QDomNode begin = periodList.at( i ).namedItem( QStringLiteral( "start" ) );
      QDomNode end = periodList.at( i ).namedItem( QStringLiteral( "end" ) );
      QDateTime beginDate = QDateTime().fromString( begin.toElement().text(), Qt::ISODate );
      QDateTime endDate = QDateTime().fromString( end.toElement().text(), Qt::ISODate );
      QgsDateTimeRange date = QgsDateTimeRange( beginDate, endDate );
      metadataDates << date;
    }
  }
  metadataExtent.setTemporalExtents( metadataDates );
  setExtent( metadataExtent );

  // contact
  QDomNodeList contactsList = metadataElement.elementsByTagName( QStringLiteral( "contact" ) );
  mContacts.clear();
  for ( int i = 0; i < contactsList.size(); i++ )
  {
    mnl = contactsList.at( i );
    mne = mnl.toElement();

    QgsLayerMetadata::Contact oneContact;
    oneContact.name = mne.namedItem( QStringLiteral( "name" ) ).toElement().text();
    oneContact.organization = mne.namedItem( QStringLiteral( "organization" ) ).toElement().text();
    oneContact.position = mne.namedItem( QStringLiteral( "position" ) ).toElement().text();
    oneContact.voice = mne.namedItem( QStringLiteral( "voice" ) ).toElement().text();
    oneContact.fax = mne.namedItem( QStringLiteral( "fax" ) ).toElement().text();
    oneContact.email = mne.namedItem( QStringLiteral( "email" ) ).toElement().text();
    oneContact.role = mne.namedItem( QStringLiteral( "role" ) ).toElement().text();

    QList< QgsLayerMetadata::Address > addresses;
    QDomNodeList addressList = mne.elementsByTagName( QStringLiteral( "contactAddress" ) );
    for ( int j = 0; j < addressList.size(); j++ )
    {
      QDomElement addressElement = addressList.at( j ).toElement();
      QgsLayerMetadata::Address oneAddress;
      oneAddress.address = addressElement.namedItem( QStringLiteral( "address" ) ).toElement().text();
      oneAddress.administrativeArea = addressElement.namedItem( QStringLiteral( "administrativearea" ) ).toElement().text();
      oneAddress.city = addressElement.namedItem( QStringLiteral( "city" ) ).toElement().text();
      oneAddress.country = addressElement.namedItem( QStringLiteral( "country" ) ).toElement().text();
      oneAddress.postalCode = addressElement.namedItem( QStringLiteral( "postalcode" ) ).toElement().text();
      oneAddress.type = addressElement.namedItem( QStringLiteral( "type" ) ).toElement().text();
      addresses << oneAddress;
    }
    oneContact.addresses = addresses;
    addContact( oneContact );
  }

  // links
  mnl = metadataElement.namedItem( QStringLiteral( "links" ) );
  mne = mnl.toElement();
  mLinks.clear();
  QDomNodeList el = mne.elementsByTagName( QStringLiteral( "link" ) );
  for ( int i = 0; i < el.size(); i++ )
  {
    mne = el.at( i ).toElement();
    QgsLayerMetadata::Link oneLink;
    oneLink.name = mne.attribute( QStringLiteral( "name" ) );
    oneLink.type = mne.attribute( QStringLiteral( "type" ) );
    oneLink.url = mne.attribute( QStringLiteral( "url" ) );
    oneLink.description = mne.attribute( QStringLiteral( "description" ) );
    oneLink.format = mne.attribute( QStringLiteral( "format" ) );
    oneLink.mimeType = mne.attribute( QStringLiteral( "mimeType" ) );
    oneLink.size = mne.attribute( QStringLiteral( "size" ) );
    addLink( oneLink );
  }

  // history
  QDomNodeList historyNodeList = metadataElement.elementsByTagName( QStringLiteral( "history" ) );
  QStringList historyList;
  for ( int i = 0; i < historyNodeList.size(); i++ )
  {
    mnl = historyNodeList.at( i );
    mne = mnl.toElement();
    historyList.append( mne.text() );
  }
  setHistory( historyList );

  return true;
}
Exemplo n.º 17
0
void consoleintr(int (*getc)(void)) {
	int c, doprocdump = 0;
	// int historyInd = 1; //when arr not full we should put here the last  command written, most cases, when full davka should be 15
	acquire(&cons.lock);
	int tmp;
	while ((c = getc()) >= 0) {
		switch (c) {
		case C('P'):  // Process listing.
					doprocdump = 1; // procdump() locks cons.lock indirectly; invoke later
		break;
		case C('U'):  // Kill line.
					kill_line();
		break;
		case C('H'):
		case '\x7f':  // Backspace
			if (input.e != input.w) { //regular caret
				input.e--;
				input.f--;
				if (input.e < input.f) {  // middle caret
					midflag = input.f - input.e;
					int i = input.e;
					while (i < input.f) {
						input.buf[i % INPUT_BUF] =
								input.buf[(i + 1) % INPUT_BUF];
						i++;
					}
				}
				consputc(BACKSPACE);
				midflag = 0;
			}
			break;
		case KEY_LEFT: // Left arrow
			if (input.e != input.w) {
				input.e--;
				consputc(KEY_LEFT);
			}
			break;
		case KEY_RIGHT: // Right arrow
			if (input.f > input.e) {
				input.e++;
				consputc(KEY_RIGHT);
			}
			break;
		case KEY_UP: // Key Up
			if (historyInd != 0)
				kill_line();
			if (historyList.size > 0) {
				char buffer[INPUT_BUF];
				tmp = (historyInd - 1) % historyList.size;
				if (tmp > -1) {
					historyInd = tmp;
					if (history(buffer, historyInd) == 0) {
						setHistory(buffer);
					} else
						panic("history");
				}
			}
			break;
		case KEY_DOWN: // Key Down
			kill_line();
			if (historyInd < historyList.size - 1) {
				char buffer[INPUT_BUF];
				historyInd = (historyInd + 1) % MAX_HISTORY;
				if (historyInd < historyList.size) {
					if (history(buffer, historyInd) == 0) {
						setHistory(buffer);
					} else
						panic("history");
				} else
					kill_line();
			} else if (historyInd == historyList.size - 1)
				kill_line();
			break;
		default:
			if (c != 0 && input.f - input.r < INPUT_BUF) {
				c = (c == '\r') ? '\n' : c;
				if (c == '\n') {
					// if any command is currently written, first record it in the history books
					if (input.f >= input.w) {
						updateHistory();
					}
				}
				//*** regular caret ***
				if (input.e >= input.f) {
					input.buf[input.e++ % INPUT_BUF] = c;
					consputc(c);
				}
				//*** middle caret ***
				else {
					if (c == '\n') {
						input.buf[input.f % INPUT_BUF] = c;
						input.e = input.f + 1;
						consputc(c);
					} else {
						int index = input.f;
						while (index > input.e) { // first shift by one each char in buffer from caret to the end
							input.buf[index % INPUT_BUF] = input.buf[(index - 1)
																	 % INPUT_BUF];
							index--;
						}
						input.buf[input.e % INPUT_BUF] = c; // Write new char in buffer
						int i = input.e;
						index = input.f + 1;
						while (i < index) // Print those chars from buffer to console
							consputc(input.buf[i++ % INPUT_BUF]);
						i = input.e;
						index = input.f;
						while (i < index) { // move caret back to it's place after the new character
							consputc(KEY_LEFT);
							i++;
						}
						input.e++;
					}
				}
				input.f++;
				if (c == '\n' || c == C('D') || input.f == input.r + INPUT_BUF) {
					input.w = input.f;
					input.e = input.f;
					wakeup(&input.r);
				}
			}
			break;
		}
	}
	release(&cons.lock);
	if (doprocdump) {
		procdump();  // now call procdump() wo. cons.lock held
	}
}