~larryprice/acolyterm/release-0.1

« back to all changes in this revision

Viewing changes to src/plugin/qmltermwidget/lib/TerminalDisplay.cpp

  • Committer: Larry Price
  • Date: 2016-06-15 14:47:59 UTC
  • Revision ID: larry.price@canonical.com-20160615144759-6wopn0gxwgta3x1n
Updating QMLTermWidget and removing unnecessary konsole codebase

Show diffs side-by-side

added added

removed removed

Lines of Context:
280
280
 
281
281
    m_font = font;
282
282
    fontChange(font);
 
283
    emit vtFontChanged();
283
284
  //}
284
285
}
285
286
 
 
287
void TerminalDisplay::setBoldIntense(bool value)
 
288
{
 
289
    if ( _boldIntense != value ) {
 
290
        _boldIntense = value;
 
291
        emit boldIntenseChanged();
 
292
    }
 
293
}
 
294
 
286
295
void TerminalDisplay::setFont(const QFont &f)
287
296
{
288
 
  Q_UNUSED(f);
289
 
  // ignore font change request if not coming from konsole itself
 
297
    Q_UNUSED(f);
 
298
    // ignore font change request if not coming from konsole itself
290
299
}
291
300
 
292
301
/* ------------------------------------------------------------------------- */
329
338
,_cursorBlinking(false)
330
339
,_hasBlinkingCursor(false)
331
340
,_allowBlinkingText(true)
332
 
,_dragMode(CtrlModifierDrag)
 
341
,_ctrlDrag(false)
333
342
,_tripleClickMode(SelectWholeLine)
334
343
,_isFixedSize(false)
335
344
,_possibleTripleClick(false)
345
354
,mMotionAfterPasting(NoMoveScreenWindow)
346
355
,m_font("Monospace", 12)
347
356
,m_color_role(QPalette::Background)
 
357
,m_full_cursor_height(false)
348
358
{
349
359
  // terminal applications are not designed with Right-To-Left in mind,
350
360
  // so the layout is forced to Left-To-Right
656
666
                                 bool& invertCharacterColor)
657
667
{
658
668
    QRect cursorRect = rect;
659
 
    cursorRect.setHeight(_fontHeight - _lineSpacing - 1);
 
669
    cursorRect.setHeight(_fontHeight - ((m_full_cursor_height) ? 0 : _lineSpacing) - 1);
660
670
    
661
671
    if (!_cursorBlinking)
662
672
    {
1270
1280
    //drawBackground(*painter, rect, m_palette.background().color(), false /* use opacity setting */);
1271
1281
    drawContents(*painter, dirtyRect);
1272
1282
 
1273
 
    emit imagePainted();
1274
 
 
1275
1283
    //drawInputMethodPreeditString(*painter, preeditRect());
1276
1284
    //paintFilters(painter);
1277
1285
}
1804
1812
    
1805
1813
    selected =  _screenWindow->isSelected(pos.x(),pos.y());
1806
1814
 
1807
 
    if (((_dragMode == DragMode::CtrlModifierDrag && ev->modifiers() & Qt::ControlModifier) ||
1808
 
         _dragMode == DragMode::NoModifierDrag) && selected ) {
 
1815
    if ((!_ctrlDrag || ev->modifiers() & Qt::ControlModifier) && selected ) {
1809
1816
      // The user clicked inside selected text
1810
1817
      dragInfo.state = diPending;
1811
1818
      dragInfo.start = ev->pos();
2571
2578
  emitSelection(true,false);
2572
2579
}
2573
2580
 
2574
 
// TODO: These 2 functions are not in the upstream LxQt version
2575
 
// See https://code.launchpad.net/~mcintire-evan/ubuntu-terminal-app/disable-paste/+merge/283244/comments/725331
2576
 
bool TerminalDisplay::isClipboardEmpty()
2577
 
{
2578
 
    return QApplication::clipboard()->text().isEmpty();
2579
 
}
2580
 
 
2581
 
bool TerminalDisplay::isSelectionEmpty()
2582
 
{
2583
 
    return _screenWindow->selectedText(_preserveLineBreaks).isEmpty();
2584
 
}
2585
 
 
2586
2581
/* ------------------------------------------------------------------------- */
2587
2582
/*                                                                           */
2588
2583
/*                                Keyboard                                   */
2998
2993
{
2999
2994
  if (event->mimeData()->hasFormat("text/plain"))
3000
2995
      event->acceptProposedAction();
3001
 
  if (event->mimeData()->urls().count());
 
2996
  if (event->mimeData()->urls().count())
3002
2997
      event->acceptProposedAction();
3003
2998
}
3004
2999
 
3100
3095
 
3101
3096
void TerminalDisplay::setLineSpacing(uint i)
3102
3097
{
3103
 
  _lineSpacing = i;
3104
 
  setVTFont(font()); // Trigger an update.
 
3098
    if ( i != _lineSpacing ) {
 
3099
      _lineSpacing = i;
 
3100
      setVTFont(font()); // Trigger an update.
 
3101
      emit lineSpacingChanged();
 
3102
    }
3105
3103
}
3106
3104
 
3107
3105
AutoScrollHandler::AutoScrollHandler(QWidget* parent)
3182
3180
//            QQuickPaintedItem::update(rect.adjusted(-1, -1, +1, +1));
3183
3181
//        }
3184
3182
    QQuickPaintedItem::update(region.boundingRect().adjusted(-1, -1, +1, +1));
 
3183
    emit imagePainted();
3185
3184
}
3186
3185
 
3187
3186
void TerminalDisplay::update()
3241
3240
 
3242
3241
void TerminalDisplay::setColorScheme(const QString &name)
3243
3242
{
3244
 
    const ColorScheme *cs;
3245
 
    // avoid legacy (int) solution
3246
 
    if (!availableColorSchemes().contains(name))
3247
 
        cs = ColorSchemeManager::instance()->defaultColorScheme();
3248
 
    else
3249
 
        cs = ColorSchemeManager::instance()->findColorScheme(name);
3250
 
 
3251
 
    if (! cs)
3252
 
    {
3253
 
        qDebug() << "Cannot load color scheme: " << name;
3254
 
        return;
 
3243
    if ( name != _colorScheme ) {
 
3244
        const ColorScheme *cs;
 
3245
        // avoid legacy (int) solution
 
3246
        if (!availableColorSchemes().contains(name))
 
3247
            cs = ColorSchemeManager::instance()->defaultColorScheme();
 
3248
        else
 
3249
            cs = ColorSchemeManager::instance()->findColorScheme(name);
 
3250
 
 
3251
        if (! cs)
 
3252
        {
 
3253
            qDebug() << "Cannot load color scheme: " << name;
 
3254
            return;
 
3255
        }
 
3256
 
 
3257
        ColorEntry table[TABLE_COLORS];
 
3258
        cs->getColorTable(table);
 
3259
        setColorTable(table);
 
3260
 
 
3261
        setFillColor(cs->backgroundColor());
 
3262
        _colorScheme = name;
 
3263
        emit colorSchemeChanged();
3255
3264
    }
3256
 
 
3257
 
    ColorEntry table[TABLE_COLORS];
3258
 
    cs->getColorTable(table);
3259
 
    setColorTable(table);
3260
 
 
3261
 
    setFillColor(cs->backgroundColor());
3262
 
}
3263
 
 
3264
 
void TerminalDisplay::simulateKeyPress(int key, int modifiers, bool pressed, quint32 nativeScanCode, QString text)
 
3265
}
 
3266
 
 
3267
QString TerminalDisplay::colorScheme() const
 
3268
{
 
3269
    return _colorScheme;
 
3270
}
 
3271
 
 
3272
void TerminalDisplay::simulateKeyPress(int key, int modifiers, bool pressed, quint32 nativeScanCode, const QString &text)
3265
3273
{
3266
3274
    Q_UNUSED(nativeScanCode);
3267
 
 
3268
 
    // TODO WORKAROUND: If text is not given we try to guess it from the unicode value.
3269
 
    // This solution is probably not complete on the domain, but works for the most common cases.
3270
 
    if (text.isEmpty()) {
3271
 
        bool shiftMod = modifiers & Qt::ShiftModifier;
3272
 
        text = QString(shiftMod ? QChar(key) : QChar(key).toLower());
3273
 
    }
3274
 
 
3275
3275
    QEvent::Type type = pressed ? QEvent::KeyPress : QEvent::KeyRelease;
3276
3276
    QKeyEvent event = QKeyEvent(type, key, (Qt::KeyboardModifier) modifiers, text);
3277
3277
    keyPressedSignal(&event);
3332
3332
    return QSize(_fontWidth, _fontHeight);
3333
3333
}
3334
3334
 
 
3335
void TerminalDisplay::setFullCursorHeight(bool val)
 
3336
{
 
3337
    if ( m_full_cursor_height != val ) {
 
3338
        m_full_cursor_height = val;
 
3339
        emit fullCursorHeightChanged();
 
3340
    }
 
3341
}
 
3342
 
 
3343
bool TerminalDisplay::fullCursorHeight() const
 
3344
{
 
3345
    return m_full_cursor_height;
 
3346
}
 
3347
 
3335
3348
void TerminalDisplay::itemChange(ItemChange change, const ItemChangeData & value)
3336
3349
{
3337
3350
    switch (change) {