unsigned char * EiC_readline(char *prompt) { /* start with a string of MAXBUF chars */ char * editLine(char *); if(line_len!=0) { free(cur_line); line_len=0; } cur_line=alloc((unsigned long)MAXBUF, "readline"); line_len=MAXBUF; /* set the termio so we can do our own input processing */ set_termio(); /* print the prompt */ user_puts(prompt); cur_line[0] = '\0'; cur_pos = 0; max_pos = 0; cur_entry = NULL; return editLine(prompt); }
SearchQueryView::SearchQueryView(QWidget *parent) : QTreeView(parent) { setContextMenuPolicy(Qt::CustomContextMenu); connect( this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)) ); connect( this, SIGNAL(activated(QModelIndex)), this, SLOT(editLine()) ); }
int EiC_load_history(char * fname, int prompt) { #define BufSz 512 int i; char buff[BufSz]; char *line; FILE *fp = fopen(fname,"r"); if(prompt) set_termio(); if(fp) { while(fgets(buff,BufSz-2,fp)) { for(i=0;buff[i] && buff[i] != '\n';++i) ; if(!buff[i]) buff[i++] = '\\'; buff[i] = 0; if(prompt) { printf("Re-enter [%s] (Y/N/E)?",buff); switch(special_getc()) { case 'y': case 'Y': user_puts(" Y\n"); break; case 'e': case 'E': user_puts(" E\n"); copy_line(buff); line = editLine("edit: "); if(*line) EiC_add_history(line); free(line); set_termio(); continue; default: user_puts(" N\n"); continue; } } EiC_add_history(buff); } fclose(fp); i = 1; } else i = 0; if(prompt) reset_termio(); printf("added %d lines\n",HistLineNo); return i; #undef BufSz }
void SearchQueryView::contextMenu( const QPoint & pos ) { bool isNumeric; indexAt(pos).data(Qt::UserRole).toInt(&isNumeric); if( isNumeric ) { QMenu menu(this); menu.addAction(tr("Edit line"), this, SLOT(editLine())); menu.addAction(tr("Open text"), this, SLOT(openText())); menu.addAction(tr("Play sound"), this, SLOT(playSound())); menu.exec( mapToGlobal(pos) ); } }