void OutputWindow::setWordWrapEnabled(bool wrap)
{
    if (wrap)
        setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    else
        setWordWrapMode(QTextOption::NoWrap);
}
Beispiel #2
0
void ChatBrowser::setWordWrap()
{
    if(m_wordWarp->isChecked())
    {
        setWordWrapMode(QTextOption::WordWrap);
    }
    else
    {
        setWordWrapMode(QTextOption::WrapAnywhere);
    }
}
Beispiel #3
0
ChatBrowser::ChatBrowser(QWidget *parent) :
    QTextBrowser(parent),m_bgColor(MAX_COLOR_CHANNEL,MAX_COLOR_CHANNEL,MAX_COLOR_CHANNEL),m_parent(parent)
{
    //setOpenLinks(true);
    m_bgColorAct= new QAction(tr("Background Color"),this); //toolBar->addWidget(m_bgColorSelector);
    m_bgColorAct->setToolTip(tr("Background Color"));
    connect(m_bgColorAct,SIGNAL(triggered()),this, SLOT(backGroundChanged()));


    m_detachedDialog = new QAction(tr("Detach the view"),this);
    m_detachedDialog->setCheckable(true);
    m_wordWarp = new QAction(tr("Word Wrap"),this);
    m_wordWarp->setCheckable(true);
    m_wordWarp->setChecked(true);

    connect(m_detachedDialog,SIGNAL(triggered()),this, SLOT(detachedView()));
    //connect(m_anyWhereWarp,SIGNAL(triggered()),this, SLOT(setWrapAnyWhere()));
    connect(m_wordWarp,SIGNAL(triggered()),this, SLOT(setWordWrap()));

    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(showContextMenu(QPoint)));

    setAcceptRichText(false);
    //setContextMenuPolicy(Qt::NoContextMenu);
    setOpenLinks(true);
    setReadOnly(true);
    setUndoRedoEnabled(false);
    setWordWrapMode(QTextOption::WordWrap);
    document()->setDefaultStyleSheet(QString(".dice {color:%1;font-weight: bold;}").arg(PreferencesManager::getInstance()->value("DiceHighlightColor",QColor(Qt::red)).value<QColor>().name()));
}
void
body_view::set_wrap(bool on)
{
  Q_UNUSED(on);
  // for text parts, we'll probably need to implement wrapmode by HTML-styling the contents
#ifndef TODO_WEBKIT
  if (on) {
    setWordWrapMode(QTextOption::WordWrap);
    setLineWrapMode(QTextEdit::WidgetWidth);
  }
  else {
    setLineWrapMode(QTextEdit::NoWrap);
    setWordWrapMode(QTextOption::NoWrap);
  }
#endif
}
Beispiel #5
0
SourceWindow::SourceWindow(const QString& fileName, QWidget* parent) :
	QPlainTextEdit(parent),
	m_fileName(fileName),
	m_highlighter(0),
	m_widthItems(16),
	m_widthPlus(12),
	m_widthLineNo(30),
	m_lineInfoArea(new LineInfoArea(this))
{
    // load pixmaps
    m_pcinner = UserIcon("pcinner");
    m_pcup = UserIcon("pcup");
    m_brkena = UserIcon("brkena");
    m_brkdis = UserIcon("brkdis");
    m_brktmp = UserIcon("brktmp");
    m_brkcond = UserIcon("brkcond");
    m_brkorph = UserIcon("brkorph");
    setFont(KGlobalSettings::fixedFont());
    setReadOnly(true);
    setViewportMargins(lineInfoAreaWidth(), 0, 0 ,0);
    setWordWrapMode(QTextOption::NoWrap);
    connect(this, SIGNAL(updateRequest(const QRect&, int)),
	    m_lineInfoArea, SLOT(update()));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(cursorChanged()));

    // add a syntax highlighter
    if (QRegExp("\\.(c(pp|c|\\+\\+)?|CC?|h(\\+\\+|h|pp)?|HH?)$").indexIn(m_fileName) >= 0)
    {
	m_highlighter = new HighlightCpp(this);
    }
}
Beispiel #6
0
GLSLTextEditor::GLSLTextEditor(QWidget* parent)
  : QPlainTextEdit (parent)
{
  _highlighter = new GLSLSyntaxHighlighter(document());

  _lineNumberArea = new LineNumberArea (this);
  connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(UpdateLineNumberAreaWidth(int)));
  connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(UpdateLineNumberArea(QRect,int)));
  connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(HighlightCurrentLine()));


  setWordWrapMode(QTextOption::NoWrap);
  QTextDocument* doc = document();
#ifdef _WIN32
  QFont f ("Courier");
#else
  QFont f ("Monospace");
#endif
  f.setStyleHint(QFont::Monospace);
	f.setPixelSize(11);
  doc->setDefaultFont(f);


  connect (doc, SIGNAL(contentsChange(int,int,int)), SLOT(on_document_contentChanged (int, int, int)));

  connect(doc, SIGNAL(contentsChanged()), this, SIGNAL(ContentChanged()));
}
Beispiel #7
0
//----------------------------------------------------------------------------
// ChatView
//----------------------------------------------------------------------------
ChatView::ChatView(QWidget *parent)
	: PsiTextView(parent)
	, dialog_(0)
{
	setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);

	setReadOnly(true);
	setUndoRedoEnabled(false);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

#ifndef Q_WS_X11	// linux has this feature built-in
	connect(this, SIGNAL(selectionChanged()), SLOT(autoCopy()));
	connect(this, SIGNAL(cursorPositionChanged()), SLOT(autoCopy()));
#endif

// FIXME
#ifdef YAPSI
	CombinedSyntaxHighlighter* hl = new CombinedSyntaxHighlighter(this);
	new QuotationHighlighter(hl, this);
	new WikiHighlighter(hl, this);
#ifdef YAPSI_DEV
	new CppHighlighter(hl, this);
#endif
#endif
}
Beispiel #8
0
CodeArea::CodeArea(QWidget *parent)
    :QPlainTextEdit(parent)
    ,highlighter(this->document())
{
    QFont font;
    font.setFamily("Courier");
    font.setFixedPitch(true);
    font.setPointSize(10);
    font.insertSubstitution("	","    ");
    setFont(font);
    setWordWrapMode(QTextOption::NoWrap);

    lineNumberArea = new LineNumberArea(this);
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();
    mCompleter = new QCompleter(this);
    mCompleter->setModel(new QStringListModel(mWordList, mCompleter));
    mCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
    mCompleter->setCaseSensitivity(Qt::CaseSensitive);
    mCompleter->setWrapAround(false);

    mCompleter->setWidget(this);
    mCompleter->setCompletionMode(QCompleter::PopupCompletion);
    mCompleter->setCaseSensitivity(Qt::CaseInsensitive);
    QObject::connect(mCompleter, SIGNAL(activated(QString)),
                  this, SLOT(insertCompletion(QString)));

    connect(this,SIGNAL(textChanged()), this, SLOT(onTextChange()));
}
KNSourceViewWindow::KNSourceViewWindow( const QString &text )
  : KTextBrowser(0)
{
  setWindowFlags( Qt::Window );
  setAttribute( Qt::WA_DeleteOnClose );

  QShortcut *shortcut = new QShortcut( QKeySequence(Qt::Key_Escape), this );
  connect( shortcut, SIGNAL(activated()), this, SLOT(close()) );

  setAcceptRichText( false );

  setWindowTitle(KDialog::makeStandardCaption(i18n("Article Source"), this));

  QPalette p = palette();
  p.setColor( QPalette::Text, knGlobals.settings()->textColor() );
  p.setColor( QPalette::Base, knGlobals.settings()->backgroundColor() );
  setPalette( p );

  setFont( knGlobals.settings()->articleFixedFont() );
  setWordWrapMode( QTextOption::NoWrap );

  setPlainText( text );
  KNHelper::restoreWindowSize("sourceWindow", this, QSize(500,300));
  show();
}
Beispiel #10
0
 MdiChild::MdiChild()
 {
     setAttribute(Qt::WA_DeleteOnClose);
     isUntitled = true;
     setAcceptRichText(false);
     setFontFamily("Monospace");
     setWordWrapMode(QTextOption::NoWrap);
     
 }
OneLineTextEdit::OneLineTextEdit(QWidget *parent) :
    QPlainTextEdit(parent)
{
    setWordWrapMode (QTextOption::NoWrap);
    setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
    setTabChangesFocus (true);
    setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
}
v_singlelineTextEdit::v_singlelineTextEdit(QWidget * parent):QTextEdit(parent){
    setTabChangesFocus(true);
    setWordWrapMode(QTextOption::NoWrap);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    //setFixedHeight(sizeHint().height());

}
Beispiel #13
0
ChatEdit::ChatEdit(QWidget *parent) : QTextEdit(parent), cc(nullptr)
{
    setMinimumHeight(10);

    setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    connect(this, SIGNAL(textChanged()), this, SLOT(recalculateGeometry()));
}
Beispiel #14
0
ChatbarTextEdit::ChatbarTextEdit(QWidget *p) : QTextEdit(p), iHistoryIndex(-1) {
	setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setMinimumHeight(0);
	connect(this, SIGNAL(textChanged()), SLOT(doResize()));

	bDefaultVisible = true;
	setDefaultText(tr("<center>Type chat message here</center>"));
}
Beispiel #15
0
QTerminalEdit::QTerminalEdit(QWidget *parent) :
    QPlainTextEdit(parent)
{
    echoBytes = false;
    hexMode = false;
    setFont(QFont("Consolas"));
    setWordWrapMode(QTextOption::WrapAnywhere);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setMaximumBlockCount(100);
}
Beispiel #16
0
GroupedLineEdit::GroupedLineEdit(QWidget *parent) : QPlainTextEdit(parent),
	d(new Private)
{
	setWordWrapMode(QTextOption::NoWrap);
	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	document()->setMaximumBlockCount(1);
}
Beispiel #17
0
/**
 * Sets the style of wrapping used if the text area is wrapping
 * lines.  If set to true the lines will be wrapped at word
 * boundaries (whitespace) if they are too long
 * to fit within the allocated width.  If set to false,
 * the lines will be wrapped at character boundaries.
 * By default this property is false.
 *
 * @param word indicates if word boundaries should be used
 *   for line wrapping
 * @see #getWrapStyleWord
 * @beaninfo
 *   preferred: false
 *       bound: true
 * description: should wrapping occur at word boundaries
 */
/*public*/ void JTextArea::setWrapStyleWord(bool word) {
 textOption = wordWrapMode();
    bool old = this->word;
    this->word = word;
    if(word)
     textOption = QTextOption::WordWrap;
    else
     textOption = QTextOption::WordWrap;
    setWordWrapMode(textOption);
    //firePropertyChange("wrapStyleWord", old, word);
}
CodeLineEdit::CodeLineEdit(QWidget *parent) : QPlainTextEdit(parent) {
  setTabChangesFocus(true);
  setWordWrapMode(QTextOption::NoWrap);
  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
  setFixedHeight(sizeHint().height());
  QPalette p = this->palette();
  p.setColor(QPalette::Base, Qt::black);
  p.setColor(QPalette::Text, Qt::white);
  this->setPalette(p);
}
TranslationLine::TranslationLine(QWidget *parent)
	: QTextEdit(parent)
{
	fixingSize=false;
	setWordWrapMode(QTextOption::WrapAnywhere);
	setTabChangesFocus(true);
	setAcceptRichText(false);
    setMinimumWidth(100);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	connect(this,SIGNAL(textChanged()),this,SLOT(textChangedSlot()));
}
Beispiel #20
0
TCommandLine::TCommandLine( Host * pHost, TConsole * pConsole, QWidget * parent )
: QPlainTextEdit( parent )
, mpHost( pHost )
, mpConsole( pConsole )
, mSelectedText( "" )
, mSelectionStart( 0 )

{
    QString path;
#ifdef Q_OS_LINUX
    path = "/usr/share/hunspell/";
#else
    path = "./";
#endif

    QString spell_aff = path + pHost->mSpellDic + ".aff";
    QString spell_dic = path + pHost->mSpellDic + ".dic";
    mpHunspell = Hunspell_create( spell_aff.toLatin1().data(), spell_dic.toLatin1().data() );//"en_US.aff", "en_US.dic");
    mpKeyUnit = mpHost->getKeyUnit();
    setAutoFillBackground(true);
    setFocusPolicy(Qt::StrongFocus);

    QFont font = mpHost->mDisplayFont;
    setFont(font);

    mRegularPalette.setColor(QPalette::Text, mpHost->mCommandLineFgColor );//QColor(0,0,192));
    mRegularPalette.setColor(QPalette::Highlight,QColor(0,0,192));
    mRegularPalette.setColor(QPalette::HighlightedText, QColor(255,255,255));
    mRegularPalette.setColor(QPalette::Base,mpHost->mCommandLineBgColor);//QColor(255,255,225));

    setPalette( mRegularPalette );

    mTabCompletionPalette.setColor(QPalette::Text,QColor(0,0,192));
    mTabCompletionPalette.setColor(QPalette::Highlight,QColor(0,0,192));
    mTabCompletionPalette.setColor(QPalette::HighlightedText, QColor(255,255,255));
    mTabCompletionPalette.setColor(QPalette::Base,QColor(235,255,235));

    mAutoCompletionPalette.setColor(QPalette::Text,QColor(0,0,192));
    mAutoCompletionPalette.setColor(QPalette::Highlight,QColor(0,0,192));
    mAutoCompletionPalette.setColor(QPalette::HighlightedText, QColor(255,255,255));
    mAutoCompletionPalette.setColor(QPalette::Base,QColor(255,235,235));


    mHistoryBuffer = 0;
    mAutoCompletion = false;
    setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    setCenterOnScroll( false );
    setWordWrapMode( QTextOption::WrapAnywhere );
//    setMaximumBlockCount(1);
    setContentsMargins(0,0,0,0);
}
Beispiel #21
0
/**
 * Sets the line-wrapping policy of the text area.  If set
 * to true the lines will be wrapped if they are too long
 * to fit within the allocated width.  If set to false,
 * the lines will always be unwrapped.  A <code>PropertyChange</code>
 * event ("lineWrap") is fired when the policy is changed.
 * By default this property is false.
 *
 * @param wrap indicates if lines should be wrapped
 * @see #getLineWrap
 * @beaninfo
 *   preferred: true
 *       bound: true
 * description: should lines be wrapped
 */
/*public*/ void JTextArea::setLineWrap(bool wrap) {
 textOption = wordWrapMode();
    bool old = this->wrap;
    this->wrap = wrap;
    if(!wrap)
     textOption = QTextOption::NoWrap;
    else
    {
     if(textOption == QTextOption::NoWrap)
      textOption = QTextOption::WrapAtWordBoundaryOrAnywhere;
    }
     setWordWrapMode(textOption);
//    firePropertyChange("lineWrap", old, wrap);
}
Beispiel #22
0
QgsBrowserPropertiesWrapLabel::QgsBrowserPropertiesWrapLabel( const QString& text, QWidget* parent )
    : QTextEdit( text, parent )
{
  setReadOnly( true );
  setFrameStyle( QFrame::NoFrame );
  setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
  QPalette pal = palette();
  pal.setColor( QPalette::Base, Qt::transparent );
  setPalette( pal );
  setLineWrapMode( QTextEdit::WidgetWidth );
  setWordWrapMode( QTextOption::WrapAnywhere );
  connect( qobject_cast<QObject*>( document()->documentLayout() ), SIGNAL( documentSizeChanged( QSizeF ) ),
           this, SLOT( adjustHeight( QSizeF ) ) );
  setMaximumHeight( 20 );
}
Beispiel #23
0
RichTextLineEdit::RichTextLineEdit(QWidget *parent)
    : QTextEdit(parent)
{
    setLineWrapMode(QTextEdit::NoWrap);
    setWordWrapMode(QTextOption::NoWrap);
    setAcceptRichText(true);
    setTabChangesFocus(true);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    createShortcuts();
    createActions();
    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
            this, SLOT(customContextMenuRequested(const QPoint&)));
}
Beispiel #24
0
Console::Console(QWidget *parent)
    : QTextEdit(parent) {
    setFrameShape(QFrame::NoFrame);
    viewport()->setCursor(Qt::ArrowCursor);

    setFont(QFont("Lucida Console", 10));

    setWordWrapMode(QTextOption::WrapAnywhere);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    history = new QStringList;
    historyPos = 0;

    locked = false;
}
ResultDisplay::ResultDisplay(QWidget* parent)
    : QPlainTextEdit(parent)
    , m_count(0)
    , m_highlighter(new SyntaxHighlighter(this))
    , m_scrolledLines(0)
    , m_scrollDirection(0)
    , m_isScrollingPageOnly(false)
{
    setViewportMargins(0, 0, 0, 0);
    setBackgroundRole(QPalette::Base);
    setLayoutDirection(Qt::LeftToRight);
    setMinimumWidth(150);
    setReadOnly(true);
    setFocusPolicy(Qt::NoFocus);
    setWordWrapMode(QTextOption::WrapAnywhere);
}
Beispiel #26
0
EmailComposer::EmailComposer( QWidget *parent, const char *name )
  : QTextEdit( parent ),
    m_index( -1 )
{
    setObjectName(name);

    setFrameStyle(NoFrame);
    setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );

    connect( this, SIGNAL(textChanged()), this, SIGNAL(contentChanged()) );
    connect( this, SIGNAL(textChanged()), this, SLOT(updateLabel()) );
    setWordWrapMode( QTextOption::WordWrap);

    m_addAttDialog = new AddAttDialog(this, "attachmentDialog");

    updateLabel();
}
Beispiel #27
0
/*!
 * \brief TextDoc::TextDoc Text document constructor
 * \param App_ is the parent object
 * \param Name_ is the initial text document name
 */
TextDoc::TextDoc(QucsApp *App_, const QString& Name_) : QPlainTextEdit(), QucsDoc(App_, Name_)
{
  TextFont = QFont("Courier New");
  TextFont.setPointSize(QucsSettings.font.pointSize()-1);
  TextFont.setStyleHint(QFont::Courier);
  TextFont.setFixedPitch(true);
  document()->setDefaultFont(TextFont);

  simulation = true;
  Library = "";
  Libraries = "";
  SetChanged = false;
  devtype = DEV_DEF;

  tmpPosX = tmpPosY = 1;  // set to 1 to trigger line highlighting
  Scale = (float)TextFont.pointSize();
  //TODO (not supported) setUndoDepth(QucsSettings.maxUndo);
  setLanguage (Name_);
  QFileInfo Info (Name_);

  if(App) {
    if(Name_.isEmpty()) {
      App->DocumentTab->addTab(this, QPixmap(empty_xpm), QObject::tr("untitled"));
      }
    else {
      App->DocumentTab->addTab(this, QPixmap(empty_xpm), Info.fileName());
    }
    App->DocumentTab->setCurrentPage(App->DocumentTab->indexOf(this));

    viewport()->setFocus();

    setWordWrapMode(QTextOption::NoWrap);
    setPaletteBackgroundColor(QucsSettings.BGColor);
    connect(this, SIGNAL(textChanged()), SLOT(slotSetChanged()));
    connect(this, SIGNAL(cursorPositionChanged()),
            SLOT(slotCursorPosChanged()));

    syntaxHighlight = new SyntaxHighlighter(this);
    syntaxHighlight->setLanguage(language);
    syntaxHighlight->setDocument(document());

    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
    highlightCurrentLine();
  }
}
Beispiel #28
0
/* ContactBrowser */
ContactBrowser::ContactBrowser( QWidget *parent, const char * objectName)
    : QDLBrowserClient( parent, "contactnotes" )
{
    setObjectName(objectName);

    setFrameStyle(NoFrame);
    setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);

    connect(this, SIGNAL(highlighted(QString)),
            this, SLOT(linkHighlighted(QString)));

    QSoftMenuBar::setLabel(this, Qt::Key_Back,
        QSoftMenuBar::Back, QSoftMenuBar::AnyFocus);
    QSoftMenuBar::setLabel(this, Qt::Key_Select,
        QSoftMenuBar::NoLabel, QSoftMenuBar::AnyFocus);
    mDocument = NULL;
}
Beispiel #29
0
AdvancedRenameLineEdit::AdvancedRenameLineEdit(QWidget* parent)
    : QTextEdit(parent), d(new AdvancedRenameLineEditPriv)
{
    setLineWrapMode(QTextEdit::NoWrap);
    setWordWrapMode(QTextOption::NoWrap);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setFrameStyle(QFrame::NoFrame);
    setPalette(kapp->palette());
    setFocusPolicy(Qt::StrongFocus);

    viewport()->setAutoFillBackground(false);
    setAutoFillBackground(false);

    QFontMetrics fm = fontMetrics();
    setFixedHeight(fm.height());

    // --------------------------------------------------------

    d->parseTimer = new QTimer(this);
    d->parseTimer->setInterval(500);
    d->parseTimer->setSingleShot(true);

    // --------------------------------------------------------

    // layout widget correctly by setting a dummy text and calling ensureCursorVisible().
    // Save the scrollbar position now, to avoid scrolling of the text when selecting with the mouse
    setPlainText("DUMMY TEXT");
    ensureCursorVisible();
    d->verticalSliderPosition = verticalScrollBar()->value();
    clear();

    // --------------------------------------------------------

    connect(d->parseTimer, SIGNAL(timeout()),
            this, SLOT(slotParseTimer()));

    connect(this, SIGNAL(textChanged()),
            this, SLOT(slotTextChanged()));

    connect(this, SIGNAL(cursorPositionChanged()),
            this, SLOT(slotCursorPositionChanged()));
}
Beispiel #30
0
/*!
 * \brief TextDoc::TextDoc Text document constructor
 * \param App_ is the parent object
 * \param Name_ is the initial text document name
 */
TextDoc::TextDoc(QucsApp *App_, const QString& Name_) : QPlainTextEdit(), QucsDoc(App_, Name_)
{
  TextFont = QFont("Courier New");
  TextFont.setPointSize(QucsSettings.font.pointSize()-1);
  TextFont.setStyleHint(QFont::Courier);
  TextFont.setFixedPitch(true);
  document()->setDefaultFont(TextFont);

  simulation = true;
  Library = "";
  Libraries = "";
  SetChanged = false;
  devtype = DEV_DEF;

  tmpPosX = tmpPosY = 1;  // set to 1 to trigger line highlighting
  Scale = (float)TextFont.pointSize();
  setLanguage (Name_);

  viewport()->setFocus();

  setWordWrapMode(QTextOption::NoWrap);
  setPaletteBackgroundColor(QucsSettings.BGColor);
  connect(this, SIGNAL(textChanged()), SLOT(slotSetChanged()));
  connect(this, SIGNAL(cursorPositionChanged()),
          SLOT(slotCursorPosChanged()));
  if (App_) {
    connect(this, SIGNAL(signalCursorPosChanged(int, int)),
        App_, SLOT(printCursorPosition(int, int)));
    connect(this, SIGNAL(signalUndoState(bool)),
        App_, SLOT(slotUpdateUndo(bool)));
    connect(this, SIGNAL(signalRedoState(bool)),
        App_, SLOT(slotUpdateRedo(bool)));
    connect(this, SIGNAL(signalFileChanged(bool)),
        App_, SLOT(slotFileChanged(bool)));
  }

  syntaxHighlight = new SyntaxHighlighter(this);
  syntaxHighlight->setLanguage(language);
  syntaxHighlight->setDocument(document());

  connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
  highlightCurrentLine();
}