MainWindow::MainWindow(ModuleLoader &moduleLoader, const ProgramLoader &programLoader, QWidget *parent) : QMainWindow(parent), moduleLoader(moduleLoader), programLoader(programLoader) { createActions(); createMenus(); setAcceptDrops(true); treeWidget = new TreeWidget(programLoader, this); hexFileWidget = new HexFileWidget(this); logWidget = new LogWidget(); setCentralWidget(new QWidget(this)); QHBoxLayout* layout = new QHBoxLayout(centralWidget()); QTabWidget* tab = new QTabWidget(centralWidget()); tab->addTab(hexFileWidget, "hex"); tab->addTab(logWidget, "log"); layout->addWidget(treeWidget, 1); layout->addWidget(tab); layout->setContentsMargins(0,0,0,0); centralWidget()->setLayout(layout); QAction* search = new QAction(this); search->setShortcut(QKeySequence::Find); addAction(search); connect(treeWidget,SIGNAL(pathChanged(QString)), hexFileWidget, SLOT(setFile(QString))); connect(treeWidget,SIGNAL(positionChanged(qint64, qint64)), hexFileWidget, SLOT(gotoPosition(qint64))); connect(treeWidget,SIGNAL(positionChanged(qint64, qint64)), hexFileWidget, SLOT(highlight(qint64,qint64))); connect(treeWidget,SIGNAL(eventDropped(QDropEvent*)),this, SLOT(dropEvent(QDropEvent*))); connect(search, SIGNAL(triggered()), hexFileWidget, SLOT(focusSearch())); connect(treeWidget,SIGNAL(openFragmentedFile(Object&)), this, SLOT(openFragmentedFile(Object&))); connect(hexFileWidget, SIGNAL(selected(qint64)), treeWidget, SLOT(updateByFilePosition(qint64))); }
/* * Make a pass over the filesystem info in ``mntbuf'' filtering out * filesystem types not in ``fsmask'' and possibly re-stating to get * current (not cached) info. Returns the new count of valid statvfs bufs. */ static size_t regetmntinfo(struct statvfs **mntbufp, size_t mntsize) { size_t i, j; struct statvfs *mntbuf; if (!lflag && typelist == NULL && aflag) return nflag ? mntsize : (size_t)getmntinfo(mntbufp, MNT_WAIT); mntbuf = *mntbufp; j = 0; for (i = 0; i < mntsize; i++) { if (!aflag && (mntbuf[i].f_flag & MNT_IGNORE) != 0) continue; if (lflag && (mntbuf[i].f_flag & MNT_LOCAL) == 0) continue; if (!selected(mntbuf[i].f_fstypename, sizeof(mntbuf[i].f_fstypename))) continue; if (nflag) mntbuf[j] = mntbuf[i]; else { struct statvfs layerbuf = mntbuf[i]; (void)statvfs(mntbuf[i].f_mntonname, &mntbuf[j]); /* * If the FS name changed, then new data is for * a different layer and we don't want it. */ if (memcmp(layerbuf.f_mntfromname, mntbuf[j].f_mntfromname, MNAMELEN)) mntbuf[j] = layerbuf; } j++; } return j; }
void RenderVideoFrame::paintEvent(QPaintEvent *) { QPainter painter(this); if (state==-1 || state==0 || state==1) painter.drawImage(QPoint(0, 0), image); else { // draw black screen or something QImage tmp(image.width(), image.height(), QImage::Format_RGB888); tmp.fill(0); painter.drawImage(QPoint(0,0), tmp); } if (state==1) { // draw circles on the frame QBrush selected(QColor(64,64,255,200)); QBrush not_selected(QColor(127,127,127,40)); vector<Circle>::iterator it; for (it=circles.begin(); it!=circles.end(); it++) { if ((*it).getSelected()) painter.setBrush(selected); else painter.setBrush(not_selected); painter.drawEllipse((*it).x, (*it).y, d, d); painter.drawText((*it).x+d/2-4, (*it).y+d/2+4, QString("%1").arg((*it).id)); } // draw the tracking point painter.setBrush(QBrush(QColor(255, 0, 0, 200))); if (point_x != -1 && point_y != -1) { painter.drawEllipse(point_x-(point_diameter/2), point_y-(point_diameter/2), point_diameter, point_diameter); } } }
bool KviIconWidget::eventFilter(QObject * pObject, QEvent * pEvent) { if(pEvent->type() == QEvent::MouseButtonPress) { if(pObject->inherits("QLabel")) { KviCString szName = ((QLabel *)pObject)->objectName(); bool bOk; KviIconManager::SmallIcon eIcon = (KviIconManager::SmallIcon) szName.toInt(&bOk); if(bOk) emit selected(eIcon); if(parentWidget() && isVisible() && parentWidget()->inherits("QMenu")) { parentWidget()->close(); return true; } else { if(const QPixmap * pPix = ((QLabel *)pObject)->pixmap()) { QDrag * pDrag = new QDrag(this); QMimeData * pMime = new QMimeData; pMime->setText(pObject->objectName()); pMime->setImageData(*pPix); pDrag->setMimeData(pMime); pDrag->setPixmap(*pPix); } } } } else if(pEvent->type() == QEvent::DragEnter) { ((QDragEnterEvent *)pEvent)->setAccepted(true); return true; } return QWidget::eventFilter(pObject,pEvent); }
/* * Make a pass over the filesystem info in ``mntbuf'' filtering out * filesystem types not in ``fsmask'' and possibly re-stating to get * current (not cached) info. Returns the new count of valid statfs bufs. */ static long regetmntinfo(struct statfs **mntbufp, long mntsize) { int i, j; struct statfs *mntbuf; if (!lflag && typelist == NULL) return (nflag ? mntsize : getmntinfo(mntbufp, MNT_WAIT)); mntbuf = *mntbufp; j = 0; for (i = 0; i < mntsize; i++) { if (lflag && (mntbuf[i].f_flags & MNT_LOCAL) == 0) continue; if (!selected(mntbuf[i].f_fstypename)) continue; if (nflag) mntbuf[j] = mntbuf[i]; else (void)statfs(mntbuf[i].f_mntonname, &mntbuf[j]); j++; } return (j); }
void CometsComponent::draw( SkyPainter *skyp ) { if( !selected() || Options::zoomFactor() < 10*MINZOOM ) return; bool hideLabels = ! Options::showCometNames() || (SkyMap::Instance()->isSlewing() && Options::hideLabels() ); double rsunLabelLimit = Options::maxRadCometName(); //FIXME: Should these be config'able? skyp->setPen( QPen( QColor( "darkcyan" ) ) ); skyp->setBrush( QBrush( QColor( "darkcyan" ) ) ); foreach ( SkyObject *so, m_ObjectList ) { KSComet *com = (KSComet*)so; double mag= com->mag(); if (std::isnan(mag) == 0) { bool drawn = skyp->drawPointSource(com,mag); if ( drawn && !(hideLabels || com->rsun() >= rsunLabelLimit) ) SkyLabeler::AddLabel( com, SkyLabeler::COMET_LABEL ); } }
void FragmentSeparatorCanvas::drawShape(QPainter & p) { p.setBackgroundMode(::Qt::TransparentMode); p.setRenderHint(QPainter::Antialiasing, true); p.setPen(::Qt::DashLine); int m = (int) (fragment->y() + fragment->height() * vpos); p.drawLine((int) fragment->x(), m, (int) fragment->x() + fragment->width() - 1, m); p.setPen(::Qt::SolidLine); FILE * fp = svg(); if (fp != 0) fprintf(fp, "<g>\n\t<line stroke=\"black\" stroke-dasharray=\"20,4\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n</g>\n", (int) fragment->x(), m, (int) fragment->x() + fragment->width() - 1, m); if (selected()) show_mark(p, rect()); }
void PatchPortModule::property_changed(const URI& key, const Atom& value) { const LV2URIMap& uris = App::instance().uris(); switch (value.type()) { case Atom::FLOAT: if (key == uris.ingenui_canvas_x) { move_to(value.get_float(), property_y()); } else if (key == uris.ingenui_canvas_y) { move_to(property_x(), value.get_float()); } break; case Atom::STRING: if (key == uris.lv2_name && App::instance().configuration()->name_style() == Configuration::HUMAN) { set_name(value.get_string()); } else if (key == uris.lv2_symbol && App::instance().configuration()->name_style() == Configuration::PATH) { set_name(value.get_string()); } break; case Atom::BOOL: if (key == uris.ingen_polyphonic) { set_stacked_border(value.get_bool()); } else if (key == uris.ingen_selected) { if (value.get_bool() != selected()) { if (value.get_bool()) { _canvas->select_item(this); } else { _canvas->unselect_item(this); } } } default: break; } }
void TextCanvas::draw(QPainter & p) { if (! visible()) return; QColor bgcolor = p.backgroundColor(); QPen fgcolor = p.pen(); if (bg_c == UmlTransparent) p.setBackgroundMode(::Qt::TransparentMode); else { p.setBackgroundMode(::Qt::OpaqueMode); p.setBackgroundColor(color(bg_c)); } if (fg_c != UmlTransparent) p.setPen(color(fg_c)); QRect r = rect(); p.setFont(the_canvas()->get_font(itsfont)); p.drawText (r.left(), r.top(), r.width(), r.height(), ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::WordBreak, text); FILE * fp = svg(); if (fp != 0) draw_text (r.left(), r.top(), r.width(), r.height(), ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::WordBreak, text, p.font(), fp, fg_c, bg_c); p.setFont(the_canvas()->get_font(UmlNormalFont)); p.setBackgroundColor(bgcolor); p.setPen(fgcolor); if (selected()) show_mark(p, r); }
extern void error ( const errorSelection selection, const char *const format, ...) { va_list ap; va_start (ap, format); if (Option.json) { char *reason; vasprintf (&reason, format, ap); json_t *response = json_object (); json_object_set_new (response, "error", json_string (reason)); if (selected (selection, WARNING)) json_object_set_new (response, "warning", json_true ()); if (selected (selection, FATAL)) json_object_set_new (response, "fatal", json_true ()); if (selected (selection, PERROR)) { json_object_set_new (response, "errno", json_integer (errno)); json_object_set_new (response, "perror", json_string (strerror (errno))); } json_dumpf (response, stdout, 0); fprintf (stdout, "\n"); json_decref (response); free (reason); } else { fprintf (errout, "%s: %s", getExecutableName (), selected (selection, WARNING) ? "Warning: " : ""); vfprintf (errout, format, ap); if (selected (selection, PERROR)) #ifdef HAVE_STRERROR fprintf (errout, " : %s", strerror (errno)); #else perror (" "); #endif fputs ("\n", errout); } va_end (ap); if (! Option.json && selected (selection, FATAL)) exit (1); }
void CreatePage::tagTypeSelected(const QModelIndex &which) { dismiss(); Q_EMIT(selected(m_model != 0 ? m_model->name(which) : "")); }
static int testSelected(const char* test) { return selected(UnityFixture.NameFilter, test); }
static int groupSelected(const char* group) { return selected(UnityFixture.GroupFilter, group); }
bool FragmentCanvas::copyable() const { return selected(); }
int main(int argc, char *argv[]) { struct stat stbuf; struct statfs *mntbuf; long mntsize; int ch, i; int width, maxwidth; char *mntpt; if (pledge("stdio rpath", NULL) == -1) err(1, "pledge"); while ((ch = getopt(argc, argv, "hiklnPt:")) != -1) switch (ch) { case 'h': hflag = 1; kflag = 0; break; case 'i': iflag = 1; break; case 'k': kflag = 1; hflag = 0; break; case 'l': lflag = 1; break; case 'n': nflag = 1; break; case 'P': Pflag = 1; break; case 't': if (typelist != NULL) errx(1, "only one -t option may be specified."); maketypelist(optarg); break; default: usage(); } argc -= optind; argv += optind; if ((iflag || hflag) && Pflag) { warnx("-h and -i are incompatible with -P"); usage(); } mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); if (mntsize == 0) err(1, "retrieving information on mounted file systems"); if (!*argv) { mntsize = regetmntinfo(&mntbuf, mntsize); } else { mntbuf = calloc(argc, sizeof(struct statfs)); if (mntbuf == NULL) err(1, NULL); mntsize = 0; for (; *argv; argv++) { if (stat(*argv, &stbuf) < 0) { if ((mntpt = getmntpt(*argv)) == 0) { warn("%s", *argv); continue; } } else if (S_ISCHR(stbuf.st_mode) || S_ISBLK(stbuf.st_mode)) { if (!raw_df(*argv, &mntbuf[mntsize])) ++mntsize; continue; } else mntpt = *argv; /* * Statfs does not take a `wait' flag, so we cannot * implement nflag here. */ if (!statfs(mntpt, &mntbuf[mntsize])) if (lflag && (mntbuf[mntsize].f_flags & MNT_LOCAL) == 0) warnx("%s is not a local file system", *argv); else if (!selected(mntbuf[mntsize].f_fstypename)) warnx("%s mounted as a %s file system", *argv, mntbuf[mntsize].f_fstypename); else ++mntsize; else warn("%s", *argv); } } if (mntsize) { maxwidth = 11; for (i = 0; i < mntsize; i++) { width = strlen(mntbuf[i].f_mntfromname); if (width > maxwidth) maxwidth = width; } if (Pflag) posixprint(mntbuf, mntsize, maxwidth); else bsdprint(mntbuf, mntsize, maxwidth); } return (mntsize ? 0 : 1); }
void DialogPlayerCard::closeEvent(QCloseEvent *) { if(!finished) emit selected(0); }
void DialogPlayerCard::buttonClick(int i) { finished=true; emit selected(pos[i]); close(); }
void ActivityPartitionCanvas::draw(QPainter & p) { if (! visible()) return; p.setRenderHint(QPainter::Antialiasing, true); QRect r = rect(); FILE * fp = svg(); QColor bckgrnd = p.backgroundColor(); QColor co = color(used_color); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); p.setBackgroundColor(co); if (used_color != UmlTransparent) p.fillRect(r, co); p.setFont(the_canvas()->get_font(UmlNormalFont)); QFontMetrics fm(p.font()); int h = 3*fm.height(); if (fp != 0) { fprintf(fp, "<g>\n\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", svg_color(used_color), r.x(), r.y(), r.width() - 1, r.height() - 1); } p.drawRect(r); if (horiz) { if (! str.isEmpty()) { p.save(); p.rotate(-90); p.drawText(-r.y(), r.x(), -r.height(), h, ::Qt::AlignCenter, str); p.restore(); if (fp != 0) { int index = str.find('\n'); if (index == -1) draw_rotate_text(r.x() + h/2, r.y() + r.height()/2, 270, str, p.font(), fp); else { int vc = r.y() + r.height()/2; draw_rotate_text(r.x() + h/4, vc, 270, str.left(index), p.font(), fp); draw_rotate_text(r.x() + (h*3)/4, vc, 270, str.mid(index + 1), p.font(), fp); } } } r.setLeft(r.left() + h); p.drawLine(r.topLeft(), r.bottomLeft()); if (fp) { fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", r.left(), r.top(), r.left(), r.bottom()); fputs("</g>\n", fp); } } else { if (! str.isEmpty()) { p.drawText(r.x(), r.y(), r.width(), h, ::Qt::AlignCenter, str); if (fp != 0) draw_text(r.x(), r.y(), r.width(), h, ::Qt::AlignCenter, str, p.font(), fp); } r.setTop(r.top() + h); p.drawLine(r.topLeft(), r.topRight()); if (fp) { fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", r.left(), r.top(), r.right(), r.top()); fputs("</g>\n", fp); } } p.setBackgroundColor(bckgrnd); if (selected()) show_mark(p, rect()); }
bool ActivityPartitionCanvas::copyable() const { return selected(); }
void FragmentCanvas::draw(QPainter & p) { if (! visible()) return; p.setRenderHint(QPainter::Antialiasing, true); QFontMetrics fm(the_canvas()->get_font(UmlNormalFont)); int w = fm.width((name.isEmpty()) ? QString("X") : name); int h = fm.height() / 2; QRect r = rect(); QRect rname = r; rname.setWidth(w + h); rname.setHeight(fm.height() + h); int h1 = (fm.height() + h)/2; int x1 = rname.right() + h1; int y1 = rname.bottom() - h1; QColor bckgrnd = p.backgroundColor(); p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode); QColor co = color(used_color); FILE * fp = svg(); if (fp != 0) fputs("<g>\n", fp); p.setBackgroundColor(co); p.setFont(the_canvas()->get_font(UmlNormalFont)); if (used_color != UmlTransparent) p.fillRect(r, co); else if (!name.isEmpty()) { Q3PointArray a(6); QBrush brsh = p.brush(); a.setPoint(0, rname.left(), rname.top()); a.setPoint(1, x1, rname.top()); a.setPoint(2, x1, y1); a.setPoint(3, rname.right(), rname.bottom()); a.setPoint(4, rname.left(), rname.bottom()); a.setPoint(5, rname.left(), rname.top()); p.setBrush(UmlWhiteColor); p.drawPolygon(a, TRUE, 0, 5); p.setBrush(brsh); if (fp != 0) draw_poly(fp, a, UmlWhite); } if (fp != 0) fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\"" " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n", svg_color(used_color), r.x(), r.y(), r.width() - 1, r.height() - 1); p.drawRect(r); if (refer != 0) { QString s = refer->get_name() + form; QRect r2(r.left(), r.top() + 2*fm.height(), r.width(), fm.height()); p.drawText(r2, ::Qt::AlignCenter, s); if (fp != 0) draw_text(r2, ::Qt::AlignCenter, s, p.font(), fp); } if (!name.isEmpty()) p.drawText(rname, ::Qt::AlignCenter, name); if (fp != 0) draw_text(rname, ::Qt::AlignCenter, name, p.font(), fp); p.drawLine(rname.left(), rname.bottom(), rname.right(), rname.bottom()); p.drawLine(rname.right(), rname.bottom(), x1, y1); p.drawLine(x1, y1, x1, rname.top()); if (fp != 0) { fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", rname.left(), rname.bottom(), rname.right(), rname.bottom()); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", rname.right(), rname.bottom(), x1, y1); fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\"" " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n", x1, y1, x1, rname.top()); fputs("</g>\n", fp); } p.setBackgroundColor(bckgrnd); if (selected()) show_mark(p, r); }
/*! * Check object selecting. * \return true if object record selected in database. */ bool aObject::IsSelected() { return selected(); }
void GraphicsIcon::mousePressEvent(QGraphicsSceneMouseEvent* e) { if(e->button() == Qt::LeftButton) emit selected(this); }
void KTabBar::emitSelected(int tab) { emit selected(tab); }
bool HubCanvas::copyable() const { return selected(); }
void ColorLabel::mouseReleaseEvent(QMouseEvent*) { emit selected(m_id); }
MarkCanvas::~MarkCanvas() { if (selected()) deselect(); }
void ListBaseTestCase::ItemClick() { #if wxUSE_UIACTIONSIMULATOR #ifdef __WXMSW__ // FIXME: This test fails on MSW buildbot slaves although works fine on // development machine, no idea why. It seems to be a problem with // wxUIActionSimulator rather the wxListCtrl control itself however. if ( IsAutomaticTest() ) return; #endif // __WXMSW__ wxListCtrl* const list = GetList(); list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); list->InsertItem(0, "Item 0"); list->SetItem(0, 1, "first column"); list->SetItem(0, 2, "second column"); EventCounter selected(list, wxEVT_LIST_ITEM_SELECTED); EventCounter focused(list, wxEVT_LIST_ITEM_FOCUSED); EventCounter activated(list, wxEVT_LIST_ITEM_ACTIVATED); EventCounter rclick(list, wxEVT_LIST_ITEM_RIGHT_CLICK); wxUIActionSimulator sim; wxRect pos; list->GetItemRect(0, pos); //We move in slightly so we are not on the edge wxPoint point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 5); sim.MouseMove(point); wxYield(); sim.MouseClick(); wxYield(); sim.MouseDblClick(); wxYield(); sim.MouseClick(wxMOUSE_BTN_RIGHT); wxYield(); // when the first item was selected the focus changes to it, but not // on subsequent clicks // FIXME: This test fail under wxGTK & wxOSX because we get 3 FOCUSED events and // 2 SELECTED ones instead of the one of each we expect for some // reason, this needs to be debugged as it may indicate a bug in the // generic wxListCtrl implementation. #ifndef _WX_GENERIC_LISTCTRL_H_ CPPUNIT_ASSERT_EQUAL(1, focused.GetCount()); CPPUNIT_ASSERT_EQUAL(1, selected.GetCount()); #endif CPPUNIT_ASSERT_EQUAL(1, activated.GetCount()); CPPUNIT_ASSERT_EQUAL(1, rclick.GetCount()); //tidy up when we are finished list->ClearAll(); #endif // wxUSE_UIACTIONSIMULATOR }
void ReferenceDialog::update() { selected((results->count() != 0) ? results->currentItem() : -1); }
int Q3ButtonGroup::selectedId() const { return id(selected()); }
bool GUIChatConsole::OnEvent(const SEvent& event) { ChatPrompt &prompt = m_chat_backend->getPrompt(); if(event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown) { // Key input if(KeyPress(event.KeyInput) == getKeySetting("keymap_console")) { closeConsole(); // inhibit open so the_game doesn't reopen immediately m_open_inhibited = 50; m_close_on_enter = false; return true; } else if(event.KeyInput.Key == KEY_ESCAPE) { closeConsoleAtOnce(); m_close_on_enter = false; // inhibit open so the_game doesn't reopen immediately m_open_inhibited = 1; // so the ESCAPE button doesn't open the "pause menu" return true; } else if(event.KeyInput.Key == KEY_PRIOR) { m_chat_backend->scrollPageUp(); return true; } else if(event.KeyInput.Key == KEY_NEXT) { m_chat_backend->scrollPageDown(); return true; } else if(event.KeyInput.Key == KEY_RETURN) { prompt.addToHistory(prompt.getLine()); std::wstring text = prompt.replace(L""); m_client->typeChatMessage(text); if (m_close_on_enter) { closeConsoleAtOnce(); m_close_on_enter = false; } return true; } else if(event.KeyInput.Key == KEY_UP) { // Up pressed // Move back in history prompt.historyPrev(); return true; } else if(event.KeyInput.Key == KEY_DOWN) { // Down pressed // Move forward in history prompt.historyNext(); return true; } else if(event.KeyInput.Key == KEY_LEFT || event.KeyInput.Key == KEY_RIGHT) { // Left/right pressed // Move/select character/word to the left depending on control and shift keys ChatPrompt::CursorOp op = event.KeyInput.Shift ? ChatPrompt::CURSOROP_SELECT : ChatPrompt::CURSOROP_MOVE; ChatPrompt::CursorOpDir dir = event.KeyInput.Key == KEY_LEFT ? ChatPrompt::CURSOROP_DIR_LEFT : ChatPrompt::CURSOROP_DIR_RIGHT; ChatPrompt::CursorOpScope scope = event.KeyInput.Control ? ChatPrompt::CURSOROP_SCOPE_WORD : ChatPrompt::CURSOROP_SCOPE_CHARACTER; prompt.cursorOperation(op, dir, scope); return true; } else if(event.KeyInput.Key == KEY_HOME) { // Home pressed // move to beginning of line prompt.cursorOperation( ChatPrompt::CURSOROP_MOVE, ChatPrompt::CURSOROP_DIR_LEFT, ChatPrompt::CURSOROP_SCOPE_LINE); return true; } else if(event.KeyInput.Key == KEY_END) { // End pressed // move to end of line prompt.cursorOperation( ChatPrompt::CURSOROP_MOVE, ChatPrompt::CURSOROP_DIR_RIGHT, ChatPrompt::CURSOROP_SCOPE_LINE); return true; } else if(event.KeyInput.Key == KEY_BACK) { // Backspace or Ctrl-Backspace pressed // delete character / word to the left ChatPrompt::CursorOpScope scope = event.KeyInput.Control ? ChatPrompt::CURSOROP_SCOPE_WORD : ChatPrompt::CURSOROP_SCOPE_CHARACTER; prompt.cursorOperation( ChatPrompt::CURSOROP_DELETE, ChatPrompt::CURSOROP_DIR_LEFT, scope); return true; } else if(event.KeyInput.Key == KEY_DELETE) { // Delete or Ctrl-Delete pressed // delete character / word to the right ChatPrompt::CursorOpScope scope = event.KeyInput.Control ? ChatPrompt::CURSOROP_SCOPE_WORD : ChatPrompt::CURSOROP_SCOPE_CHARACTER; prompt.cursorOperation( ChatPrompt::CURSOROP_DELETE, ChatPrompt::CURSOROP_DIR_RIGHT, scope); return true; } else if(event.KeyInput.Key == KEY_KEY_A && event.KeyInput.Control) { // Ctrl-A pressed // Select all text prompt.cursorOperation( ChatPrompt::CURSOROP_SELECT, ChatPrompt::CURSOROP_DIR_LEFT, // Ignored ChatPrompt::CURSOROP_SCOPE_LINE); return true; } else if(event.KeyInput.Key == KEY_KEY_C && event.KeyInput.Control) { // Ctrl-C pressed // Copy text to clipboard if (prompt.getCursorLength() <= 0) return true; std::wstring wselected = prompt.getSelection(); std::string selected(wselected.begin(), wselected.end()); Environment->getOSOperator()->copyToClipboard(selected.c_str()); return true; } else if(event.KeyInput.Key == KEY_KEY_V && event.KeyInput.Control) { // Ctrl-V pressed // paste text from clipboard if (prompt.getCursorLength() > 0) { // Delete selected section of text prompt.cursorOperation( ChatPrompt::CURSOROP_DELETE, ChatPrompt::CURSOROP_DIR_LEFT, // Ignored ChatPrompt::CURSOROP_SCOPE_SELECTION); } IOSOperator *os_operator = Environment->getOSOperator(); const c8 *text = os_operator->getTextFromClipboard(); if (!text) return true; std::basic_string<unsigned char> str((const unsigned char*)text); prompt.input(std::wstring(str.begin(), str.end())); return true; } else if(event.KeyInput.Key == KEY_KEY_X && event.KeyInput.Control) { // Ctrl-X pressed // Cut text to clipboard if (prompt.getCursorLength() <= 0) return true; std::wstring wselected = prompt.getSelection(); std::string selected(wselected.begin(), wselected.end()); Environment->getOSOperator()->copyToClipboard(selected.c_str()); prompt.cursorOperation( ChatPrompt::CURSOROP_DELETE, ChatPrompt::CURSOROP_DIR_LEFT, // Ignored ChatPrompt::CURSOROP_SCOPE_SELECTION); return true; } else if(event.KeyInput.Key == KEY_KEY_U && event.KeyInput.Control) { // Ctrl-U pressed // kill line to left end prompt.cursorOperation( ChatPrompt::CURSOROP_DELETE, ChatPrompt::CURSOROP_DIR_LEFT, ChatPrompt::CURSOROP_SCOPE_LINE); return true; } else if(event.KeyInput.Key == KEY_KEY_K && event.KeyInput.Control) { // Ctrl-K pressed // kill line to right end prompt.cursorOperation( ChatPrompt::CURSOROP_DELETE, ChatPrompt::CURSOROP_DIR_RIGHT, ChatPrompt::CURSOROP_SCOPE_LINE); return true; } else if(event.KeyInput.Key == KEY_TAB) { // Tab or Shift-Tab pressed // Nick completion std::list<std::string> names = m_client->getConnectedPlayerNames(); bool backwards = event.KeyInput.Shift; prompt.nickCompletion(names, backwards); return true; } else if(event.KeyInput.Char != 0 && !event.KeyInput.Control) { #if (defined(linux) || defined(__linux)) wchar_t wc = L'_'; mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) ); prompt.input(wc); #else prompt.input(event.KeyInput.Char); #endif return true; } } else if(event.EventType == EET_MOUSE_INPUT_EVENT) { if(event.MouseInput.Event == EMIE_MOUSE_WHEEL) { s32 rows = myround(-3.0 * event.MouseInput.Wheel); m_chat_backend->scroll(rows); } } return Parent ? Parent->OnEvent(event) : false; }