ClientTextEdit::ClientTextEdit(QWidget* parent) : QTextEdit(parent) { setReadOnly(true); setOverwriteMode(true); setUndoRedoEnabled(false); setDocumentTitle("mClient"); setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); setTabChangesFocus(false); //_doc->setMaximumBlockCount(Config().scrollbackSize); // max number of lines? document()->setUndoRedoEnabled(false); QTextFrame* frame = document()->rootFrame(); _cursor = frame->firstCursorPosition(); // Default Colors _foregroundColor = Qt::lightGray; _backgroundColor = Qt::black; _blackColor = Qt::darkGray; _redColor = Qt::darkRed; _greenColor = Qt::darkGreen; _yellowColor = Qt::darkYellow; _blueColor = Qt::darkBlue; _magentaColor = Qt::darkMagenta; _cyanColor = Qt::darkCyan; _grayColor = Qt::lightGray; _darkGrayColor = Qt::gray; _brightRedColor = Qt::red; _brightGreenColor = Qt::green; _brightYellowColor = Qt::yellow; _brightBlueColor = Qt::blue; _brightMagentaColor = Qt::magenta; _brightCyanColor = Qt::cyan; _whiteColor = Qt::white; // Default Fonts _serverOutputFont = QFont("Monospace", 10); _inputLineFont = QFont("Monospace", 10); //QApplication::font(); _serverOutputFont.setStyleHint(QFont::TypeWriter, QFont::PreferAntialias); QTextFrameFormat frameFormat = frame->frameFormat(); frameFormat.setBackground(_backgroundColor); frameFormat.setForeground(_foregroundColor); frame->setFrameFormat(frameFormat); _format = _cursor.charFormat(); setDefaultFormat(_format); _defaultFormat = _format; _cursor.setCharFormat(_format); QFontMetrics fm(_serverOutputFont); setTabStopWidth(fm.width(" ") * 8); // A tab is 8 spaces wide QScrollBar* scrollbar = verticalScrollBar(); scrollbar->setSingleStep(fm.leading()+fm.height()); connect(scrollbar, SIGNAL(sliderReleased()), this, SLOT(scrollBarReleased())); previous = 0; }