예제 #1
0
int main() {		//main function
	int ch, b, x;
	char c;
	while(1){
		system("clear");
		home();
		scanf("%d",&ch);
			if(ch == 4)
				break;
		switch(ch)
		{
			case 1:
				x = elogin();
				if(x == 0){
					printf("\tWarning!! Incorrect Password or Username\n\n");
					printf("press c to continue ");
					getchar();
					scanf("%c", &c);
					break;	
				}
				b = 1;
				maintry(b);	
				break;
			case 2:
				ulogin();		
				break;
			case 3:
				create();
				break;
 			case 4:
				exit(0);					;
				break;
 			default:
				printf("\nwrong choice");
				break;
		}
	}			

}		
예제 #2
0
static void
xmore(char *s)
{
	if(flags.toplin) {
		curs(tlx, tly);
		if(tlx + 8 > CO) putsym('\n'), tly++;
	}

	if(flags.standout)
		standoutbeg();
	putstr("--More--");
	if(flags.standout)
		standoutend();

	xwaitforspace(s);
	if(flags.toplin && tly > 1) {
		home();
		cl_end();
		docorner(1, tly-1);
	}
	flags.toplin = 0;
}
예제 #3
0
QString SSHPrivateIdentityFile()
{
   QVariant value(Get("SSHPrivateIdentityFile"));
   if (!value.isNull()) return value.value<QString>();

   QString home(QDir::homePath());
   if (home.isEmpty()) return QString();

   QString fileName(home + "/.ssh/id_rsa");
   QFileInfo info(fileName); 
   if (info.exists()) return fileName;

   fileName = home + "/.ssh/id_dsa";
   info.setFile(fileName);
   if (info.exists()) return fileName;

   fileName = home + "/.ssh/identity";
   info.setFile(fileName);
   if (info.exists()) return fileName;

   return QString();
}
예제 #4
0
void
panic(const char *fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
    if (panicking++)
        exit(1);	/* avoid loops - this should never happen */
    home();
    puts(" Suddenly, the dungeon collapses.");
    fputs(" ERROR:  ", stdout);
    vprintf(fmt, ap);
    va_end(ap);
#ifdef DEBUG
#ifdef UNIX
    if (!fork())
        abort();	/* generate core dump */
#endif	/* UNIX */
#endif	/* DEBUG */
    more();			/* contains a fflush() */
    done("panicked");
}
예제 #5
0
/* spaceflag: TRUE if space required */
void xmore(boolean spaceflag)
{
    if(flags.topl != 0) {
        curs(tlx, tly);
        
        if((tlx + 8) > COLNO) {
            putsym('\n');
            ++tly;
        }
    }

    putstr("--More--");
    xwaitforspace(spaceflag);

    if((flags.topl != 0) && (tly > 1)) {
        home();
        cl_end();
        docorner(1, tly - 1);
    }

    flags.topl = 0;
}
예제 #6
0
void SerialLCD::init () {
	delay(500);
	switch (g_interface) {
		case RS232:
			LCD_SERIAL.begin(g_baudrate);
			break;
		case I2C:
			Wire.begin();
			break;
		case SPI:
			pinMode(g_sspin, OUTPUT);
			pinMode(g_sclk, OUTPUT);
			pinMode(g_mosi, OUTPUT);
			pinMode(g_miso, INPUT);
			digitalWrite(g_sspin, HIGH);
			break;
	}
	on();
	clear();
	blinkOff();
	cursorOff(); 
	home();
}
예제 #7
0
void gcWebControl::handleKeyEvent(int eventCode)
{
	switch (eventCode)
	{
		case IDC_BACK:						m_pChromeBrowser->back(); break;
		case IDC_FORWARD:					m_pChromeBrowser->forward(); break;
		case IDC_DEV_TOOLS:					break;
		case IDC_DEV_TOOLS_CONSOLE:			break;
		case IDC_PRINT:						m_pChromeBrowser->print(); break;
		case IDC_RELOAD:					m_pChromeBrowser->refresh(); break;
		case IDC_RELOAD_IGNORING_CACHE:		m_pChromeBrowser->refresh(true); break;
		case IDC_HOME:						home(); break;
		case IDC_STOP:						m_pChromeBrowser->stop(); break;
		case IDC_VIEW_SOURCE:				m_pChromeBrowser->viewSource(); break;
		case IDC_ZOOM_MINUS:				m_pChromeBrowser->zoomOut(); break;
		case IDC_ZOOM_NORMAL:				m_pChromeBrowser->zoomNormal(); break;
		case IDC_ZOOM_PLUS:					m_pChromeBrowser->zoomIn(); break;

		case IDC_FIND: 
			onFindEvent();
			break;
	};
}
예제 #8
0
파일: yadayuse.cpp 프로젝트: AlekSi/Jabbin
QString YaDayUse::uiPath() const
{
#ifdef Q_WS_WIN
	QString base = QDir::homePath();
	WCHAR str[MAX_PATH+1] = { 0 };
	if (SHGetSpecialFolderPathW(0, str, CSIDL_APPDATA, true))
		base = QString::fromWCharArray(str);

	QDir uihome(base + "/Jabbin");
	if(!uihome.exists()) {
		QDir home(base);
		home.mkdir("Jabbin");
	}
#else
	QDir uihome(QDir::homeDirPath() + "/.jabbin");
	if(!uihome.exists()) {
		QDir home = QDir::home();
		home.mkdir(".jabbin");
		chmod(QFile::encodeName(uihome.path()), 0700);
	}
#endif
	return uihome.absoluteFilePath("ui");
}
예제 #9
0
  void
  Log::EnsureOpen()
  {
    if (!handle) {
      char* log = getenv("ADR_LOG_FILE");
      if (log && log[0]) {
        handle = fopen(log, "w");
      } else {
        #ifdef WIN32
          handle = fopen("C:/audiere_debug.log", "w");
        #else
          std::string home(getenv("HOME"));
          handle = fopen((home + "/audiere_debug.log").c_str(), "w");
        #endif
      }
        
      if (!handle) {
        handle = stderr;
      }

      atexit(Close);
    }
  }
예제 #10
0
파일: main.c 프로젝트: Brayan1/Danake
static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
    char buffer[Tbuffer];
    buffer[0] = '\x0';

    switch (ev) {
        case MG_AUTH:
            return MG_MORE;

        case MG_REQUEST:
	
			mg_send_header(conn, "Content-Type", "text/html");
		
			if(home(buffer, sizeof(buffer)) == 0){
				return MG_FALSE;
			}
		
			mg_printf_data(conn, buffer);
			return MG_TRUE;	
			
        default:
            return MG_FALSE;
    }
}
예제 #11
0
/*** PUBLIC ***/
br::GalleryToolBar::GalleryToolBar(QWidget *parent)
    : QToolBar("Gallery", parent)
{
    lGallery.setAlignment(Qt::AlignCenter);
    lGallery.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    tbOpenFile.setIcon(QIcon(":/glyphicons/png/[email protected]"));
    tbOpenFile.setToolTip("Load Photo");
    tbOpenFolder.setIcon(QIcon(":/glyphicons/png/[email protected]"));
    tbOpenFolder.setToolTip("Load Photo Folder");
    tbWebcam.setCheckable(true);
    tbWebcam.setIcon(QIcon(":/glyphicons/png/[email protected]"));
    tbWebcam.setToolTip("Load Webcam");
    tbBack.setEnabled(false);
    tbBack.setIcon(QIcon(":/glyphicons/png/[email protected]"));
    tbBack.setToolTip("Back");
    tbMean.setIcon(QIcon(":/glyphicons/png/[email protected]"));
    tbMean.setToolTip("Mean Image");

    addWidget(&tbOpenFile);
    addWidget(&tbOpenFolder);
    addWidget(&tbWebcam);
    addSeparator();
    addWidget(&lGallery);
    addSeparator();
    addWidget(&tbBack);
    addWidget(&tbMean);
    setIconSize(QSize(20,20));

    connect(&tbOpenFile, SIGNAL(clicked()), this, SLOT(openFile()));
    connect(&tbOpenFolder, SIGNAL(clicked()), this, SLOT(openFolder()));
    connect(&tbBack, SIGNAL(clicked()), this, SLOT(home()));
    connect(&tbMean, SIGNAL(clicked()), this, SLOT(mean()));
    connect(&enrollmentWatcher, SIGNAL(finished()), this, SLOT(enrollmentFinished()));
    connect(&timer, SIGNAL(timeout()), this, SLOT(checkWebcam()));

    timer.start(500);
}
예제 #12
0
파일: text.c 프로젝트: deater/dos33fsprogs
int main(int argc, char **argv) {

	int ch,i;
	char output[BUFSIZ];

	grsim_init();

	home();

	gr();

	text();

	basic_htab(10);

	basic_vtab(10);

	basic_print("HELLO WORLD!\r\r");

	for(i=0;i<128;i++) {
		sprintf(output,"%c",i);
		basic_print(output);
	}

	while(1) {
		grsim_update();

		ch=grsim_input();

		if (ch=='q') break;

		usleep(100000);

	}

	return 0;
}
예제 #13
0
파일: MOVE.C 프로젝트: MegaGod/TW
void nextword( unsigned int *x, unsigned int y ) {
	int i, j;
	i = *x + firstcol + 1;
	j = i;
	while ( !ISBLANK( workline.middle[i] ) && ( i != MAXCOL ) ) {
		i++;
	}
	while ( ISBLANK( workline.middle[i] ) && ( i != MAXCOL ) ) {
		i++;
	}
	if ( i != MAXCOL ) {
		i--;
		gocol( i, x );
	} else {
		endline( x );
		if ( ( *x + firstcol + 1 ) <= j ) {
			cursor_down( y );
			home( x );
			if ( ISBLANK( workline.middle[1] ) ) {
				nextword( x, y );
			}
		}
	}
}
예제 #14
0
/// PUBLIC
HelpBrowser::HelpBrowser(QString strPath,
                         QString strFileName,
                         QWidget *parent):
    QWidget(parent)
{
    pButtonBack    = new QPushButton("<<");
    pButtonHome    = new QPushButton("Home");
    pButtonForward = new QPushButton(">>");
    textBrowser = new QTextBrowser();

    connect(pButtonBack, SIGNAL(clicked()),
            textBrowser, SLOT(backward()));
    connect(pButtonHome, SIGNAL(clicked()),
            textBrowser, SLOT(home()));
    connect(pButtonForward, SIGNAL(clicked()),
            textBrowser, SLOT(forward()));
    connect(textBrowser, SIGNAL(backwardAvailable(bool)),
            pButtonBack, SLOT(setEnabled(bool)));
    connect(textBrowser, SIGNAL(forwardAvailable(bool)),
            pButtonForward, SLOT(setEnabled(bool)));

    textBrowser->setSource(QUrl::fromLocalFile(QString(strPath + strFileName)));

    hBoxLayoutCommandButton = new QHBoxLayout;

    hBoxLayoutCommandButton->addWidget(pButtonBack);
    hBoxLayoutCommandButton->addWidget(pButtonHome);
    hBoxLayoutCommandButton->addWidget(pButtonForward);

    vBoxLayoutMain = new QVBoxLayout;

    vBoxLayoutMain->addLayout(hBoxLayoutCommandButton);
    vBoxLayoutMain->addWidget(textBrowser);

    setLayout(vBoxLayoutMain);
}
예제 #15
0
bool GetHomeDirectory(std::string& HomeDirectory)
{
   TDEBUG_ENTER("GetHomeDirectory");
   std::string home("");
   bool SuccessValue;

   // We usually recalculate home every time - so ignore the
   // value in the registry.  The user can turn that off though!
   if (!GetBooleanPreference("Always Recalculate Home"))
      home = GetStringPreference("HOME");

   if (home.empty() || !IsDirectory(home.c_str()))
      SuccessValue = GetCalculatedHomeDirectory(home);
   else
      SuccessValue = true;

   TDEBUG_TRACE("Home directory is " << home);
 
   SuccessValue = (SuccessValue && !home.empty() && IsDirectory(home.c_str()));
   if (SuccessValue)
      HomeDirectory = home;

   return SuccessValue;
}
예제 #16
0
void main( ) {		//main function
	system("clear");
	start:
	home( );
	int ch;
	scanf("%d", &ch);
	switch(ch) {
		case 1:	ulogin( ); 
			system("clear");
			break;
 		case 2:create( ); 
			system("clear");
			break;
 		case 3:	elogin( ); 
			system("clear");
			break;
 		case 4:release( ); 
			break;
 		case 5:exit(0);
 		default:printf("\nwrong choice"); 
		goto start;
		}
	goto start;
}
SortServiceModel::SortServiceModel(QObject *parent)
    : QSortFilterProxyModel(parent)
{
    /* testing purpose */
    QString testPath(getenv("SERVICES_PRIORITY"));
    if (!testPath.isEmpty()) {
        QDir testDir(testPath);
        QStringList testPriorityList = testDir.entryList(QDir::Files);
        foreach(QString filename, testPriorityList)
            createPriorities(testDir.filePath(filename));
    }
    else {
        QDir etc(QDir::rootPath() + QLatin1String("/etc/accounts-ui/service-sorting.d"));
        QDir home(QDir::homePath() + QLatin1String("/.config/accounts-ui/service-sorting.d"));

        QStringList etcPriorityList = etc.entryList(QDir::Files);
        foreach(QString filename, etcPriorityList)
            createPriorities(etc.filePath(filename));

        QStringList homePriorityList = home.entryList(QDir::Files);
        foreach(QString filename, homePriorityList)
            createPriorities(home.filePath(filename));
    }
}
예제 #18
0
GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
{
    TRACE_OBJ

    // TODO: Put resource path in misc class
    QString resourcePath = QLatin1String(":/trolltech/assistant/images/");
#ifdef Q_OS_MAC
    resourcePath.append(QLatin1String("mac"));
#else
    resourcePath.append(QLatin1String("win"));
#endif
    CentralWidget *centralWidget = CentralWidget::instance();

    m_backAction = new QAction(tr("&Back"), parent);
    m_backAction->setEnabled(false);
    m_backAction->setShortcuts(QKeySequence::Back);
    m_backAction->setIcon(QIcon(resourcePath + QLatin1String("/previous.png")));
    connect(m_backAction, SIGNAL(triggered()), centralWidget, SLOT(backward()));
    m_actionList << m_backAction;

    m_nextAction = new QAction(tr("&Forward"), parent);
    m_nextAction->setPriority(QAction::LowPriority);
    m_nextAction->setEnabled(false);
    m_nextAction->setShortcuts(QKeySequence::Forward);
    m_nextAction->setIcon(QIcon(resourcePath + QLatin1String("/next.png")));
    connect(m_nextAction, SIGNAL(triggered()), centralWidget, SLOT(forward()));
    m_actionList << m_nextAction;

    setupNavigationMenus(m_backAction, m_nextAction, centralWidget);

    m_homeAction = new QAction(tr("&Home"), parent);
    m_homeAction->setShortcut(tr("ALT+Home"));
    m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png")));
    connect(m_homeAction, SIGNAL(triggered()), centralWidget, SLOT(home()));
    m_actionList << m_homeAction;

    QAction *separator = new QAction(parent);
    separator->setSeparator(true);
    m_actionList << separator;

    m_zoomInAction = new QAction(tr("Zoom &in"), parent);
    m_zoomInAction->setPriority(QAction::LowPriority);
    m_zoomInAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomin.png")));
    m_zoomInAction->setShortcut(QKeySequence::ZoomIn);
    connect(m_zoomInAction, SIGNAL(triggered()), centralWidget, SLOT(zoomIn()));
    m_actionList << m_zoomInAction;

    m_zoomOutAction = new QAction(tr("Zoom &out"), parent);
    m_zoomOutAction->setPriority(QAction::LowPriority);
    m_zoomOutAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomout.png")));
    m_zoomOutAction->setShortcut(QKeySequence::ZoomOut);
    connect(m_zoomOutAction, SIGNAL(triggered()), centralWidget, SLOT(zoomOut()));
    m_actionList << m_zoomOutAction;

    separator = new QAction(parent);
    separator->setSeparator(true);
    m_actionList << separator;

    m_copyAction = new QAction(tr("&Copy selected Text"), parent);
    m_copyAction->setPriority(QAction::LowPriority);
    m_copyAction->setIconText("&Copy");
    m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png")));
    m_copyAction->setShortcuts(QKeySequence::Copy);
    m_copyAction->setEnabled(false);
    connect(m_copyAction, SIGNAL(triggered()), centralWidget, SLOT(copy()));
    m_actionList << m_copyAction;

    m_printAction = new QAction(tr("&Print..."), parent);
    m_printAction->setPriority(QAction::LowPriority);
    m_printAction->setIcon(QIcon(resourcePath + QLatin1String("/print.png")));
    m_printAction->setShortcut(QKeySequence::Print);
    connect(m_printAction, SIGNAL(triggered()), centralWidget, SLOT(print()));
    m_actionList << m_printAction;

    m_findAction = new QAction(tr("&Find in Text..."), parent);
    m_findAction->setIconText(tr("&Find"));
    m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png")));
    m_findAction->setShortcuts(QKeySequence::Find);
    connect(m_findAction, SIGNAL(triggered()), centralWidget, SLOT(showTextSearch()));
    m_actionList << m_findAction;

#ifdef Q_WS_X11
    m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon()));
    m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon()));
    m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon()));
    m_zoomOutAction->setIcon(QIcon::fromTheme("zoom-out" , m_zoomOutAction->icon()));
    m_copyAction->setIcon(QIcon::fromTheme("edit-copy" , m_copyAction->icon()));
    m_findAction->setIcon(QIcon::fromTheme("edit-find" , m_findAction->icon()));
    m_homeAction->setIcon(QIcon::fromTheme("go-home" , m_homeAction->icon()));
    m_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->icon()));
#endif
}
예제 #19
0
void WoLineEdit::sParse()
{
  if (!_parsed)
  {
    if (text().stripWhiteSpace().length() == 0)
      setId(-1);

    else if (_useQuery)
    {
      XSqlQuery wo;
      wo.prepare(_sql);
      wo.exec();
      if (wo.findFirst("wonumber", text().stripWhiteSpace().upper()) != -1)
      {
        setId(wo.value("wo_id").toInt());
        return;
      }
    }

    else if (text().contains('-'))
    {
      int soNumber = text().left(text().find('-')).toInt();
      int subNumber = text().right(text().length() - text().find('-') - 1).toInt();
 //     bool statusCheck = FALSE;
      QString sql = QString( "SELECT wo_id "
                             "FROM wo "
                             "WHERE ((wo_number=%1)"
                             " AND (wo_subnumber=%2)" )
                    .arg(soNumber)
                    .arg(subNumber);

  //  Add in the Status checks
      QStringList statuses;
      if (_woType & cWoOpen)
        statuses << "(wo_status='O')";

      if (_woType & cWoExploded)
        statuses << "(wo_status='E')";

      if (_woType & cWoReleased)
        statuses << "(wo_status='R')";

      if (_woType & cWoIssued)
        statuses << "(wo_status='I')";

      if (_woType & cWoClosed)
        statuses << "(wo_status='C')";

      if(!statuses.isEmpty())
        sql += " AND (" + statuses.join(" OR ") + ")";

      sql += ")";

      XSqlQuery wo(sql);

      if (wo.first())
        setId(wo.value("wo_id").toInt());
      else
        setId(-1);
    }

    else
    {
      bool statusCheck = FALSE;
      QString sql = QString( "SELECT wo_id, wo_number "
                             "FROM wo "
                             "WHERE ((wo_number=%1)")
                    .arg(text().toInt());

//  Add in the Status checks
      if (_woType)
      {
	sql += " AND (";

	if (_woType & cWoOpen)
	{
	  sql += "(wo_status='O')";
	  statusCheck = TRUE;
	}

	if (_woType & cWoExploded)
	{
	  if (statusCheck)
	    sql += " OR ";
	  sql += "(wo_status='E')";
	  statusCheck = TRUE;
	}

	if (_woType & cWoReleased)
	{
	  if (statusCheck)
	    sql += " OR ";
	  sql += "(wo_status='R')";
	  statusCheck = TRUE;
	}

	if (_woType & cWoIssued)
	{
	  if (statusCheck)
	    sql += " OR ";
	  sql += "(wo_status='I')";
	  statusCheck = TRUE;
	}

	if (_woType & cWoClosed)
	{
	  if (statusCheck)
	    sql += " OR ";
	  sql += "(wo_status='C')";
	}

	sql += ")";
      }
      sql += ");";

      XSqlQuery wo(sql);

      if (wo.first())
      {
        if (wo.size() == 1)
          setId(wo.value("wo_id").toInt());
        else
        {
          setId(-1);
          setText(wo.value("wo_number").toString() + "-");
          focusNextPrevChild(FALSE);
          home(FALSE);
          end(FALSE);
        }
      }
      else
        setId(-1);
    }
  }
}
예제 #20
0
void Screen::clear()
{
    clearEntireScreen();
    home();
}
예제 #21
0
파일: more.c 프로젝트: aalm/obsd-src
/*
 * Print out the contents of the file f, one screenful at a time.
 */
void
screen(FILE *f, int num_lines)
{
	int ch;
	int nchars;
	int length;			/* length of current line */
	static int prev_len = 1;	/* length of previous line */

	for (;;) {
		while (num_lines > 0 && !Pause) {
			if ((nchars = get_line(f, &length)) == EOF) {
				if (clreol)
					clreos();
				return;
			}
			if (ssp_opt && length == 0 && prev_len == 0)
				continue;
			prev_len = length;
			if (bad_so ||
			    (Senter && *Senter == ' ' && promptlen > 0))
				erasep(0);
			/*
			 * Must clear before drawing line since tabs on some
			 * terminals do not erase what they tab over.
			 */
			if (clreol)
				cleareol();
			prbuf(Line, length);
			if (nchars < promptlen) {
				/* erasep() sets promptlen to 0 */
				erasep(nchars);
			} else
				promptlen = 0;
#if 0
			/* XXX - is this needed? */
			if (clreol) {
				/* must clear again in case we wrapped * */
				cleareol();
			}
#endif
			if (nchars < Mcol || !fold_opt) {
				/* will turn off UL if necessary */
				prbuf("\n", 1);
			}
			if (nchars == STOP)
				break;
			num_lines--;
		}
		if (pstate) {
			tputs(ULexit, 1, putch);
			pstate = 0;
		}
		fflush(stdout);
		if ((ch = Getc(f)) == EOF) {
			if (clreol)
				clreos();
			return;
		}

		if (Pause && clreol)
			clreos();
		Ungetc(ch, f);
		Pause = 0;
		startup = 0;
		if ((num_lines = command(NULL, f)) == 0)
			return;
		if (hard && promptlen > 0)
			erasep(0);
		if (noscroll && num_lines >= dlines) {
			if (clreol)
				home();
			else
				doclear();
		}
		/*
		 * XXX - should store the *first* line on the screen,
		 * not the last (but we don't know the file position).
		 * Fixing this requires keeping an arry of dline off_ts
		 * and updating each one when a new line is started.
		 */
		screen_start.line = Currline;
		screen_start.chrctr = Ftell(f);
	}
}
예제 #22
0
파일: more.c 프로젝트: aalm/obsd-src
int
main(int argc, char **argv)
{
	FILE * volatile f;
	char		*s;
	volatile int	left;
	volatile off_t	initline;
	volatile int	prnames = 0;
	volatile int	initopt = 0;
	volatile int	srchopt = 0;
	int		clearit = 0;
	int		ch;
	char		initbuf[80];

	if (pledge("stdio rpath tty", NULL) == -1) {
		perror("pledge");
		exit(1);
	}

	setlocale(LC_ALL, "");

	/* all signals just use a stub handler and interrupt syscalls */
	sigemptyset(&sa.sa_mask);
	sa.sa_flags = 0;
	sa.sa_handler = onsignal;

	nfiles = argc;
	fnames = argv;
	initterm();
	nscroll = Lpp/2 - 1;
	if (nscroll <= 0)
		nscroll = 1;
	if ((s = getenv("MORE")) != NULL && *s != '\0')
		argscan(s);
	while (--nfiles > 0) {
		if ((ch = (*++fnames)[0]) == '-')
			argscan(*fnames + 1);
		else if (ch == '+') {
			s = *fnames;
			if (*++s == '/') {
				srchopt++;
				(void)strlcpy(initbuf, ++s, sizeof(initbuf));
			} else {
				initopt++;
				for (initline = 0; *s != '\0'; s++) {
					if (isdigit((unsigned char)*s))
						initline =
						    initline * 10 + *s - '0';
				}
				--initline;
			}
		} else
			break;
	}
	/*
	 * Allow clreol only if Home and eraseln and EodClr strings are
	 * defined, and in that case, make sure we are in noscroll mode.
	 */
	if (clreol) {
		if (Home == NULL || *Home == '\0' || eraseln == NULL ||
		    *eraseln == '\0' || EodClr == NULL || *EodClr == '\0')
			clreol = 0;
		else
			noscroll = 1;
	}
	if (dlines == 0)
		dlines = Lpp - 1;
	left = dlines;
	if (nfiles > 1)
		prnames++;
	if (!no_intty && nfiles == 0)
		usage();
	else
		f = stdin;
	if (!no_tty) {
		struct sigaction osa;

		(void)sigaction(SIGQUIT, &sa, NULL);
		(void)sigaction(SIGINT, &sa, NULL);
		(void)sigaction(SIGWINCH, &sa, NULL);
		if (sigaction(SIGTSTP, &osa, NULL) == 0 &&
		    osa.sa_handler == SIG_DFL) {
			(void)sigaction(SIGTSTP, &sa, NULL);
			(void)sigaction(SIGTTIN, &sa, NULL);
			(void)sigaction(SIGTTOU, &sa, NULL);
			catch_susp++;
		}
		set_tty();
	}
	if (no_intty) {
		if (no_tty)
			copy_file(stdin);
		else {
			if ((ch = Getc(f)) == '\f')
				doclear();
			else {
				Ungetc(ch, f);
				if (noscroll && ch != EOF) {
					if (clreol)
						home();
					else
						doclear();
				}
			}
			if (srchopt) {
				if (search(initbuf, stdin, 1) == 0 && noscroll)
					left--;
			} else if (initopt)
				skiplns(initline, stdin);
			screen(stdin, left);
		}
		no_intty = 0;
		dup2(STDERR_FILENO, STDIN_FILENO);	/* stderr is a tty */
		prnames++;
		firstf = 0;
	}

	while (fnum < nfiles) {
		if ((f = checkf(fnames[fnum], &clearit)) != NULL) {
			context.line = context.chrctr = 0;
			Currline = 0;
		restart:
			if (firstf) {
				firstf = 0;
				if (srchopt) {
					if (search(initbuf, f, 1) < 0)
						goto restart;
					if (noscroll)
						left--;
				} else if (initopt)
					skiplns(initline, f);
			} else if (fnum < nfiles && !no_tty)
				left = command(fnames[fnum], f);
			if (left != 0) {
				if ((noscroll || clearit) &&
				    (file_size != LONG_MAX)) {
					if (clreol)
						home();
					else
						doclear();
				}
				if (prnames) {
					if (bad_so)
						erasep(0);
					if (clreol)
						cleareol();
					fputs("::::::::::::::", stdout);
					if (promptlen > 14)
						erasep(14);
					putchar('\n');
					if (clreol)
						cleareol();
					printf("%s\n", fnames[fnum]);
					if (clreol)
						cleareol();
					fputs("::::::::::::::\n", stdout);
					if (left > Lpp - 4)
						left = Lpp - 4;
				}
				if (no_tty)
					copy_file(f);
				else {
					within++;
					screen(f, left);
					within = 0;
				}
			}
			fflush(stdout);
			fclose(f);
			screen_start.line = screen_start.chrctr = 0L;
			context.line = context.chrctr = 0L;
		}
		fnum++;
		firstf = 0;
	}
	reset_tty();
	exit(0);
}
예제 #23
0
파일: more.c 프로젝트: aalm/obsd-src
/*
 * Search for nth occurrence of regular expression contained in buf in the file
 */
int
search(char *buf, FILE *file, int n)
{
	off_t startline = Ftell(file);
	off_t line1 = startline;
	off_t line2 = startline;
	off_t line3 = startline;
	off_t saveln;
	int lncount, rv;
	char ebuf[BUFSIZ];
	static regex_t reg;
	static int initialized;

	context.line = saveln = Currline;
	context.chrctr = startline;
	lncount = 0;
	if (buf != NULL && *buf != '\0') {
		if ((rv = regcomp(&reg, buf, REG_NOSUB)) != 0) {
			initialized = 0;
			regerror(rv, &reg, ebuf, sizeof(ebuf));
			regfree(&reg);
			error(ebuf);
			return (-1);
		}
		initialized = 1;
	} else if (!initialized) {
		error("No previous regular expression");
		return (-1);
	}
	while (!feof(file)) {
		line3 = line2;
		line2 = line1;
		line1 = Ftell(file);
		rdline(file);
		lncount++;
		if ((rv = regexec(&reg, Line, 0, NULL, 0)) == 0) {
			if (--n == 0) {
				if (lncount > 3 || (lncount > 1 && no_intty)) {
					putchar('\n');
					if (clreol)
						cleareol();
					fputs("...skipping\n", stdout);
				}
				if (!no_intty) {
					Currline -= (lncount >= 3 ? 3 : lncount);
					Fseek(file, line3);
					if (noscroll) {
						if (clreol) {
							home();
							cleareol();
						} else
							doclear();
					}
				} else {
					kill_line();
					if (noscroll) {
					    if (clreol) {
						    home();
						    cleareol();
					    } else
						    doclear();
					}
					fputs(Line, stdout);
					putchar('\n');
				}
				break;
			}
		} else if (rv != REG_NOMATCH) {
			regerror(rv, &reg, ebuf, sizeof(ebuf));
			error(ebuf);
			return (-1);
		}
	}
	if (feof(file)) {
		if (!no_intty) {
			Currline = saveln;
			Fseek(file, startline);
		} else {
			fputs("\nPattern not found\n", stdout);
			end_it();
		}
		error("Pattern not found");
		return (-1);
	}
	return (0);
}
예제 #24
0
  void posicionEstadoCorriente(const myrabot_arm_base::ReadServos& pec)   
  { 
	  
	ros::NodeHandle n;
 
  	ros::Publisher move_pub_=n.advertise<myrabot_arm_base::WriteServos>("move_arm", 1);   
  	
  	ros::Publisher hand_pub_=n.advertise<myrabot_arm_base::WriteServos>("hand_arm", 1);  
  	   
	myrabot_arm_base::Servos p = pec.posicion;   

	::pg = pec.posicion;
	::cg = pec.corriente; 	
	
	myrabot_arm_base::Servos e = pec.estado;   
	
	myrabot_arm_base::Servos c = pec.corriente;   
	

	if (::cont == 0)
	{
		::punto_0 = home(p, c);
		
		::punto_1 = ::punto_0;
	
		::cont = ::cont+1;
		
		::pinza.pinza = p.pinza;
	
	}
	
	if (::punto_0.x != ::punto_1.x || ::punto_0.y != ::punto_1.y || ::punto_0.z != ::punto_1.z ) {	
		
  	if (::cont_1 == 0) {
  	
		::move = acercar(::punto_0); 	
  	
		move_pub_.publish(::move);
  	
		::cont_1 = ::cont_1+1;
  	
	}
  	
  	if (((p.base-15) < ::move.posicion.base && ::move.posicion.base < (p.base+15)) 
  	    && ((p.arti1-15) < ::move.posicion.arti1 && ::move.posicion.arti1 < (p.arti1+15)) 
  	    && ((p.arti2-15) < ::move.posicion.arti2 && ::move.posicion.arti2 < (p.arti2+15)) 
  	    && ((p.arti3-15) < ::move.posicion.arti3 && ::move.posicion.arti3 < (p.arti3+15))) {
		
		if (::cont_2 == 0) {
			
			::move = inversa(::punto_0, ::inclinacion_pinza, p, 0);

			move_pub_.publish(::move);
		 
			::cont_2 = ::cont_2+1;
		
		
		}
		else {	 
		
		
			if (((p.base-15) < ::move.posicion.base && ::move.posicion.base < (p.base+15)) 
			    && ((p.arti1-15) < ::move.posicion.arti1 && ::move.posicion.arti1 < (p.arti1+15)) 
			    && ((p.arti2-15) < ::move.posicion.arti2 && ::move.posicion.arti2 < (p.arti2+15)) 
			    && ((p.arti3-15) < ::move.posicion.arti3 && ::move.posicion.arti3 < (p.arti3+15))) {
				
				if(::pin.posicion.pinza != p.pinza) {
				
					std::cout<<c.pinza<<std::endl;
			
					::pinza.pinza = ::pinza.pinza + 20;
				
					::pin = controlPinza(::pinza, p, c);
				
					hand_pub_.publish(::pin);
					
				}
				else {
				
					std::cout<<"Agarrado"<<std::endl;
			
					::move = levantarAcercar(::punto_0);				
		
					move_pub_.publish(::move);
				
					::punto_1 = ::punto_0;
				
					::cont_1 = 0;
					::cont_2 = 0;
				}
			}
		}
			
	}
	else {
			
			std::cout<<"En movimiento"<<std::endl;
	}
	
	}
		
	  
  }
예제 #25
0
http::doc urlhandle(const std::string &url, const std::string &querystr, const uint32_t remoteip)
{
	//std::cout << url << "\n";
	const uint32_t localip = util::str2ip("127.0.0.1"); // TODO Make this configurable
	std::vector<std::string> path = util::strsplit(url, '/');
	if (path.size() && path[0] == "") path.erase(path.begin());
	for (std::string &elem : path) elem = util::urldecode(elem);
	std::unordered_map<std::string, std::string> query{};
	if (querystr.size() > 0) for (const std::string &qu : util::strsplit(querystr, '&'))
	{
		std::string::size_type idx = qu.find("=");
		if (idx == qu.npos) query[util::urldecode(qu)] = "";
		else query[util::urldecode(qu.substr(0, idx), true)] = util::urldecode(qu.substr(idx + 1), true);
	}
	try
	{
		if (path.size() == 0 || path[0] == "") return home(remoteip == localip);
		if (path[0] == "search" || path[0] == "view" || path[0] == "content" || path[0] == "complete" || path[0] == "titles" || path[0] == "shuffle")
		{
			if (path.size() < 2) return error("Bad Request", "Missing volume ID");
			if (! volumes.check(path[1])) return error("Not Found", "No volume with ID “" + path[1] + "” exists");
			std::string input{};
			std::string::const_iterator start = util::find_nth(url.begin(), url.end(), '/', 3) + 1;
			if (start > url.end()) input = "";
			else input = util::urldecode(std::string{start, url.end()});
			std::string input_qstr = input + (querystr.size() ? "?" + querystr : "");
			if (path[0] == "search") return search(volumes.get(path[1]), input_qstr);
			else if (path[0] == "view") return content(volumes.get(path[1]), input, true);
			else if (path[0] == "complete") return complete(volumes.get(path[1]), input_qstr);
			else if (path[0] == "titles") return titles(volumes.get(path[1]), input_qstr);
			else if (path[0] == "shuffle") return shuffle(volumes.get(path[1]));
			else return content(volumes.get(path[1]), input);
		}
		else if (path[0] == "load" || path[0] == "unload")
		{
			if (path.size() < 2) return error("Bad Request", "Missing category name");
			if (path[0] == "load") return loadcat(path[1]);
			else return unloadcat(path[1]);
		}
		else if (path[0] == "external")
		{
			if (path.size() < 2) return error("Bad Request", "Missing external path");
			if (remoteip != localip) return error("Denied", "You do not have permission to access this functionality");
			return http::doc{"text/plain", volumes.load_external(path[1])};
		}
		else if (path[0] == "pref") return pref();
		else if (path[0] == "rsrc") return rsrc(util::strjoin(path, '/', 1));
		else if (path[0] == "add") return http::doc{resource("html/add.html")};
		else if (path[0] == "action")
		{
			if (path.size() < 2) return error("Bad Request", "No action selected");
			if (remoteip != localip) return error("Denied", "You do not have permission to access this functionality");
			return action(path[1], query);
		}
		else throw handle_error{"Unknown action “" + path[0] + "”"};
	}
	catch (std::exception &e)
	{
		return error("Error", e.what());
	}
}
void TRACKS()
{


		sky();

		tree_one();
		tree_one_body();
		tree_two();
		tree_two_body();
		wall();
		platform();
		//quad();
		woman();
        resting();
        home();

		/*body_one();
		window_one();
		c_one();

		body_two();
		window_two();
		door_one();
		c_two();

		body_three();
        window_three();
		door_two();
		c_three();

		body_four();
		window_four();
		door_three();*/

//
        glBegin(GL_LINES);// samner lomba line
		glColor3f(0.0,0.0,0.0);
		glVertex2f(0,85);
		glVertex2f(999,85);
		glVertex2f(999,84);
		glVertex2f(0,84);

        glVertex2f(0,82);
		glVertex2f(999,82);
		glVertex2f(999,78);
		glVertex2f(0,78);

		glVertex2f(0,147);
		glVertex2f(999,147);
		glVertex2f(999,148);
		glVertex2f(0,148);


		glVertex2f(0,152);
		glVertex2f(999,152);
		glVertex2f(0,150);
		glVertex2f(999,150);

	glEnd();
	quad();


		/** boundery strt **/
	/*	glBegin(GL_LINES);// samner boundery
		glColor3f(0.0,0.0,0.0);
		glVertex2f(0,300);
		glVertex2f(1000,300);
		glVertex2f(0,297);
		glVertex2f(1000,297);



		glColor3f(0.0,0.0,0.0);//boundery samner
		glVertex2f(0,295);
		glVertex2f(1000,295);
		glVertex2f(0,293);
		glVertex2f(1000,293);

		glColor3f(0.0,0.0,0.0);
		glVertex2f(0,400);
		glVertex2f(1000,400);
		glVertex2f(0,397);
		glVertex2f(1000,397);

        glColor3f(.1111,.10,.0);
		glVertex2f(0,395);
		glVertex2f(1000,395);
		glVertex2f(0,393);
		glVertex2f(1000,393);


        glColor3f(.1111,.10,.0);
		glVertex2f(0,304);
		glVertex2f(1000,304);

		glVertex2f(0,305);
		glVertex2f(1000,305);// samner railline shes


// sliper
		while(c!=1000)
		{
			glVertex2f(c,d);
			glVertex2f(c,d+120);
			c+=10;
		}
		glEnd();*/

		/** boundery finish **/


}
예제 #27
0
int main()
{
  char keyboard_input[100];
  XColor black_col,white_col,red_col,green_col,blue_col,yellow_col,magenta_col,cyan_col;
  Colormap colormap;
  char black_bits[] = "#000000";
  char white_bits[] = "#FFFFFF";    // Mix red, green and blue to get white
  char red_bits[] = "#FF0000";
  char green_bits[] = "#00FF00";
  char blue_bits[] = "#0000FF";
  char yellow_bits[] = "#FFFF00";   // Mix red and green to get yellow
  char magenta_bits[] = "#FF00FF";  // A sort of purple color
  char cyan_bits[] = "#00FFFF";     // A blue-green color

  //Display *dpy = XOpenDisplay(NIL); 
  dpy = XOpenDisplay(NIL); assert(dpy);   // Open the display
  // Define the colors we want to use
  colormap = DefaultColormap(dpy, 0);
  XParseColor(dpy, colormap, black_bits, &black_col); XAllocColor(dpy, colormap, &black_col);
  XParseColor(dpy, colormap, white_bits, &white_col); XAllocColor(dpy, colormap, &white_col);
  XParseColor(dpy, colormap, red_bits, &red_col); XAllocColor(dpy, colormap, &red_col);
  XParseColor(dpy, colormap, green_bits, &green_col);XAllocColor(dpy, colormap, &green_col);
  XParseColor(dpy, colormap, blue_bits, &blue_col);XAllocColor(dpy, colormap, &blue_col);
  XParseColor(dpy, colormap, yellow_bits, &yellow_col);XAllocColor(dpy, colormap, &yellow_col);
  XParseColor(dpy, colormap, magenta_bits, &magenta_col);XAllocColor(dpy, colormap, &magenta_col);
  XParseColor(dpy, colormap, cyan_bits, &cyan_col);XAllocColor(dpy, colormap, &cyan_col);
  // Create the window  The numbers are the x and y locations on the screen, the width and height, 
  // border width (which is usually zero)
  w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, window_width, window_height,
  0, black_col.pixel, black_col.pixel);
  XSelectInput(dpy, w, StructureNotifyMask);        // We want to get MapNotify events
  XMapWindow(dpy, w);         // "Map" the window (that is, make it appear on the screen)
  for(;;){XEvent e; XNextEvent(dpy,&e); if(e.type == MapNotify) break;} //Wait for the MapNotify event
  // which means that the window has appeared on the screen.
  gc = XCreateGC(dpy, w, 0, NIL);        // Create a "Graphics Context"
  get_pen(white_col);
  //  We are finally ready to do some drawing!  Whew!  

  // ................  Students: you put your beautiful code HERE: .......................

  int i;
  home();      // Send the turtle to the middle of the window.  That's its "home"
  get_pen(green_col);
  for (i=0; i<36; i++) {
    forward(250);
    //printf("1 x=%g y=%g heading=%g\n",turtle_x,turtle_y,turtle_heading); //Optional: use for debugging
    right(170);
    //usleep(100000); XFlush(dpy); // Optional: use this to see the lines being drawn, one-by-one
  }
  pen_up(); home(); 
  left(90); pen_down();
  for (i=0; i<4; i++) {
    get_pen(cyan_col);
    forward(200);
    //printf("2 x=%g y=%g heading=%g\n",turtle_x,turtle_y,turtle_heading); //Optional: use for debugging
    left(90);
  }

  XFlush(dpy); // Tell the graphics server that it should really show us the results now.
  sleep(1);  // Wait for 1 second
  printf("Press enter when done.\n");
  fgets (keyboard_input,100,stdin); 
  return(0);
}
예제 #28
0
int aboutMenu()
{
	aboutBg = sf2d_create_texture_mem_RGBA8(about_img.pixel_data, about_img.width, about_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	highlight = sf2d_create_texture_mem_RGBA8(highlight_img.pixel_data, highlight_img.width, highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));
	
	while (aptMainLoop())
	{
		hidScanInput();

		u32 kDown = hidKeysDown();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(aboutBg, 0, 0);
		
		sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][0]);
		sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][1]);
		sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][2]);
		//sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL");
		sftd_draw_textf(roboto, 20, 168, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][5]);
		//sftd_draw_textf(roboto, 20, 183, RGBA8(0, 0, 0, 255), 12, "NinjaHax version: NULL");
		
		if (touch.px  >= 0 && touch.px  <= 480 && touch.py >= 58 && touch.py <= 105)
		{
			sf2d_draw_texture(highlight, 0, 56);
			sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS Updates");
			sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "Click for, view or isntall available updates");
		}
		else if (touch.px  >= 0 && touch.px  <= 480 && touch.py >= 106 && touch.py <= 157)
		{
			sf2d_draw_texture(highlight, 0, 105);
			sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS version: 0.01-20151019-UNOFFICIAL");
			sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL");
		}
		 
		digitalTime(350, 2); 
		batteryStatus(316, 2); 
		androidQuickSettings();
		cursorController();
		
		sf2d_end_frame();
		
		navbarControls(1);
		
		if (kDown & KEY_Y)
			powerMenu(); 
		
		if (kDown & KEY_L)
			lockScreen();
		
		if (kDown & KEY_B)
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			settingsMenu();
		}
		
		if ((touch.px  >= 44 && touch.px  <= 119 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			settingsMenu();
		}
		
		else if ((touch.px  >= 120 && touch.px  <= 195 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			home();
		}
		
		sf2d_swapbuffers();
	}
	
	sf2d_free_texture(aboutBg);
	sf2d_free_texture(highlight);

	return 0;
}
예제 #29
0
  void posicionEstadoCorriente(const myrabot_arm_base_b::ReadServos& pec)   
  { 

	ros::NodeHandle n;
	  
	ros::Publisher move_pub_=n.advertise<myrabot_arm_base_b::WriteServos>("move_arm", 1); 
	   
	p = pec.posicion;
	
	c = pec.corriente;
	
	if (start == 0 || (((p.base-15) < ::move.posicion.base && ::move.posicion.base < (p.base+15)) 
  	    && ((p.arti1-15) < ::move.posicion.arti1 && ::move.posicion.arti1 < (p.arti1+15)) 
  	    && ((p.arti2-15) < ::move.posicion.arti2 && ::move.posicion.arti2 < (p.arti2+15)) 
  	    && ((p.arti3-15) < ::move.posicion.arti3 && ::move.posicion.arti3 < (p.arti3+15)))) {
		
		if (::cont == 0)
		{
			::punto = home(p, c);
			
			::move = inversa(::punto, ::inclinacion_pinza, p, 0);
			
			::cont = 1;
			::start = 1;
			
			sleep(2);
		}
		
		else if (::cont_1 == 0)
		{
			::punto.x = 0;
			::punto.z = 0;
			::punto.y = 265;
			
			::move = inversa(::punto, ::inclinacion_pinza, p, 0);
			
			move_pub_.publish(::move);
			
			::cont_1 = 1;
		}
		else if (::cont_2 == 0)
		{
			::punto.x = 260;
			::punto.z = 0;
			::punto.y = 50;
			
			::move = inversa(::punto, ::inclinacion_pinza, p, 0);
			
			move_pub_.publish(::move);
			
			::cont_2 = 1;
			
			sleep(2);
		}
		else if (::cont_3 == 0)
		{
			::punto.x = 0;
			::punto.z = 205;
			::punto.y = 60;
			
			::move = inversa(::punto, ::inclinacion_pinza, p, 0);
			
			move_pub_.publish(::move);
			
			::cont_3 = 1;
			
			sleep(2);
		}
		else if (::cont_4 == 0)
		{
			::punto.x = -260;
			::punto.z = 0;
			::punto.y = 50;
			
			::move = inversa(::punto, ::inclinacion_pinza, p, 0);
			
			move_pub_.publish(::move);
			
			::cont_4 = 1;
			
			sleep(2);
		}
		else
		{
			::punto.x = 0;
			::punto.z = 0;
			::punto.y = 265;
			
			::move = inversa(::punto, ::inclinacion_pinza, p, 0);
			
			move_pub_.publish(::move);

			::cont = 0;
			::cont_1 = 0;
			::cont_2 = 0;
			::cont_3 = 0;
			::cont_4 = 0;
			::start = 0;
			
			sleep(2);
		}
	}
	
  }
예제 #30
0
파일: edit.c 프로젝트: kotuku-aero/diy-efis
/**
 * Edit a stream
 * @param console_in   stream to read console from
 * @param console_out  stream to write console to
 * @param stream  stream to read/write file to
 */
void muon_edit(handle_t console_in, handle_t console_out, const char *title, handle_t stream)
  {
  int rc;
  int i;

  editor_t *ed = (editor_t *) neutron_malloc(sizeof(editor_t));
  memset(ed, 0, sizeof(editor_t));
  ed->console_in = console_in;
  ed->console_out = console_out;
  ed->title = title;
  ed->anchor = -1;

  rc = load_file(ed, stream);

  get_console_size(ed);

  bool done = false;
  int key;

  ed->refresh = 1;
  while (!done)
    {
    if (ed->refresh)
      {
      draw_screen(ed);
      draw_full_statusline(ed);
      ed->refresh = 0;
      ed->lineupdate = 0;
      }
    else if (ed->lineupdate)
      {
      update_line(ed);
      ed->lineupdate = 0;
      draw_statusline(ed);
      }
    else
      {
      draw_statusline(ed);
      }

    position_cursor(ed);

    key = getkey(ed);

    if (key >= ' ' && key <= 0x7F)
      {
      insert_char(ed, (char) key);
      }
    else
      {
      switch (key)
        {
        case KEY_F1:
          help(ed);
          break;
        case KEY_F5:
          redraw_screen(ed);
          break;
       case KEY_UP:
         up(ed, 0);
          break;
        case KEY_DOWN:
          down(ed, 0);
          break;
        case KEY_LEFT:
          left(ed, 0);
          break;
        case KEY_RIGHT:
          right(ed, 0);
          break;
        case KEY_HOME:
          home(ed, 0);
          break;
        case KEY_END:
          end(ed, 0);
          break;
        case KEY_PGUP:
          pageup(ed, 0);
          break;
        case KEY_PGDN:
          pagedown(ed, 0);
          break;
        case KEY_CTRL_RIGHT:
          wordright(ed, 0);
          break;
        case KEY_CTRL_LEFT:
          wordleft(ed, 0);
          break;
        case KEY_CTRL_HOME:
          top(ed, 0);
          break;
        case KEY_CTRL_END:
          bottom(ed, 0);
          break;
        case KEY_SHIFT_UP:
          up(ed, 1);
          break;
        case KEY_SHIFT_DOWN:
          down(ed, 1);
          break;
        case KEY_SHIFT_LEFT:
          left(ed, 1);
          break;
        case KEY_SHIFT_RIGHT:
          right(ed, 1);
          break;
        case KEY_SHIFT_PGUP:
          pageup(ed, 1);
          break;
        case KEY_SHIFT_PGDN:
          pagedown(ed, 1);
          break;
        case KEY_SHIFT_HOME:
          home(ed, 1);
          break;
        case KEY_SHIFT_END:
          end(ed, 1);
          break;
        case KEY_SHIFT_CTRL_RIGHT:
          wordright(ed, 1);
          break;
        case KEY_SHIFT_CTRL_LEFT:
          wordleft(ed, 1);
          break;
        case KEY_SHIFT_CTRL_HOME:
          top(ed, 1);
          break;
        case KEY_SHIFT_CTRL_END:
          bottom(ed, 1);
          break;
        case ctrl('a'):
          select_all(ed);
          break;
        case ctrl('c'):
          copy_selection(ed);
          break;
        case ctrl('f'):
          find_text(ed, 0);
          break;
        case ctrl('l'):
          goto_line(ed);
          break;
        case ctrl('g'):
          find_text(ed, 1);
          break;
        case KEY_TAB:
          indent(ed, INDENT);
          break;
        case KEY_SHIFT_TAB:
          unindent(ed, INDENT);
          break;
        case KEY_ENTER:
          newline(ed);
          break;
        case KEY_BACKSPACE:
          backspace(ed);
          break;
        case KEY_DEL:
          del(ed);
          break;
        case ctrl('x'):
          cut_selection(ed);
          break;
        case ctrl('z'):
          undo(ed);
          break;
        case ctrl('r'):
          redo(ed);
          break;
        case ctrl('v'):
          paste_selection(ed);
          break;
        case ctrl('s'):
          save_editor(ed);
          break;
        case ctrl('q'):
          done = close_editor(ed);
          break;
        }
      }
    }

  gotoxy(ed, 0, ed->lines + 1);

  outstr(ed, RESET_COLOR CLREOL);

  if (ed->clipboard)
    neutron_free(ed->clipboard);

  if (ed->search)
    neutron_free(ed->search);

  if (ed->linebuf)
    neutron_free(ed->linebuf);

  clear_undo(ed);
  neutron_free(ed);
  }