Mercurial > octave-dspies
annotate libgui/qterminal/libqterminal/unix/TerminalView.cpp @ 19010:3fb030666878 draft default tip dspies
Added special-case logical-indexing function
* logical-index.h (New file) : Logical-indexing function. May be called on
octave_value types via call_bool_index
* nz-iterators.h : Add base-class nz_iterator for iterator types. Array has
template bool for whether to internally store row-col or compute on the fly
Add skip_ahead method which skips forward to the next nonzero after its
argument
Add flat_index for computing octave_idx_type index of current position (with
assertion failure in the case of overflow)
Move is_zero to separate file
* ov-base-diag.cc, ov-base-mat.cc, ov-base-sparse.cc, ov-perm.cc
(do_index_op): Add call to call_bool_index in logical-index.h
* Array.h : Move forward-declaration for array_iterator to separate header file
* dim-vector.cc (dim_max): Refers to idx-bounds.h (max_idx)
* array-iter-decl.h (New file): Header file for forward declaration of
array-iterator
* direction.h : Add constants fdirc and bdirc to avoid having to reconstruct
them
* dv-utils.h, dv-utils.cc (New files) :
Utility functions for querying and constructing dim-vectors
* idx-bounds.h (New file) :
Utility constants and functions for determining whether things will overflow
the maximum allowed bounds
* interp-idx.h (New function : to_flat_idx) : Converts row-col pair to linear
index of octave_idx_type
* is-zero.h (New file) : Function for determining whether an element is zero
* logical-index.tst : Add tests for correct return-value dimensions and large
sparse matrix behavior
author | David Spies <dnspies@gmail.com> |
---|---|
date | Fri, 25 Jul 2014 13:39:31 -0600 |
parents | dcb260e7a648 |
children |
rev | line source |
---|---|
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1 /* |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2 This file is part of Konsole, a terminal emulator for KDE. |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
3 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
4 Copyright (C) 2006-7 by Robert Knight <robertknight@gmail.com> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
5 Copyright (C) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
6 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
7 Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008 |
18640
a25bbe8c954c
Update Jacob Dawid's email address
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
18555
diff
changeset
|
8 Copyright (C) 2012-2013 Jacob Dawid <jacob.dawid@cybercatalyst.com> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
9 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
10 This program is free software; you can redistribute it and/or modify |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
11 it under the terms of the GNU General Public License as published by |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
12 the Free Software Foundation; either version 2 of the License, or |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
13 (at your option) any later version. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
14 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
15 This program is distributed in the hope that it will be useful, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
16 but WITHOUT ANY WARRANTY; without even the implied warranty of |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
18 GNU General Public License for more details. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
19 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
20 You should have received a copy of the GNU General Public License |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
21 along with this program; if not, write to the Free Software |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
23 02110-1301 USA. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
24 */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
25 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
26 // Own |
15653
35c891dce299
Removed INCLUDEPATH.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15651
diff
changeset
|
27 #include "unix/TerminalView.h" |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
28 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
29 // Qt |
17827
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
30 #include <QApplication> |
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
31 #include <QBoxLayout> |
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
32 #include <QClipboard> |
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
33 #include <QKeyEvent> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
34 #include <QtCore/QEvent> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
35 #include <QtCore/QTime> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
36 #include <QtCore/QFile> |
17827
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
37 #include <QGridLayout> |
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
38 #include <QLabel> |
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
39 #include <QLayout> |
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
40 #include <QPainter> |
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
41 #include <QPixmap> |
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
42 #include <QScrollBar> |
2de613986374
include Qt files with <QFoo> instead of <QtGui/QFoo> (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
43 #include <QStyle> |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
44 #include <QtCore> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
45 #include <QtGui> |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
46 |
15653
35c891dce299
Removed INCLUDEPATH.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15651
diff
changeset
|
47 #include "unix/Filter.h" |
35c891dce299
Removed INCLUDEPATH.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15651
diff
changeset
|
48 #include "unix/konsole_wcwidth.h" |
35c891dce299
Removed INCLUDEPATH.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15651
diff
changeset
|
49 #include "unix/ScreenWindow.h" |
35c891dce299
Removed INCLUDEPATH.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15651
diff
changeset
|
50 #include "unix/TerminalCharacterDecoder.h" |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
51 |
16538
8e180eac78d0
raise SIGWINCH signal in Unix GUI terminal window when size changes
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
52 #include <signal.h> |
8e180eac78d0
raise SIGWINCH signal in Unix GUI terminal window when size changes
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
53 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
54 #ifndef loc |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
55 #define loc(X,Y) ((Y)*_columns+(X)) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
56 #endif |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
57 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
58 #define yMouseScroll 1 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
59 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
60 #define REPCHAR "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
61 "abcdefgjijklmnopqrstuvwxyz" \ |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
62 "0123456789./+@" |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
63 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
64 // scroll increment used when dragging selection at top/bottom of window. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
65 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
66 // static |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
67 bool TerminalView::_antialiasText = true; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
68 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
69 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
70 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
71 /* Colors */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
72 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
73 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
74 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
75 /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
76 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
77 Code 0 1 2 3 4 5 6 7 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
78 ----------- ------- ------- ------- ------- ------- ------- ------- ------- |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
79 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
80 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
81 */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
82 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
83 ScreenWindow* TerminalView::screenWindow() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
84 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
85 return _screenWindow; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
86 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
87 void TerminalView::setScreenWindow(ScreenWindow* window) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
88 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
89 // disconnect existing screen window if any |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
90 if ( _screenWindow ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
91 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
92 disconnect( _screenWindow , 0 , this , 0 ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
93 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
94 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
95 _screenWindow = window; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
96 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
97 if ( window ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
98 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
99 //#warning "The order here is not specified - does it matter whether updateImage or updateLineProperties comes first?" |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
100 connect( _screenWindow , SIGNAL(outputChanged()) , this , SLOT(updateLineProperties()) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
101 connect( _screenWindow , SIGNAL(outputChanged()) , this , SLOT(updateImage()) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
102 window->setWindowLines(_lines); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
103 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
104 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
105 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
106 const ColorEntry* TerminalView::colorTable() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
107 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
108 return _colorTable; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
109 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
110 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
111 void TerminalView::setColorTable(const ColorEntry table[]) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
112 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
113 for (int i = 0; i < TABLE_COLORS; i++) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
114 _colorTable[i] = table[i]; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
115 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
116 QPalette p = palette(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
117 p.setColor( backgroundRole(), _colorTable[DEFAULT_BACK_COLOR].color ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
118 setPalette( p ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
119 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
120 // Avoid propagating the palette change to the scroll bar |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
121 _scrollBar->setPalette( QApplication::palette() ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
122 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
123 update(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
124 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
125 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
126 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
127 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
128 /* Font */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
129 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
130 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
131 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
132 /* |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
133 The VT100 has 32 special graphical characters. The usual vt100 extended |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
134 xterm fonts have these at 0x00..0x1f. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
135 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
136 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
137 come in here as proper unicode characters. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
138 |
15678
a1bcffac7fa8
fixed cursor position
Jen Stewart <jen.stewart.london@gmail.com>
parents:
15676
diff
changeset
|
139 We treat non-iso10646 fonts as VT100 extended and do the required mapping |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
140 from unicode to 0x00..0x1f. The remaining translation is then left to the |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
141 QCodec. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
142 */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
143 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
144 static inline bool isLineChar(quint16 c) { return ((c & 0xFF80) == 0x2500);} |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
145 static inline bool isLineCharString(const QString& string) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
146 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
147 return (string.length() > 0) && (isLineChar(string.at(0).unicode())); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
148 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
149 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
150 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
151 // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
152 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
153 unsigned short vt100_graphics[32] = |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
154 { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
155 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
156 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
157 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
158 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
159 }; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
160 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
161 void TerminalView::fontChange(const QFont&) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
162 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
163 QFontMetrics fm(font()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
164 _fontHeight = fm.height() + _lineSpacing; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
165 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
166 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
167 // waba TerminalDisplay 1.123: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
168 // "Base character width on widest ASCII character. This prevents too wide |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
169 // characters in the presence of double wide (e.g. Japanese) characters." |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
170 // Get the width from representative normal width characters |
15678
a1bcffac7fa8
fixed cursor position
Jen Stewart <jen.stewart.london@gmail.com>
parents:
15676
diff
changeset
|
171 _fontWidth = (double)fm.width(REPCHAR)/(double)strlen(REPCHAR); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
172 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
173 _fixedFont = true; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
174 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
175 int fw = fm.width(REPCHAR[0]); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
176 for(unsigned int i=1; i< strlen(REPCHAR); i++) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
177 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
178 if (fw != fm.width(REPCHAR[i])) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
179 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
180 _fixedFont = false; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
181 break; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
182 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
183 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
184 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
185 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
186 if (_fontWidth < 1) |
15678
a1bcffac7fa8
fixed cursor position
Jen Stewart <jen.stewart.london@gmail.com>
parents:
15676
diff
changeset
|
187 _fontWidth = 1; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
188 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
189 _fontAscent = fm.ascent(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
190 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
191 emit changedFontMetricSignal( _fontHeight, _fontWidth ); |
15673
76452c97add8
Removed restriction on maximum terminal size.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15671
diff
changeset
|
192 //parentWidget()->setFixedWidth(_fontWidth * 80 + _leftMargin); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
193 propagateSize(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
194 update(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
195 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
196 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
197 void TerminalView::setVTFont(const QFont& f) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
198 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
199 QFont font = f; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
200 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
201 QFontMetrics metrics(font); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
202 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
203 if ( metrics.height() < height() && metrics.maxWidth() < width() ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
204 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
205 // hint that text should be drawn without anti-aliasing. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
206 // depending on the user's font configuration, this may not be respected |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
207 if (!_antialiasText) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
208 font.setStyleStrategy( QFont::NoAntialias ); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
209 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
210 // experimental optimization. Konsole assumes that the terminal is using a |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
211 // mono-spaced font, in which case kerning information should have an effect. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
212 // Disabling kerning saves some computation when rendering text. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
213 // font.setKerning(false); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
214 |
18973
625e3bb65885
don't require Qt 4.7 (bug #42657)
John W. Eaton <jwe@octave.org>
parents:
18657
diff
changeset
|
215 QFont::StyleStrategy strategy = font.styleStrategy(); |
625e3bb65885
don't require Qt 4.7 (bug #42657)
John W. Eaton <jwe@octave.org>
parents:
18657
diff
changeset
|
216 #if defined (HAVE_QFONT_FORCE_INTEGER_METRICS) |
625e3bb65885
don't require Qt 4.7 (bug #42657)
John W. Eaton <jwe@octave.org>
parents:
18657
diff
changeset
|
217 strategy |= QFont::ForceIntegerMetrics; |
625e3bb65885
don't require Qt 4.7 (bug #42657)
John W. Eaton <jwe@octave.org>
parents:
18657
diff
changeset
|
218 #endif |
625e3bb65885
don't require Qt 4.7 (bug #42657)
John W. Eaton <jwe@octave.org>
parents:
18657
diff
changeset
|
219 font.setStyleStrategy(QFont::StyleStrategy(strategy)); |
18657
5fb180e37d7c
force integer font metric in gui terminal (partial fix of bug #37187)
Torsten <ttl@justmail.de>
parents:
17920
diff
changeset
|
220 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
221 QWidget::setFont(font); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
222 fontChange(font); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
223 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
224 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
225 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
226 void TerminalView::setFont(const QFont &) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
227 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
228 // ignore font change request if not coming from konsole itself |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
229 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
230 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
231 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
232 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
233 /* Constructor / Destructor */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
234 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
235 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
236 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
237 TerminalView::TerminalView(QWidget *parent) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
238 :QWidget(parent) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
239 ,_screenWindow(0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
240 ,_allowBell(true) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
241 ,_gridLayout(0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
242 ,_fontHeight(1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
243 ,_fontWidth(1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
244 ,_fontAscent(1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
245 ,_lines(1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
246 ,_columns(1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
247 ,_usedLines(1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
248 ,_usedColumns(1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
249 ,_contentHeight(1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
250 ,_contentWidth(1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
251 ,_image(0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
252 ,_randomSeed(0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
253 ,_resizing(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
254 ,_terminalSizeHint(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
255 ,_terminalSizeStartup(true) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
256 ,_actSel(0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
257 ,_wordSelectionMode(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
258 ,_lineSelectionMode(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
259 ,_preserveLineBreaks(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
260 ,_columnSelectionMode(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
261 ,_scrollbarLocation(NoScrollBar) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
262 ,_wordCharacters(":@-./_~") |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
263 ,_bellMode(SystemBeepBell) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
264 ,_blinking(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
265 ,_cursorBlinking(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
266 ,_hasBlinkingCursor(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
267 ,_ctrlDrag(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
268 ,_tripleClickMode(SelectWholeLine) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
269 ,_isFixedSize(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
270 ,_possibleTripleClick(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
271 ,_resizeWidget(0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
272 ,_resizeTimer(0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
273 ,_outputSuspendedLabel(0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
274 ,_lineSpacing(0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
275 ,_colorsInverted(false) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
276 ,_blendColor(qRgba(0,0,0,0xff)) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
277 ,_filterChain(new TerminalImageFilterChain()) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
278 ,_cursorShape(BlockCursor) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
279 ,_readonly(false) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
280 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
281 // terminal applications are not designed with Right-To-Left in mind, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
282 // so the layout is forced to Left-To-Right |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
283 setLayoutDirection(Qt::LeftToRight); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
284 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
285 // The offsets are not yet calculated. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
286 // Do not calculate these too often to be more smoothly when resizing |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
287 // konsole in opaque mode. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
288 _topMargin = DEFAULT_TOP_MARGIN; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
289 _leftMargin = DEFAULT_LEFT_MARGIN; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
290 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
291 // create scroll bar for scrolling output up and down |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
292 // set the scroll bar's slider to occupy the whole area of the scroll bar initially |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
293 _scrollBar = new QScrollBar(this); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
294 setScroll(0,0); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
295 _scrollBar->setCursor( Qt::ArrowCursor ); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
296 connect(_scrollBar, SIGNAL(valueChanged(int)), this, |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
297 SLOT(scrollBarPositionChanged(int))); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
298 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
299 // setup timers for blinking cursor and text |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
300 _blinkTimer = new QTimer(this); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
301 connect(_blinkTimer, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
302 _blinkCursorTimer = new QTimer(this); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
303 connect(_blinkCursorTimer, SIGNAL(timeout()), this, SLOT(blinkCursorEvent())); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
304 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
305 // QCursor::setAutoHideCursor( this, true ); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
306 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
307 setUsesMouse(true); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
308 setColorTable(base_color_table); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
309 setMouseTracking(true); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
310 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
311 // Enable drag and drop |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
312 setAcceptDrops(true); // attempt |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
313 dragInfo.state = diNone; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
314 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
315 setFocusPolicy( Qt::WheelFocus ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
316 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
317 // enable input method support |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
318 setAttribute(Qt::WA_InputMethodEnabled, true); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
319 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
320 // this is an important optimization, it tells Qt |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
321 // that TerminalDisplay will handle repainting its entire area. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
322 setAttribute(Qt::WA_OpaquePaintEvent); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
323 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
324 _gridLayout = new QGridLayout(this); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
325 _gridLayout->setMargin(0); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
326 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
327 setLayout( _gridLayout ); |
16970
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16956
diff
changeset
|
328 |
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16956
diff
changeset
|
329 connect (this, SIGNAL (set_global_shortcuts_signal (bool)), |
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16956
diff
changeset
|
330 parent->parent (), SLOT (set_global_shortcuts (bool))); |
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16956
diff
changeset
|
331 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
332 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
333 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
334 TerminalView::~TerminalView() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
335 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
336 qApp->removeEventFilter( this ); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
337 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
338 delete[] _image; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
339 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
340 delete _gridLayout; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
341 delete _outputSuspendedLabel; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
342 delete _filterChain; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
343 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
344 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
345 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
346 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
347 /* Display Operations */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
348 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
349 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
350 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
351 /** |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
352 A table for emulating the simple (single width) unicode drawing chars. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
353 It represents the 250x - 257x glyphs. If it's zero, we can't use it. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
354 if it's not, it's encoded as follows: imagine a 5x5 grid where the points are numbered |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
355 0 to 24 left to top, top to bottom. Each point is represented by the corresponding bit. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
356 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
357 Then, the pixels basically have the following interpretation: |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
358 _|||_ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
359 -...- |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
360 -...- |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
361 -...- |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
362 _|||_ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
363 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
364 where _ = none |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
365 | = vertical line. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
366 - = horizontal line. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
367 */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
368 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
369 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
370 enum LineEncode |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
371 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
372 TopL = (1<<1), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
373 TopC = (1<<2), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
374 TopR = (1<<3), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
375 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
376 LeftT = (1<<5), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
377 Int11 = (1<<6), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
378 Int12 = (1<<7), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
379 Int13 = (1<<8), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
380 RightT = (1<<9), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
381 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
382 LeftC = (1<<10), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
383 Int21 = (1<<11), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
384 Int22 = (1<<12), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
385 Int23 = (1<<13), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
386 RightC = (1<<14), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
387 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
388 LeftB = (1<<15), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
389 Int31 = (1<<16), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
390 Int32 = (1<<17), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
391 Int33 = (1<<18), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
392 RightB = (1<<19), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
393 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
394 BotL = (1<<21), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
395 BotC = (1<<22), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
396 BotR = (1<<23) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
397 }; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
398 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
399 #include "LineFont.h" |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
400 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
401 static void drawLineChar(QPainter& paint, int x, int y, int w, int h, uchar code) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
402 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
403 //Calculate cell midpoints, end points. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
404 int cx = x + w/2; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
405 int cy = y + h/2; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
406 int ex = x + w - 1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
407 int ey = y + h - 1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
408 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
409 quint32 toDraw = LineChars[code]; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
410 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
411 //Top _lines: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
412 if (toDraw & TopL) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
413 paint.drawLine(cx-1, y, cx-1, cy-2); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
414 if (toDraw & TopC) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
415 paint.drawLine(cx, y, cx, cy-2); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
416 if (toDraw & TopR) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
417 paint.drawLine(cx+1, y, cx+1, cy-2); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
418 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
419 //Bot _lines: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
420 if (toDraw & BotL) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
421 paint.drawLine(cx-1, cy+2, cx-1, ey); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
422 if (toDraw & BotC) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
423 paint.drawLine(cx, cy+2, cx, ey); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
424 if (toDraw & BotR) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
425 paint.drawLine(cx+1, cy+2, cx+1, ey); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
426 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
427 //Left _lines: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
428 if (toDraw & LeftT) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
429 paint.drawLine(x, cy-1, cx-2, cy-1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
430 if (toDraw & LeftC) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
431 paint.drawLine(x, cy, cx-2, cy); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
432 if (toDraw & LeftB) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
433 paint.drawLine(x, cy+1, cx-2, cy+1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
434 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
435 //Right _lines: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
436 if (toDraw & RightT) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
437 paint.drawLine(cx+2, cy-1, ex, cy-1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
438 if (toDraw & RightC) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
439 paint.drawLine(cx+2, cy, ex, cy); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
440 if (toDraw & RightB) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
441 paint.drawLine(cx+2, cy+1, ex, cy+1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
442 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
443 //Intersection points. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
444 if (toDraw & Int11) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
445 paint.drawPoint(cx-1, cy-1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
446 if (toDraw & Int12) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
447 paint.drawPoint(cx, cy-1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
448 if (toDraw & Int13) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
449 paint.drawPoint(cx+1, cy-1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
450 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
451 if (toDraw & Int21) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
452 paint.drawPoint(cx-1, cy); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
453 if (toDraw & Int22) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
454 paint.drawPoint(cx, cy); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
455 if (toDraw & Int23) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
456 paint.drawPoint(cx+1, cy); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
457 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
458 if (toDraw & Int31) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
459 paint.drawPoint(cx-1, cy+1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
460 if (toDraw & Int32) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
461 paint.drawPoint(cx, cy+1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
462 if (toDraw & Int33) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
463 paint.drawPoint(cx+1, cy+1); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
464 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
465 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
466 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
467 void TerminalView::drawLineCharString( QPainter& painter, int x, int y, const QString& str, |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
468 const Character* attributes) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
469 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
470 const QPen& currentPen = painter.pen(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
471 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
472 if ( attributes->rendition & RE_BOLD ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
473 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
474 QPen boldPen(currentPen); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
475 boldPen.setWidth(3); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
476 painter.setPen( boldPen ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
477 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
478 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
479 for (int i=0 ; i < str.length(); i++) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
480 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
481 uchar code = str[i].cell(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
482 if (LineChars[code]) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
483 drawLineChar(painter, x + (_fontWidth*i), y, _fontWidth, _fontHeight, code); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
484 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
485 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
486 painter.setPen( currentPen ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
487 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
488 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
489 void TerminalView::setKeyboardCursorShape(KeyboardCursorShape shape) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
490 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
491 _cursorShape = shape; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
492 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
493 TerminalView::KeyboardCursorShape TerminalView::keyboardCursorShape() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
494 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
495 return _cursorShape; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
496 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
497 void TerminalView::setKeyboardCursorColor(bool useForegroundColor, const QColor& color) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
498 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
499 if (useForegroundColor) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
500 _cursorColor = QColor(); // an invalid color means that |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
501 // the foreground color of the |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
502 // current character should |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
503 // be used |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
504 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
505 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
506 _cursorColor = color; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
507 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
508 QColor TerminalView::keyboardCursorColor() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
509 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
510 return _cursorColor; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
511 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
512 |
15675
22bd268429d3
Cursor is now blinking in the terminal.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15673
diff
changeset
|
513 void TerminalView::drawBackground(QPainter& painter, const QRect& rect, const QColor& backgroundColor) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
514 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
515 // the area of the widget showing the contents of the terminal display is drawn |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
516 // using the background color from the color scheme set with setColorTable() |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
517 // |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
518 // the area of the widget behind the scroll-bar is drawn using the background |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
519 // brush from the scroll-bar's palette, to give the effect of the scroll-bar |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
520 // being outside of the terminal display and visual consistency with other KDE |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
521 // applications. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
522 // |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
523 QRect scrollBarArea = _scrollBar->isVisible() ? |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
524 rect.intersected(_scrollBar->geometry()) : |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
525 QRect(); |
15675
22bd268429d3
Cursor is now blinking in the terminal.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15673
diff
changeset
|
526 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
527 QRegion contentsRegion = QRegion(rect).subtracted(scrollBarArea); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
528 QRect contentsRect = contentsRegion.boundingRect(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
529 |
15675
22bd268429d3
Cursor is now blinking in the terminal.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15673
diff
changeset
|
530 painter.fillRect(contentsRect, backgroundColor); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
531 painter.fillRect(scrollBarArea,_scrollBar->palette().background()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
532 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
533 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
534 void TerminalView::drawCursor(QPainter& painter, |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
535 const QRect& rect, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
536 const QColor& foregroundColor, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
537 const QColor& /*backgroundColor*/, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
538 bool& invertCharacterColor) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
539 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
540 QRect cursorRect = rect; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
541 cursorRect.setHeight(_fontHeight - _lineSpacing - 1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
542 |
16609
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
543 if (!_cursorBlinking) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
544 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
545 if ( _cursorColor.isValid() ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
546 painter.setPen(_cursorColor); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
547 else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
548 painter.setPen(foregroundColor); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
549 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
550 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
551 if ( _cursorShape == BlockCursor ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
552 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
553 // draw the cursor outline, adjusting the area so that |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
554 // it is draw entirely inside 'rect' |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
555 int penWidth = qMax(1,painter.pen().width()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
556 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
557 painter.drawRect(cursorRect.adjusted(penWidth/2, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
558 penWidth/2, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
559 - penWidth/2 - penWidth%2, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
560 - penWidth/2 - penWidth%2)); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
561 if ( hasFocus() ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
562 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
563 painter.fillRect(cursorRect, _cursorColor.isValid() ? _cursorColor : foregroundColor); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
564 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
565 if ( !_cursorColor.isValid() ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
566 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
567 // invert the colour used to draw the text to ensure that the character at |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
568 // the cursor position is readable |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
569 invertCharacterColor = true; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
570 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
571 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
572 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
573 else if ( _cursorShape == UnderlineCursor ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
574 painter.drawLine(cursorRect.left(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
575 cursorRect.bottom(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
576 cursorRect.right(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
577 cursorRect.bottom()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
578 else if ( _cursorShape == IBeamCursor ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
579 painter.drawLine(cursorRect.left(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
580 cursorRect.top(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
581 cursorRect.left(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
582 cursorRect.bottom()); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
583 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
584 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
585 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
586 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
587 void TerminalView::drawCharacters(QPainter& painter, |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
588 const QRect& rect, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
589 const QString& text, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
590 const Character* style, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
591 bool invertCharacterColor) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
592 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
593 // don't draw text which is currently blinking |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
594 if ( _blinking && (style->rendition & RE_BLINK) ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
595 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
596 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
597 // setup bold and underline |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
598 bool useBold = style->rendition & RE_BOLD || style->isBold(_colorTable) || font().bold(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
599 bool useUnderline = style->rendition & RE_UNDERLINE || font().underline(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
600 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
601 QFont font = painter.font(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
602 if ( font.bold() != useBold |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
603 || font.underline() != useUnderline ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
604 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
605 font.setBold(useBold); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
606 font.setUnderline(useUnderline); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
607 painter.setFont(font); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
608 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
609 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
610 const CharacterColor& textColor = ( invertCharacterColor ? style->backgroundColor : style->foregroundColor ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
611 const QColor color = textColor.color(_colorTable); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
612 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
613 QPen pen = painter.pen(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
614 if ( pen.color() != color ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
615 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
616 pen.setColor(color); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
617 painter.setPen(color); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
618 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
619 // draw text |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
620 if ( isLineCharString(text) ) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
621 drawLineCharString(painter,rect.x(),rect.y(),text,style); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
622 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
623 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
624 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
625 // the drawText(rect,flags,string) overload is used here with null flags |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
626 // instead of drawText(rect,string) because the (rect,string) overload causes |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
627 // the application's default layout direction to be used instead of |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
628 // the widget-specific layout direction, which should always be |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
629 // Qt::LeftToRight for this widget |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
630 painter.drawText(rect,0,text); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
631 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
632 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
633 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
634 void TerminalView::drawTextFragment(QPainter& painter , |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
635 const QRect& rect, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
636 const QString& text, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
637 const Character* style) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
638 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
639 painter.save(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
640 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
641 // setup painter |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
642 const QColor foregroundColor = style->foregroundColor.color(_colorTable); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
643 const QColor backgroundColor = style->backgroundColor.color(_colorTable); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
644 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
645 // draw background if different from the display's background color |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
646 if ( backgroundColor != palette().background().color() ) |
15675
22bd268429d3
Cursor is now blinking in the terminal.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15673
diff
changeset
|
647 drawBackground(painter,rect,backgroundColor); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
648 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
649 // draw cursor shape if the current character is the cursor |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
650 // this may alter the foreground and background colors |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
651 bool invertCharacterColor = false; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
652 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
653 if ( style->rendition & RE_CURSOR ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
654 drawCursor(painter,rect,foregroundColor,backgroundColor,invertCharacterColor); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
655 // draw text |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
656 drawCharacters(painter,rect,text,style,invertCharacterColor); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
657 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
658 painter.restore(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
659 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
660 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
661 void TerminalView::setRandomSeed(uint randomSeed) { _randomSeed = randomSeed; } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
662 uint TerminalView::randomSeed() const { return _randomSeed; } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
663 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
664 #if 0 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
665 /*! |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
666 Set XIM Position |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
667 */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
668 void TerminalDisplay::setCursorPos(const int curx, const int cury) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
669 { |
17872
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
670 QPoint tL = contentsRect().topLeft(); |
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
671 int tLx = tL.x(); |
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
672 int tLy = tL.y(); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
673 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
674 int xpos, ypos; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
675 ypos = _topMargin + tLy + _fontHeight*(cury-1) + _fontAscent; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
676 xpos = _leftMargin + tLx + _fontWidth*curx; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
677 //setMicroFocusHint(xpos, ypos, 0, _fontHeight); //### ??? |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
678 // fprintf(stderr, "x/y = %d/%d\txpos/ypos = %d/%d\n", curx, cury, xpos, ypos); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
679 _cursorLine = cury; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
680 _cursorCol = curx; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
681 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
682 #endif |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
683 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
684 // scrolls the image by 'lines', down if lines > 0 or up otherwise. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
685 // |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
686 // the terminal emulation keeps track of the scrolling of the character |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
687 // image as it receives input, and when the view is updated, it calls scrollImage() |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
688 // with the final scroll amount. this improves performance because scrolling the |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
689 // display is much cheaper than re-rendering all the text for the |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
690 // part of the image which has moved up or down. |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
691 // Instead only new lines have to be drawn |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
692 // |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
693 // note: it is important that the area of the display which is |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
694 // scrolled aligns properly with the character grid - |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
695 // which has a top left point at (_leftMargin,_topMargin) , |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
696 // a cell width of _fontWidth and a cell height of _fontHeight). |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
697 void TerminalView::scrollImage(int lines , const QRect& screenWindowRegion) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
698 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
699 // if the flow control warning is enabled this will interfere with the |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
700 // scrolling optimisations and cause artifacts. the simple solution here |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
701 // is to just disable the optimisation whilst it is visible |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
702 if ( _outputSuspendedLabel && _outputSuspendedLabel->isVisible() ) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
703 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
704 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
705 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
706 // constrain the region to the display |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
707 // the bottom of the region is capped to the number of lines in the display's |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
708 // internal image - 2, so that the height of 'region' is strictly less |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
709 // than the height of the internal image. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
710 QRect region = screenWindowRegion; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
711 region.setBottom( qMin(region.bottom(),this->_lines-2) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
712 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
713 if ( lines == 0 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
714 || _image == 0 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
715 || !region.isValid() |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
716 || (region.top() + abs(lines)) >= region.bottom() |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
717 || this->_lines <= region.height() ) return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
718 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
719 QRect scrollRect; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
720 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
721 void* firstCharPos = &_image[ region.top() * this->_columns ]; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
722 void* lastCharPos = &_image[ (region.top() + abs(lines)) * this->_columns ]; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
723 |
17872
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
724 int top = _topMargin + (region.top() * _fontHeight); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
725 int linesToMove = region.height() - abs(lines); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
726 int bytesToMove = linesToMove * |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
727 this->_columns * |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
728 sizeof(Character); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
729 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
730 Q_ASSERT( linesToMove > 0 ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
731 Q_ASSERT( bytesToMove > 0 ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
732 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
733 //scroll internal image |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
734 if ( lines > 0 ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
735 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
736 // check that the memory areas that we are going to move are valid |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
737 Q_ASSERT( (char*)lastCharPos + bytesToMove < |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
738 (char*)(_image + (this->_lines * this->_columns)) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
739 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
740 Q_ASSERT( (lines*this->_columns) < _imageSize ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
741 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
742 //scroll internal image down |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
743 memmove( firstCharPos , lastCharPos , bytesToMove ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
744 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
745 //set region of display to scroll, making sure that |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
746 //the region aligns correctly to the character grid |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
747 scrollRect = QRect( _leftMargin , top, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
748 this->_usedColumns * _fontWidth , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
749 linesToMove * _fontHeight ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
750 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
751 else |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
752 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
753 // check that the memory areas that we are going to move are valid |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
754 Q_ASSERT( (char*)firstCharPos + bytesToMove < |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
755 (char*)(_image + (this->_lines * this->_columns)) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
756 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
757 //scroll internal image up |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
758 memmove( lastCharPos , firstCharPos , bytesToMove ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
759 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
760 //set region of the display to scroll, making sure that |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
761 //the region aligns correctly to the character grid |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
762 QPoint topPoint( _leftMargin , top + abs(lines)*_fontHeight ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
763 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
764 scrollRect = QRect( topPoint , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
765 QSize( this->_usedColumns*_fontWidth , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
766 linesToMove * _fontHeight )); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
767 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
768 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
769 //scroll the display vertically to match internal _image |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
770 scroll( 0 , _fontHeight * (-lines) , scrollRect ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
771 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
772 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
773 QRegion TerminalView::hotSpotRegion() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
774 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
775 QRegion region; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
776 foreach( Filter::HotSpot* hotSpot , _filterChain->hotSpots() ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
777 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
778 QRect rect; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
779 rect.setLeft(hotSpot->startColumn()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
780 rect.setTop(hotSpot->startLine()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
781 rect.setRight(hotSpot->endColumn()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
782 rect.setBottom(hotSpot->endLine()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
783 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
784 region |= imageToWidget(rect); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
785 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
786 return region; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
787 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
788 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
789 void TerminalView::processFilters() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
790 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
791 if (!_screenWindow) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
792 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
793 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
794 QRegion preUpdateHotSpots = hotSpotRegion(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
795 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
796 // use _screenWindow->getImage() here rather than _image because |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
797 // other classes may call processFilters() when this display's |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
798 // ScreenWindow emits a scrolled() signal - which will happen before |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
799 // updateImage() is called on the display and therefore _image is |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
800 // out of date at this point |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
801 _filterChain->setImage( _screenWindow->getImage(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
802 _screenWindow->windowLines(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
803 _screenWindow->windowColumns(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
804 _screenWindow->getLineProperties() ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
805 _filterChain->process(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
806 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
807 QRegion postUpdateHotSpots = hotSpotRegion(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
808 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
809 update( preUpdateHotSpots | postUpdateHotSpots ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
810 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
811 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
812 void TerminalView::updateImage() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
813 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
814 if ( !_screenWindow ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
815 return; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
816 updateLineProperties(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
817 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
818 // optimization - scroll the existing image where possible and |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
819 // avoid expensive text drawing for parts of the image that |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
820 // can simply be moved up or down |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
821 scrollImage( _screenWindow->scrollCount() , |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
822 _screenWindow->scrollRegion() ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
823 _screenWindow->resetScrollCount(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
824 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
825 Character* const newimg = _screenWindow->getImage(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
826 int lines = _screenWindow->windowLines() + 1; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
827 int columns = _screenWindow->windowColumns(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
828 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
829 setScroll( _screenWindow->currentLine() , _screenWindow->lineCount() ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
830 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
831 if (!_image) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
832 updateImageSize(); // Create _image |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
833 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
834 Q_ASSERT( this->_usedLines <= this->_lines ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
835 Q_ASSERT( this->_usedColumns <= this->_columns ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
836 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
837 int y,x,len; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
838 |
17872
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
839 QPoint tL = contentsRect().topLeft(); |
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
840 |
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
841 int tLx = tL.x(); |
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
842 int tLy = tL.y(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
843 _hasBlinker = false; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
844 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
845 CharacterColor cf; // undefined |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
846 CharacterColor _clipboard; // undefined |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
847 int cr = -1; // undefined |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
848 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
849 const int linesToUpdate = qMin(this->_lines, qMax(0,lines )); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
850 const int columnsToUpdate = qMin(this->_columns,qMax(0,columns)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
851 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
852 QChar *disstrU = new QChar[columnsToUpdate]; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
853 char *dirtyMask = new char[columnsToUpdate+2]; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
854 QRegion dirtyRegion; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
855 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
856 // debugging variable, this records the number of lines that are found to |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
857 // be 'dirty' ( ie. have changed from the old _image to the new _image ) and |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
858 // which therefore need to be repainted |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
859 int dirtyLineCount = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
860 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
861 for (y = 0; y < linesToUpdate; y++) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
862 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
863 const Character* currentLine = &_image[y*this->_columns]; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
864 const Character* const newLine = &newimg[y*columns]; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
865 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
866 bool updateLine = false; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
867 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
868 // The dirty mask indicates which characters need repainting. We also |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
869 // mark surrounding neighbours dirty, in case the character exceeds |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
870 // its cell boundaries |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
871 memset(dirtyMask, 0, columnsToUpdate+2); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
872 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
873 for( x = 0 ; x < columnsToUpdate ; x++) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
874 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
875 if ( newLine[x] != currentLine[x] ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
876 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
877 dirtyMask[x] = true; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
878 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
879 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
880 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
881 if (!_resizing) // not while _resizing, we're expecting a paintEvent |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
882 for (x = 0; x < columnsToUpdate; x++) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
883 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
884 _hasBlinker |= (newLine[x].rendition & RE_BLINK); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
885 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
886 // Start drawing if this character or the next one differs. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
887 // We also take the next one into account to handle the situation |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
888 // where characters exceed their cell width. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
889 if (dirtyMask[x]) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
890 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
891 quint16 c = newLine[x+0].character; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
892 if ( !c ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
893 continue; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
894 int p = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
895 disstrU[p++] = c; //fontMap(c); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
896 bool lineDraw = isLineChar(c); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
897 bool doubleWidth = (x+1 == columnsToUpdate) ? false : (newLine[x+1].character == 0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
898 cr = newLine[x].rendition; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
899 _clipboard = newLine[x].backgroundColor; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
900 if (newLine[x].foregroundColor != cf) cf = newLine[x].foregroundColor; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
901 int lln = columnsToUpdate - x; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
902 for (len = 1; len < lln; len++) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
903 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
904 const Character& ch = newLine[x+len]; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
905 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
906 if (!ch.character) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
907 continue; // Skip trailing part of multi-col chars. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
908 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
909 bool nextIsDoubleWidth = (x+len+1 == columnsToUpdate) ? false : (newLine[x+len+1].character == 0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
910 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
911 if ( ch.foregroundColor != cf || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
912 ch.backgroundColor != _clipboard || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
913 ch.rendition != cr || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
914 !dirtyMask[x+len] || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
915 isLineChar(c) != lineDraw || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
916 nextIsDoubleWidth != doubleWidth ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
917 break; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
918 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
919 disstrU[p++] = c; //fontMap(c); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
920 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
921 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
922 QString unistr(disstrU, p); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
923 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
924 bool saveFixedFont = _fixedFont; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
925 if (lineDraw) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
926 _fixedFont = false; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
927 if (doubleWidth) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
928 _fixedFont = false; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
929 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
930 updateLine = true; |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
931 |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
932 _fixedFont = saveFixedFont; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
933 x += len - 1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
934 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
935 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
936 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
937 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
938 //both the top and bottom halves of double height _lines must always be redrawn |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
939 //although both top and bottom halves contain the same characters, only |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
940 //the top one is actually |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
941 //drawn. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
942 if (_lineProperties.count() > y) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
943 updateLine |= (_lineProperties[y] & LINE_DOUBLEHEIGHT); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
944 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
945 // if the characters on the line are different in the old and the new _image |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
946 // then this line must be repainted. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
947 if (updateLine) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
948 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
949 dirtyLineCount++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
950 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
951 // add the area occupied by this line to the region which needs to be |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
952 // repainted |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
953 QRect dirtyRect = QRect( _leftMargin+tLx , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
954 _topMargin+tLy+_fontHeight*y , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
955 _fontWidth * columnsToUpdate , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
956 _fontHeight ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
957 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
958 dirtyRegion |= dirtyRect; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
959 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
960 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
961 // replace the line of characters in the old _image with the |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
962 // current line of the new _image |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
963 memcpy((void*)currentLine,(const void*)newLine,columnsToUpdate*sizeof(Character)); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
964 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
965 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
966 // if the new _image is smaller than the previous _image, then ensure that the area |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
967 // outside the new _image is cleared |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
968 if ( linesToUpdate < _usedLines ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
969 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
970 dirtyRegion |= QRect( _leftMargin+tLx , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
971 _topMargin+tLy+_fontHeight*linesToUpdate , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
972 _fontWidth * this->_columns , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
973 _fontHeight * (_usedLines-linesToUpdate) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
974 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
975 _usedLines = linesToUpdate; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
976 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
977 if ( columnsToUpdate < _usedColumns ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
978 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
979 dirtyRegion |= QRect( _leftMargin+tLx+columnsToUpdate*_fontWidth , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
980 _topMargin+tLy , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
981 _fontWidth * (_usedColumns-columnsToUpdate) , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
982 _fontHeight * this->_lines ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
983 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
984 _usedColumns = columnsToUpdate; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
985 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
986 dirtyRegion |= _inputMethodData.previousPreeditRect; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
987 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
988 // update the parts of the display which have changed |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
989 update(dirtyRegion); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
990 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
991 if ( _hasBlinker && !_blinkTimer->isActive()) _blinkTimer->start( BLINK_DELAY ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
992 if (!_hasBlinker && _blinkTimer->isActive()) { _blinkTimer->stop(); _blinking = false; } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
993 delete[] dirtyMask; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
994 delete[] disstrU; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
995 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
996 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
997 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
998 void TerminalView::showResizeNotification() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
999 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1000 if (_terminalSizeHint && isVisible()) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1001 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1002 if (_terminalSizeStartup) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1003 _terminalSizeStartup=false; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1004 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1005 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1006 if (!_resizeWidget) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1007 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1008 _resizeWidget = new QLabel(("Size: XXX x XXX"), this); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1009 _resizeWidget->setMinimumWidth(_resizeWidget->fontMetrics().width(("Size: XXX x XXX"))); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1010 _resizeWidget->setMinimumHeight(_resizeWidget->sizeHint().height()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1011 _resizeWidget->setAlignment(Qt::AlignCenter); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1012 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1013 _resizeWidget->setStyleSheet("background-color:palette(window);border-style:solid;border-width:1px;border-color:palette(dark)"); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1014 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1015 _resizeTimer = new QTimer(this); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1016 _resizeTimer->setSingleShot(true); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1017 connect(_resizeTimer, SIGNAL(timeout()), _resizeWidget, SLOT(hide())); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1018 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1019 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1020 QString sizeStr; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1021 sizeStr.sprintf("Size: %d x %d", _columns, _lines); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1022 _resizeWidget->setText(sizeStr); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1023 _resizeWidget->move((width()-_resizeWidget->width())/2, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1024 (height()-_resizeWidget->height())/2+20); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1025 _resizeWidget->show(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1026 _resizeTimer->start(1000); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1027 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1028 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1029 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1030 void TerminalView::setBlinkingCursor(bool blink) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1031 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1032 _hasBlinkingCursor=blink; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1033 |
16609
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1034 setBlinkingCursorState(blink); |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1035 } |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1036 |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1037 void TerminalView::setBlinkingCursorState(bool blink) |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1038 { |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1039 if (blink && !_blinkCursorTimer->isActive()) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1040 _blinkCursorTimer->start(BLINK_DELAY); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1041 |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1042 if (!blink && _blinkCursorTimer->isActive()) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1043 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1044 _blinkCursorTimer->stop(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1045 if (_cursorBlinking) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1046 blinkCursorEvent(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1047 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1048 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1049 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1050 void TerminalView::paintEvent( QPaintEvent* pe ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1051 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1052 updateImage(); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1053 //qDebug("%s %d paintEvent", __FILE__, __LINE__); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1054 QPainter paint(this); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1055 //qDebug("%s %d paintEvent %d %d", __FILE__, __LINE__, paint.window().top(), paint.window().right()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1056 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1057 foreach (QRect rect, (pe->region() & contentsRect()).rects()) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1058 { |
15675
22bd268429d3
Cursor is now blinking in the terminal.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15673
diff
changeset
|
1059 drawBackground(paint,rect,palette().background().color()); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1060 drawContents(paint, rect); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1061 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1062 // drawBackground(paint,contentsRect(),palette().background().color(), true /* use opacity setting */); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1063 // drawContents(paint, contentsRect()); |
15675
22bd268429d3
Cursor is now blinking in the terminal.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15673
diff
changeset
|
1064 drawInputMethodPreeditString(paint,preeditRect()); |
22bd268429d3
Cursor is now blinking in the terminal.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15673
diff
changeset
|
1065 paintFilters(paint); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1066 paint.end(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1067 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1068 |
16609
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1069 void TerminalView::focusInEvent(QFocusEvent *focusEvent) |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1070 { |
16970
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16956
diff
changeset
|
1071 emit set_global_shortcuts_signal (false); // disable some shortcuts |
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16956
diff
changeset
|
1072 |
16609
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1073 setBlinkingCursorState(true); |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1074 updateImage(); |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1075 repaint(); |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1076 update(); |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1077 |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1078 QWidget::focusInEvent(focusEvent); |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1079 } |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1080 |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1081 void TerminalView::focusOutEvent(QFocusEvent *focusEvent) |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1082 { |
16970
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16956
diff
changeset
|
1083 emit set_global_shortcuts_signal (true); // re-enable shortcuts |
78116b88dbf5
enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents:
16956
diff
changeset
|
1084 |
16609
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1085 // Force the cursor to be redrawn. |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1086 _cursorBlinking = true; |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1087 setBlinkingCursorState(false); |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1088 |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1089 QWidget::focusOutEvent(focusEvent); |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1090 } |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1091 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1092 QPoint TerminalView::cursorPosition() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1093 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1094 if (_screenWindow) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1095 return _screenWindow->cursorPosition(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1096 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1097 return QPoint(0,0); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1098 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1099 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1100 QRect TerminalView::preeditRect() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1101 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1102 const int preeditLength = string_width(_inputMethodData.preeditString); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1103 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1104 if ( preeditLength == 0 ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1105 return QRect(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1106 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1107 return QRect(_leftMargin + _fontWidth*cursorPosition().x(), |
17872
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
1108 _topMargin + _fontHeight*cursorPosition().y(), |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1109 _fontWidth*preeditLength, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1110 _fontHeight); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1111 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1112 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1113 void TerminalView::drawInputMethodPreeditString(QPainter& painter , const QRect& rect) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1114 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1115 if ( _inputMethodData.preeditString.isEmpty() ) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1116 return; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1117 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1118 const QPoint cursorPos = cursorPosition(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1119 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1120 bool invertColors = false; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1121 const QColor background = _colorTable[DEFAULT_BACK_COLOR].color; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1122 const QColor foreground = _colorTable[DEFAULT_FORE_COLOR].color; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1123 const Character* style = &_image[loc(cursorPos.x(),cursorPos.y())]; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1124 |
15675
22bd268429d3
Cursor is now blinking in the terminal.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
15673
diff
changeset
|
1125 drawBackground(painter,rect,background); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1126 drawCursor(painter,rect,foreground,background,invertColors); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1127 drawCharacters(painter,rect,_inputMethodData.preeditString,style,invertColors); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1128 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1129 _inputMethodData.previousPreeditRect = rect; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1130 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1131 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1132 FilterChain* TerminalView::filterChain() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1133 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1134 return _filterChain; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1135 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1136 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1137 void TerminalView::paintFilters(QPainter& painter) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1138 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1139 //qDebug("%s %d paintFilters", __FILE__, __LINE__); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1140 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1141 // get color of character under mouse and use it to draw |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1142 // lines for filters |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1143 QPoint cursorPos = mapFromGlobal(QCursor::pos()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1144 int cursorLine; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1145 int cursorColumn; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1146 getCharacterPosition( cursorPos , cursorLine , cursorColumn ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1147 Character cursorCharacter = _image[loc(cursorColumn,cursorLine)]; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1148 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1149 painter.setPen( QPen(cursorCharacter.foregroundColor.color(colorTable())) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1150 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1151 // iterate over hotspots identified by the display's currently active filters |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1152 // and draw appropriate visuals to indicate the presence of the hotspot |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1153 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1154 QList<Filter::HotSpot*> spots = _filterChain->hotSpots(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1155 QListIterator<Filter::HotSpot*> iter(spots); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1156 while (iter.hasNext()) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1157 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1158 Filter::HotSpot* spot = iter.next(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1159 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1160 for ( int line = spot->startLine() ; line <= spot->endLine() ; line++ ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1161 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1162 int startColumn = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1163 int endColumn = _columns-1; // TODO use number of _columns which are actually |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1164 // occupied on this line rather than the width of the |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1165 // display in _columns |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1166 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1167 // ignore whitespace at the end of the lines |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1168 while ( QChar(_image[loc(endColumn,line)].character).isSpace() && endColumn > 0 ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1169 endColumn--; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1170 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1171 // increment here because the column which we want to set 'endColumn' to |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1172 // is the first whitespace character at the end of the line |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1173 endColumn++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1174 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1175 if ( line == spot->startLine() ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1176 startColumn = spot->startColumn(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1177 if ( line == spot->endLine() ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1178 endColumn = spot->endColumn(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1179 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1180 // subtract one pixel from |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1181 // the right and bottom so that |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1182 // we do not overdraw adjacent |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1183 // hotspots |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1184 // |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1185 // subtracting one pixel from all sides also prevents an edge case where |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1186 // moving the mouse outside a link could still leave it underlined |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1187 // because the check below for the position of the cursor |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1188 // finds it on the border of the target area |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1189 QRect r; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1190 r.setCoords( startColumn*_fontWidth + 1, line*_fontHeight + 1, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1191 endColumn*_fontWidth - 1, (line+1)*_fontHeight - 1 ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1192 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1193 // Underline link hotspots |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1194 if ( spot->type() == Filter::HotSpot::Link ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1195 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1196 QFontMetrics metrics(font()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1197 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1198 // find the baseline (which is the invisible line that the characters in the font sit on, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1199 // with some having tails dangling below) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1200 int baseline = r.bottom() - metrics.descent(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1201 // find the position of the underline below that |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1202 int underlinePos = baseline + metrics.underlinePos(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1203 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1204 if ( r.contains( mapFromGlobal(QCursor::pos()) ) ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1205 painter.drawLine( r.left() , underlinePos , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1206 r.right() , underlinePos ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1207 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1208 // Marker hotspots simply have a transparent rectanglular shape |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1209 // drawn on top of them |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1210 else if ( spot->type() == Filter::HotSpot::Marker ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1211 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1212 //TODO - Do not use a hardcoded colour for this |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1213 painter.fillRect(r,QBrush(QColor(255,0,0,120))); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1214 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1215 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1216 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1217 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1218 void TerminalView::drawContents(QPainter &paint, const QRect &rect) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1219 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1220 //qDebug("%s %d drawContents and rect x=%d y=%d w=%d h=%d", __FILE__, __LINE__, rect.x(), rect.y(),rect.width(),rect.height()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1221 |
17872
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
1222 QPoint topLeft = contentsRect().topLeft(); |
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
1223 // Take the topmost vertical position for the view. |
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
1224 int topLeftY = topLeft.y(); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1225 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1226 // In Konsole, the view has been centered. Don't do that here, since there |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1227 // are strange hopping effects during a resize when the view does no match |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1228 // exactly the widget width. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1229 // int topLeftX = (_contentWidth - _usedColumns * _fontWidth) / 2; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1230 int topLeftX = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1231 |
17857
c17a3e43956b
avoid partial lines at top of command window
John W. Eaton <jwe@octave.org>
parents:
17852
diff
changeset
|
1232 int leftUpperX = qMin(_usedColumns-1, qMax(0, qFloor((rect.left() - topLeftX - _leftMargin ) / _fontWidth))); |
c17a3e43956b
avoid partial lines at top of command window
John W. Eaton <jwe@octave.org>
parents:
17852
diff
changeset
|
1233 int leftUpperY = qMin(_usedLines-1, qMax(0, qFloor((rect.top() - topLeftY - _topMargin ) / _fontHeight))); |
c17a3e43956b
avoid partial lines at top of command window
John W. Eaton <jwe@octave.org>
parents:
17852
diff
changeset
|
1234 int rightLowerX = qMin(_usedColumns-1, qMax(0, qFloor((rect.right() - topLeftX - _leftMargin ) / _fontWidth))); |
c17a3e43956b
avoid partial lines at top of command window
John W. Eaton <jwe@octave.org>
parents:
17852
diff
changeset
|
1235 int rightLowerY = qMin(_usedLines-1, qMax(0, qFloor((rect.bottom() - topLeftY - _topMargin ) / _fontHeight))); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1236 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1237 const int bufferSize = _usedColumns; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1238 QChar *disstrU = new QChar[bufferSize]; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1239 for (int y = leftUpperY; y <= rightLowerY; y++) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1240 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1241 quint16 c = _image[loc(leftUpperX,y)].character; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1242 int x = leftUpperX; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1243 if(!c && x) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1244 x--; // Search for start of multi-column character |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1245 for (; x <= rightLowerX; x++) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1246 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1247 int len = 1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1248 int p = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1249 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1250 // is this a single character or a sequence of characters ? |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1251 if ( _image[loc(x,y)].rendition & RE_EXTENDED_CHAR ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1252 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1253 // sequence of characters |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1254 ushort extendedCharLength = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1255 ushort* chars = ExtendedCharTable::instance |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1256 .lookupExtendedChar(_image[loc(x,y)].charSequence,extendedCharLength); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1257 for ( int index = 0 ; index < extendedCharLength ; index++ ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1258 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1259 Q_ASSERT( p < bufferSize ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1260 disstrU[p++] = chars[index]; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1261 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1262 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1263 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1264 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1265 // single character |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1266 c = _image[loc(x,y)].character; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1267 if (c) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1268 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1269 Q_ASSERT( p < bufferSize ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1270 disstrU[p++] = c; //fontMap(c); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1271 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1272 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1273 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1274 bool lineDraw = isLineChar(c); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1275 bool doubleWidth = (_image[ qMin(loc(x,y)+1,_imageSize) ].character == 0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1276 CharacterColor currentForeground = _image[loc(x,y)].foregroundColor; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1277 CharacterColor currentBackground = _image[loc(x,y)].backgroundColor; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1278 quint8 currentRendition = _image[loc(x,y)].rendition; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1279 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1280 while (x+len <= rightLowerX && |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1281 _image[loc(x+len,y)].foregroundColor == currentForeground && |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1282 _image[loc(x+len,y)].backgroundColor == currentBackground && |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1283 _image[loc(x+len,y)].rendition == currentRendition && |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1284 (_image[ qMin(loc(x+len,y)+1,_imageSize) ].character == 0) == doubleWidth && |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1285 isLineChar( c = _image[loc(x+len,y)].character) == lineDraw) // Assignment! |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1286 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1287 if (c) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1288 disstrU[p++] = c; //fontMap(c); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1289 if (doubleWidth) // assert((_image[loc(x+len,y)+1].character == 0)), see above if condition |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1290 len++; // Skip trailing part of multi-column character |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1291 len++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1292 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1293 if ((x+len < _usedColumns) && (!_image[loc(x+len,y)].character)) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1294 len++; // Adjust for trailing part of multi-column character |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1295 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1296 bool save__fixedFont = _fixedFont; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1297 if (lineDraw) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1298 _fixedFont = false; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1299 if (doubleWidth) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1300 _fixedFont = false; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1301 QString unistr(disstrU,p); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1302 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1303 if (y < _lineProperties.size()) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1304 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1305 if (_lineProperties[y] & LINE_DOUBLEWIDTH) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1306 paint.scale(2,1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1307 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1308 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1309 if (_lineProperties[y] & LINE_DOUBLEHEIGHT) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1310 paint.scale(1,2); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1311 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1312 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1313 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1314 // calculate the area in which the text will be drawn |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1315 QRect textArea = QRect( _leftMargin+topLeftX+_fontWidth*x , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1316 _topMargin+topLeftY+_fontHeight*y , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1317 _fontWidth*len, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1318 _fontHeight); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1319 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1320 // move the calculated area to take account of scaling applied to the painter. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1321 // the position of the area from the origin (0,0) is scaled |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1322 // by the opposite of whatever |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1323 // transformation has been applied to the painter. this ensures that |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1324 // painting does actually start from textArea.topLeft() |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1325 // (instead of textArea.topLeft() * painter-scale) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1326 QMatrix inverted = paint.matrix().inverted(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1327 textArea.moveCenter( inverted.map(textArea.center()) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1328 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1329 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1330 //paint text fragment |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1331 drawTextFragment( paint, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1332 textArea, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1333 unistr, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1334 &_image[loc(x,y)] ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1335 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1336 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1337 _fixedFont = save__fixedFont; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1338 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1339 //reset back to single-width, single-height _lines |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1340 paint.resetMatrix(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1341 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1342 if (y < _lineProperties.size()-1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1343 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1344 //double-height _lines are represented by two adjacent _lines |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1345 //containing the same characters |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1346 //both _lines will have the LINE_DOUBLEHEIGHT attribute. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1347 //If the current line has the LINE_DOUBLEHEIGHT attribute, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1348 //we can therefore skip the next line |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1349 if (_lineProperties[y] & LINE_DOUBLEHEIGHT) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1350 y++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1351 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1352 x += len - 1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1353 } // for x |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1354 } // for y |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1355 delete [] disstrU; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1356 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1357 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1358 void TerminalView::blinkEvent() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1359 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1360 _blinking = !_blinking; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1361 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1362 //TODO: Optimise to only repaint the areas of the widget |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1363 // where there is blinking text |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1364 // rather than repainting the whole widget. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1365 update(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1366 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1367 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1368 QRect TerminalView::imageToWidget(const QRect& imageArea) const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1369 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1370 //qDebug("%s %d imageToWidget", __FILE__, __LINE__); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1371 QRect result; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1372 result.setLeft( _leftMargin + _fontWidth * imageArea.left() ); |
17872
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
1373 result.setTop( _topMargin + _fontHeight * imageArea.top() ); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1374 result.setWidth( _fontWidth * imageArea.width() ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1375 result.setHeight( _fontHeight * imageArea.height() ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1376 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1377 return result; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1378 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1379 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1380 void TerminalView::blinkCursorEvent() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1381 { |
16609
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1382 if (_hasBlinkingCursor) |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1383 _cursorBlinking = !_cursorBlinking; |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1384 else |
6f7940e36322
improve handling of cursor blinking for unix GUI terminal window
John W. Eaton <jwe@octave.org>
parents:
16606
diff
changeset
|
1385 _cursorBlinking = false; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1386 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1387 QRect cursorRect = imageToWidget( QRect(cursorPosition(),QSize(1,1)) ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1388 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1389 update(cursorRect); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1390 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1391 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1392 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1393 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1394 /* Resizing */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1395 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1396 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1397 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1398 void TerminalView::resizeEvent(QResizeEvent*) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1399 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1400 updateImageSize(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1401 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1402 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1403 void TerminalView::propagateSize() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1404 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1405 if (_isFixedSize) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1406 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1407 setSize(_columns, _lines); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1408 QWidget::setFixedSize(sizeHint()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1409 parentWidget()->adjustSize(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1410 parentWidget()->setFixedSize(parentWidget()->sizeHint()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1411 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1412 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1413 if (_image) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1414 updateImageSize(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1415 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1416 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1417 void TerminalView::updateImageSize() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1418 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1419 //qDebug("%s %d updateImageSize", __FILE__, __LINE__); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1420 Character* oldimg = _image; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1421 int oldlin = _lines; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1422 int oldcol = _columns; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1423 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1424 makeImage(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1425 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1426 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1427 // copy the old image to reduce flicker |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1428 int lines = qMin(oldlin,_lines); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1429 int columns = qMin(oldcol,_columns); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1430 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1431 //qDebug("%s %d updateImageSize", __FILE__, __LINE__); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1432 if (oldimg) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1433 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1434 for (int line = 0; line < lines; line++) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1435 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1436 memcpy((void*)&_image[_columns*line], |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1437 (void*)&oldimg[oldcol*line],columns*sizeof(Character)); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1438 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1439 delete[] oldimg; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1440 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1441 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1442 //qDebug("%s %d updateImageSize", __FILE__, __LINE__); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1443 if (_screenWindow) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1444 _screenWindow->setWindowLines(_lines); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1445 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1446 _resizing = (oldlin!=_lines) || (oldcol!=_columns); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1447 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1448 if ( _resizing ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1449 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1450 //qDebug("%s %d updateImageSize", __FILE__, __LINE__); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1451 showResizeNotification(); |
16538
8e180eac78d0
raise SIGWINCH signal in Unix GUI terminal window when size changes
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
1452 #if defined (SIGWINCH) |
8e180eac78d0
raise SIGWINCH signal in Unix GUI terminal window when size changes
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
1453 ::raise (SIGWINCH); |
8e180eac78d0
raise SIGWINCH signal in Unix GUI terminal window when size changes
John W. Eaton <jwe@octave.org>
parents:
15681
diff
changeset
|
1454 #endif |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1455 emit changedContentSizeSignal(_contentHeight, _contentWidth); // expose resizeEvent |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1456 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1457 //qDebug("%s %d updateImageSize", __FILE__, __LINE__); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1458 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1459 _resizing = false; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1460 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1461 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1462 //showEvent and hideEvent are reimplemented here so that it appears to other classes that the |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1463 //display has been resized when the display is hidden or shown. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1464 // |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1465 //this allows |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1466 //TODO: Perhaps it would be better to have separate signals for show and hide instead of using |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1467 //the same signal as the one for a content size change |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1468 void TerminalView::showEvent(QShowEvent*) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1469 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1470 emit changedContentSizeSignal(_contentHeight,_contentWidth); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1471 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1472 void TerminalView::hideEvent(QHideEvent*) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1473 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1474 emit changedContentSizeSignal(_contentHeight,_contentWidth); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1475 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1476 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1477 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1478 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1479 /* Scrollbar */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1480 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1481 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1482 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1483 void TerminalView::scrollBarPositionChanged(int) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1484 { |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1485 if ( !_screenWindow ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1486 return; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1487 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1488 _screenWindow->scrollTo( _scrollBar->value() ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1489 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1490 // if the thumb has been moved to the bottom of the _scrollBar then set |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1491 // the display to automatically track new output, |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1492 // that is, scroll down automatically |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1493 // to how new _lines as they are added |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1494 const bool atEndOfOutput = (_scrollBar->value() == _scrollBar->maximum()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1495 _screenWindow->setTrackOutput( atEndOfOutput ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1496 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1497 updateImage(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1498 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1499 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1500 void TerminalView::setScroll(int cursor, int slines) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1501 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1502 //qDebug("%s %d setScroll", __FILE__, __LINE__); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1503 // update _scrollBar if the range or value has changed, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1504 // otherwise return |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1505 // |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1506 // setting the range or value of a _scrollBar will always trigger |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1507 // a repaint, so it should be avoided if it is not necessary |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1508 if ( _scrollBar->minimum() == 0 && |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1509 _scrollBar->maximum() == (slines - _lines) && |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1510 _scrollBar->value() == cursor ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1511 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1512 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1513 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1514 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1515 disconnect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarPositionChanged(int))); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1516 _scrollBar->setRange(0,slines - _lines); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1517 _scrollBar->setSingleStep(1); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1518 _scrollBar->setPageStep(_lines); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1519 _scrollBar->setValue(cursor); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1520 connect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarPositionChanged(int))); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1521 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1522 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1523 void TerminalView::setScrollBarPosition(ScrollBarPosition position) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1524 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1525 if (_scrollbarLocation == position) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1526 // return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1527 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1528 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1529 if ( position == NoScrollBar ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1530 _scrollBar->hide(); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1531 else |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1532 _scrollBar->show(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1533 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1534 _topMargin = _leftMargin = 1; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1535 _scrollbarLocation = position; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1536 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1537 propagateSize(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1538 update(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1539 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1540 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1541 void TerminalView::mousePressEvent(QMouseEvent* ev) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1542 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1543 if ( _possibleTripleClick && (ev->button()==Qt::LeftButton) ) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1544 mouseTripleClickEvent(ev); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1545 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1546 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1547 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1548 if ( !contentsRect().contains(ev->pos()) ) return; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1549 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1550 if ( !_screenWindow ) return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1551 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1552 int charLine; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1553 int charColumn; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1554 getCharacterPosition(ev->pos(),charLine,charColumn); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1555 QPoint pos = QPoint(charColumn,charLine); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1556 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1557 if ( ev->button() == Qt::LeftButton) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1558 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1559 _lineSelectionMode = false; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1560 _wordSelectionMode = false; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1561 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1562 emit isBusySelecting(true); // Keep it steady... |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1563 // Drag only when the Control key is hold |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1564 bool selected = false; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1565 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1566 // The receiver of the testIsSelected() signal will adjust |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1567 // 'selected' accordingly. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1568 //emit testIsSelected(pos.x(), pos.y(), selected); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1569 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1570 selected = _screenWindow->isSelected(pos.x(),pos.y()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1571 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1572 if ((!_ctrlDrag || ev->modifiers() & Qt::ControlModifier) && selected ) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1573 // The user clicked inside selected text |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1574 dragInfo.state = diPending; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1575 dragInfo.start = ev->pos(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1576 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1577 else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1578 // No reason to ever start a drag event |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1579 dragInfo.state = diNone; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1580 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1581 _preserveLineBreaks = !( ( ev->modifiers() & Qt::ControlModifier ) && !(ev->modifiers() & Qt::AltModifier) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1582 _columnSelectionMode = (ev->modifiers() & Qt::AltModifier) && (ev->modifiers() & Qt::ControlModifier); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1583 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1584 if (_mouseMarks || (ev->modifiers() & Qt::ShiftModifier)) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1585 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1586 _screenWindow->clearSelection(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1587 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1588 //emit clearSelectionSignal(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1589 pos.ry() += _scrollBar->value(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1590 _iPntSel = _pntSel = pos; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1591 _actSel = 1; // left mouse button pressed but nothing selected yet. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1592 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1593 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1594 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1595 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1596 emit mouseSignal( 0, charColumn + 1, charLine + 1 +_scrollBar->value() -_scrollBar->maximum() , 0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1597 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1598 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1599 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1600 else if ( ev->button() == Qt::MidButton ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1601 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1602 if ( _mouseMarks || (!_mouseMarks && (ev->modifiers() & Qt::ShiftModifier)) ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1603 emitSelection(true,ev->modifiers() & Qt::ControlModifier); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1604 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1605 emit mouseSignal( 1, charColumn +1, charLine +1 +_scrollBar->value() -_scrollBar->maximum() , 0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1606 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1607 else if ( ev->button() == Qt::RightButton ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1608 { |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1609 if (_mouseMarks || (ev->modifiers() & Qt::ShiftModifier)) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1610 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1611 emit configureRequest( this, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1612 ev->modifiers() & (Qt::ShiftModifier|Qt::ControlModifier), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1613 ev->pos() |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1614 ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1615 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1616 else |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1617 emit mouseSignal( 2, charColumn +1, charLine +1 +_scrollBar->value() -_scrollBar->maximum() , 0); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1618 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1619 |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1620 QWidget::mousePressEvent (ev); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1621 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1622 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1623 QList<QAction*> TerminalView::filterActions(const QPoint& position) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1624 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1625 int charLine, charColumn; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1626 getCharacterPosition(position,charLine,charColumn); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1627 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1628 Filter::HotSpot* spot = _filterChain->hotSpotAt(charLine,charColumn); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1629 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1630 return spot ? spot->actions() : QList<QAction*>(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1631 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1632 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1633 void TerminalView::mouseMoveEvent(QMouseEvent* ev) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1634 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1635 int charLine = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1636 int charColumn = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1637 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1638 getCharacterPosition(ev->pos(),charLine,charColumn); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1639 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1640 // handle filters |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1641 // change link hot-spot appearance on mouse-over |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1642 Filter::HotSpot* spot = _filterChain->hotSpotAt(charLine,charColumn); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1643 if ( spot && spot->type() == Filter::HotSpot::Link) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1644 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1645 QRect previousHotspotArea = _mouseOverHotspotArea; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1646 _mouseOverHotspotArea.setCoords( qMin(spot->startColumn() , spot->endColumn()) * _fontWidth, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1647 spot->startLine() * _fontHeight, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1648 qMax(spot->startColumn() , spot->endColumn()) * _fontHeight, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1649 (spot->endLine()+1) * _fontHeight ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1650 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1651 // display tooltips when mousing over links |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1652 // TODO: Extend this to work with filter types other than links |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1653 const QString& tooltip = spot->tooltip(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1654 if ( !tooltip.isEmpty() ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1655 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1656 QToolTip::showText( mapToGlobal(ev->pos()) , tooltip , this , _mouseOverHotspotArea ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1657 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1658 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1659 update( _mouseOverHotspotArea | previousHotspotArea ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1660 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1661 else if ( _mouseOverHotspotArea.isValid() ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1662 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1663 update( _mouseOverHotspotArea ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1664 // set hotspot area to an invalid rectangle |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1665 _mouseOverHotspotArea = QRect(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1666 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1667 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1668 // for auto-hiding the cursor, we need mouseTracking |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1669 if (ev->buttons() == Qt::NoButton ) return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1670 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1671 // if the terminal is interested in mouse movements |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1672 // then emit a mouse movement signal, unless the shift |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1673 // key is being held down, which overrides this. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1674 if (!_mouseMarks && !(ev->modifiers() & Qt::ShiftModifier)) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1675 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1676 int button = 3; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1677 if (ev->buttons() & Qt::LeftButton) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1678 button = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1679 if (ev->buttons() & Qt::MidButton) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1680 button = 1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1681 if (ev->buttons() & Qt::RightButton) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1682 button = 2; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1683 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1684 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1685 emit mouseSignal( button, |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1686 charColumn + 1, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1687 charLine + 1 +_scrollBar->value() -_scrollBar->maximum(), |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1688 1 ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1689 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1690 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1691 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1692 |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1693 if (dragInfo.state == diPending) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1694 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1695 // we had a mouse down, but haven't confirmed a drag yet |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1696 // if the mouse has moved sufficiently, we will confirm |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1697 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1698 int distance = 10; //KGlobalSettings::dndEventDelay(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1699 if ( ev->x() > dragInfo.start.x() + distance || ev->x() < dragInfo.start.x() - distance || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1700 ev->y() > dragInfo.start.y() + distance || ev->y() < dragInfo.start.y() - distance) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1701 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1702 // we've left the drag square, we can start a real drag operation now |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1703 emit isBusySelecting(false); // Ok.. we can breath again. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1704 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1705 _screenWindow->clearSelection(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1706 doDrag(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1707 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1708 return; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1709 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1710 else if (dragInfo.state == diDragging) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1711 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1712 // this isn't technically needed because mouseMoveEvent is suppressed during |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1713 // Qt drag operations, replaced by dragMoveEvent |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1714 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1715 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1716 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1717 if (_actSel == 0) return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1718 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1719 // don't extend selection while pasting |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1720 if (ev->buttons() & Qt::MidButton) return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1721 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1722 extendSelection( ev->pos() ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1723 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1724 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1725 #if 0 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1726 void TerminalDisplay::setSelectionEnd() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1727 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1728 extendSelection( _configureRequestPoint ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1729 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1730 #endif |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1731 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1732 void TerminalView::extendSelection(const QPoint& position) { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1733 QPoint pos = position; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1734 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1735 if (!_screenWindow) { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1736 return; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1737 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1738 |
17872
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
1739 QPoint tL = contentsRect().topLeft(); |
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
1740 int tLx = tL.x(); |
7d9a4eef8022
backout changeset 4de2eeb7d790
John W. Eaton <jwe@octave.org>
parents:
17857
diff
changeset
|
1741 int tLy = tL.y(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1742 int scroll = _scrollBar->value(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1743 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1744 // we're in the process of moving the mouse with the left button pressed |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1745 // the mouse cursor will kept caught within the bounds of the text in |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1746 // this widget. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1747 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1748 // Adjust position within text area bounds. See FIXME above. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1749 if (pos.x() < tLx + _leftMargin) { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1750 pos.setX(tLx + _leftMargin); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1751 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1752 if (pos.x() > tLx + _leftMargin + _usedColumns * _fontWidth - 1) { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1753 pos.setX(tLx + _leftMargin + _usedColumns * _fontWidth); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1754 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1755 if (pos.y() < tLy + _topMargin) { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1756 pos.setY(tLy + _topMargin); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1757 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1758 if (pos.y() > tLy + _topMargin + _usedLines * _fontHeight - 1) { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1759 pos.setY(tLy + _topMargin + _usedLines * _fontHeight - 1); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1760 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1761 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1762 if (pos.y() == tLy + _topMargin + _usedLines * _fontHeight - 1) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1763 _scrollBar->setValue(_scrollBar->value() + yMouseScroll); // scrollforward |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1764 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1765 if (pos.y() == tLy + _topMargin) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1766 _scrollBar->setValue(_scrollBar->value() - yMouseScroll); // scrollback |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1767 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1768 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1769 int charColumn = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1770 int charLine = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1771 getCharacterPosition(pos, charLine, charColumn); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1772 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1773 QPoint here = QPoint(charColumn, charLine); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1774 QPoint ohere(here); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1775 QPoint _iPntSelCorr = _iPntSel; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1776 _iPntSelCorr.ry() -= _scrollBar->value(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1777 QPoint _pntSelCorr = _pntSel; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1778 _pntSelCorr.ry() -= _scrollBar->value(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1779 bool swapping = false; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1780 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1781 if (_wordSelectionMode) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1782 // Extend to word boundaries |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1783 int i = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1784 int selClass = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1785 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1786 bool left_not_right = (here.y() < _iPntSelCorr.y() || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1787 (here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x())); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1788 bool old_left_not_right = (_pntSelCorr.y() < _iPntSelCorr.y() || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1789 (_pntSelCorr.y() == _iPntSelCorr.y() && _pntSelCorr.x() < _iPntSelCorr.x())); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1790 swapping = left_not_right != old_left_not_right; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1791 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1792 // Find left (left_not_right ? from here : from start) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1793 QPoint left = left_not_right ? here : _iPntSelCorr; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1794 i = loc(left.x(), left.y()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1795 if (i >= 0 && i <= _imageSize) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1796 selClass = charClass(_image[i].character); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1797 while (((left.x() > 0) || (left.y() > 0 && (_lineProperties[left.y() - 1] & LINE_WRAPPED))) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1798 && charClass(_image[i - 1].character) == selClass) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1799 i--; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1800 if (left.x() > 0) { |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1801 left.rx()--; |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1802 } else { |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1803 left.rx() = _usedColumns - 1; |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1804 left.ry()--; |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1805 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1806 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1807 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1808 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1809 // Find left (left_not_right ? from start : from here) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1810 QPoint right = left_not_right ? _iPntSelCorr : here; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1811 i = loc(right.x(), right.y()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1812 if (i >= 0 && i <= _imageSize) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1813 selClass = charClass(_image[i].character); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1814 while (((right.x() < _usedColumns - 1) || (right.y() < _usedLines - 1 && (_lineProperties[right.y()] & LINE_WRAPPED))) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1815 && charClass(_image[i + 1].character) == selClass) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1816 i++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1817 if (right.x() < _usedColumns - 1) { |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1818 right.rx()++; |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1819 } else { |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1820 right.rx() = 0; |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1821 right.ry()++; |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1822 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1823 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1824 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1825 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1826 // Pick which is start (ohere) and which is extension (here) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1827 if (left_not_right) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1828 here = left; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1829 ohere = right; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1830 } else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1831 here = right; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1832 ohere = left; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1833 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1834 ohere.rx()++; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1835 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1836 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1837 if (_lineSelectionMode) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1838 // Extend to complete line |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1839 bool above_not_below = (here.y() < _iPntSelCorr.y()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1840 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1841 QPoint above = above_not_below ? here : _iPntSelCorr; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1842 QPoint below = above_not_below ? _iPntSelCorr : here; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1843 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1844 while (above.y() > 0 && (_lineProperties[above.y() - 1] & LINE_WRAPPED)) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1845 above.ry()--; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1846 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1847 while (below.y() < _usedLines - 1 && (_lineProperties[below.y()] & LINE_WRAPPED)) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1848 below.ry()++; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1849 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1850 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1851 above.setX(0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1852 below.setX(_usedColumns - 1); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1853 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1854 // Pick which is start (ohere) and which is extension (here) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1855 if (above_not_below) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1856 here = above; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1857 ohere = below; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1858 } else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1859 here = below; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1860 ohere = above; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1861 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1862 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1863 QPoint newSelBegin = QPoint(ohere.x(), ohere.y()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1864 swapping = !(_tripleSelBegin == newSelBegin); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1865 _tripleSelBegin = newSelBegin; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1866 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1867 ohere.rx()++; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1868 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1869 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1870 int offset = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1871 if (!_wordSelectionMode && !_lineSelectionMode) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1872 int i = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1873 int selClass = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1874 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1875 bool left_not_right = (here.y() < _iPntSelCorr.y() || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1876 (here.y() == _iPntSelCorr.y() && here.x() < _iPntSelCorr.x())); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1877 bool old_left_not_right = (_pntSelCorr.y() < _iPntSelCorr.y() || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1878 (_pntSelCorr.y() == _iPntSelCorr.y() && _pntSelCorr.x() < _iPntSelCorr.x())); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1879 swapping = left_not_right != old_left_not_right; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1880 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1881 // Find left (left_not_right ? from here : from start) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1882 QPoint left = left_not_right ? here : _iPntSelCorr; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1883 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1884 // Find left (left_not_right ? from start : from here) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1885 QPoint right = left_not_right ? _iPntSelCorr : here; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1886 if (right.x() > 0 && !_columnSelectionMode) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1887 i = loc(right.x(), right.y()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1888 if (i >= 0 && i <= _imageSize) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1889 selClass = charClass(_image[i - 1].character); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1890 if (selClass == ' ') { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1891 while (right.x() < _usedColumns - 1 && charClass(_image[i + 1].character) == selClass && (right.y() < _usedLines - 1) && |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1892 !(_lineProperties[right.y()] & LINE_WRAPPED)) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1893 i++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1894 right.rx()++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1895 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1896 if (right.x() < _usedColumns - 1) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1897 right = left_not_right ? _iPntSelCorr : here; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1898 } else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1899 right.rx()++; // will be balanced later because of offset=-1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1900 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1901 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1902 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1903 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1904 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1905 // Pick which is start (ohere) and which is extension (here) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1906 if (left_not_right) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1907 here = left; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1908 ohere = right; |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1909 offset = 0; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1910 } else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1911 here = right; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1912 ohere = left; |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1913 offset = -1; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1914 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1915 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1916 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1917 if ((here == _pntSelCorr) && (scroll == _scrollBar->value())) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1918 return; // not moved |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1919 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1920 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1921 if (here == ohere) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1922 return; // It's not left, it's not right. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1923 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1924 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1925 if (_actSel < 2 || swapping) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1926 if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1927 _screenWindow->setSelectionStart(ohere.x(), ohere.y(), true); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1928 } else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1929 _screenWindow->setSelectionStart(ohere.x() - 1 - offset , ohere.y(), false); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1930 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1931 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1932 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1933 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1934 _actSel = 2; // within selection |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1935 _pntSel = here; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1936 _pntSel.ry() += _scrollBar->value(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1937 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1938 if (_columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1939 _screenWindow->setSelectionEnd(here.x(), here.y()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1940 } else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1941 _screenWindow->setSelectionEnd(here.x() + offset, here.y()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1942 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1943 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1944 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1945 void TerminalView::mouseReleaseEvent(QMouseEvent* ev) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1946 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1947 if ( !_screenWindow ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1948 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1949 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1950 int charLine; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1951 int charColumn; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1952 getCharacterPosition(ev->pos(),charLine,charColumn); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1953 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1954 if ( ev->button() == Qt::LeftButton) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1955 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1956 emit isBusySelecting(false); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1957 if(dragInfo.state == diPending) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1958 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1959 // We had a drag event pending but never confirmed. Kill selection |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1960 _screenWindow->clearSelection(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1961 //emit clearSelectionSignal(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1962 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1963 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1964 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1965 if ( _actSel > 1 ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1966 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1967 setSelection( _screenWindow->selectedText(_preserveLineBreaks) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1968 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1969 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1970 _actSel = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1971 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1972 //FIXME: emits a release event even if the mouse is |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1973 // outside the range. The procedure used in `mouseMoveEvent' |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1974 // applies here, too. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1975 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1976 if (!_mouseMarks && !(ev->modifiers() & Qt::ShiftModifier)) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1977 emit mouseSignal( 3, // release |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1978 charColumn + 1, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1979 charLine + 1 +_scrollBar->value() -_scrollBar->maximum() , 0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1980 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1981 dragInfo.state = diNone; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1982 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1983 |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1984 |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1985 if ( !_mouseMarks && |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1986 ((ev->button() == Qt::RightButton && !(ev->modifiers() & Qt::ShiftModifier)) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1987 || ev->button() == Qt::MidButton) ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1988 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1989 emit mouseSignal( 3, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1990 charColumn + 1, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1991 charLine + 1 +_scrollBar->value() -_scrollBar->maximum() , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1992 0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
1993 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1994 |
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
1995 QWidget::mouseReleaseEvent(ev); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1996 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1997 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1998 void TerminalView::getCharacterPosition(const QPoint& widgetPoint,int& line,int& column) const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
1999 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2000 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2001 column = (widgetPoint.x() + _fontWidth/2 -contentsRect().left()-_leftMargin) / _fontWidth; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2002 line = (widgetPoint.y()-contentsRect().top()-_topMargin) / _fontHeight; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2003 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2004 if ( line < 0 ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2005 line = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2006 if ( column < 0 ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2007 column = 0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2008 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2009 if ( line >= _usedLines ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2010 line = _usedLines-1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2011 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2012 // the column value returned can be equal to _usedColumns, which |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2013 // is the position just after the last character displayed in a line. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2014 // |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2015 // this is required so that the user can select characters in the right-most |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2016 // column (or left-most for right-to-left input) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2017 if ( column > _usedColumns ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2018 column = _usedColumns; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2019 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2020 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2021 void TerminalView::updateLineProperties() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2022 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2023 if ( !_screenWindow ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2024 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2025 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2026 _lineProperties = _screenWindow->getLineProperties(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2027 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2028 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2029 void TerminalView::mouseDoubleClickEvent(QMouseEvent* ev) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2030 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2031 if ( ev->button() != Qt::LeftButton) return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2032 if ( !_screenWindow ) return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2033 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2034 int charLine = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2035 int charColumn = 0; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2036 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2037 getCharacterPosition(ev->pos(),charLine,charColumn); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2038 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2039 QPoint pos(charColumn,charLine); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2040 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2041 // pass on double click as two clicks. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2042 if (!_mouseMarks && !(ev->modifiers() & Qt::ShiftModifier)) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2043 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2044 // Send just _ONE_ click event, since the first click of the double click |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2045 // was already sent by the click handler |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2046 emit mouseSignal( 0, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2047 pos.x()+1, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2048 pos.y()+1 +_scrollBar->value() -_scrollBar->maximum(), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2049 0 ); // left button |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2050 return; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2051 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2052 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2053 _screenWindow->clearSelection(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2054 QPoint bgnSel = pos; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2055 QPoint endSel = pos; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2056 int i = loc(bgnSel.x(),bgnSel.y()); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2057 _iPntSel = bgnSel; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2058 _iPntSel.ry() += _scrollBar->value(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2059 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2060 _wordSelectionMode = true; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2061 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2062 // find word boundaries... |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2063 int selClass = charClass(_image[i].character); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2064 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2065 // find the start of the word |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2066 int x = bgnSel.x(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2067 while ( ((x>0) || (bgnSel.y()>0 && (_lineProperties[bgnSel.y()-1] & LINE_WRAPPED) )) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2068 && charClass(_image[i-1].character) == selClass ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2069 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2070 i--; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2071 if (x>0) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2072 x--; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2073 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2074 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2075 x=_usedColumns-1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2076 bgnSel.ry()--; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2077 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2078 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2079 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2080 bgnSel.setX(x); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2081 _screenWindow->setSelectionStart( bgnSel.x() , bgnSel.y() , false ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2082 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2083 // find the end of the word |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2084 i = loc( endSel.x(), endSel.y() ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2085 x = endSel.x(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2086 while( ((x<_usedColumns-1) || (endSel.y()<_usedLines-1 && (_lineProperties[endSel.y()] & LINE_WRAPPED) )) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2087 && charClass(_image[i+1].character) == selClass ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2088 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2089 i++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2090 if (x<_usedColumns-1) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2091 x++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2092 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2093 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2094 x=0; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2095 endSel.ry()++; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2096 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2097 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2098 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2099 endSel.setX(x); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2100 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2101 // In word selection mode don't select @ (64) if at end of word. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2102 if ( ( QChar( _image[i].character ) == '@' ) && ( ( endSel.x() - bgnSel.x() ) > 0 ) ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2103 endSel.setX( x - 1 ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2104 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2105 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2106 _actSel = 2; // within selection |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2107 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2108 _screenWindow->setSelectionEnd( endSel.x() , endSel.y() ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2109 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2110 setSelection( _screenWindow->selectedText(_preserveLineBreaks) ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2111 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2112 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2113 _possibleTripleClick=true; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2114 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2115 QTimer::singleShot(QApplication::doubleClickInterval(),this, |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2116 SLOT(tripleClickTimeout())); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2117 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2118 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2119 void TerminalView::wheelEvent( QWheelEvent* ev ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2120 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2121 if (ev->orientation() != Qt::Vertical) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2122 return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2123 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2124 if ( _mouseMarks ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2125 _scrollBar->event(ev); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2126 else |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2127 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2128 int charLine; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2129 int charColumn; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2130 getCharacterPosition( ev->pos() , charLine , charColumn ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2131 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2132 emit mouseSignal( ev->delta() > 0 ? 4 : 5, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2133 charColumn + 1, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2134 charLine + 1 +_scrollBar->value() -_scrollBar->maximum() , |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2135 0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2136 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2137 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2138 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2139 void TerminalView::tripleClickTimeout() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2140 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2141 _possibleTripleClick=false; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2142 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2143 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2144 void TerminalView::mouseTripleClickEvent(QMouseEvent* ev) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2145 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2146 if ( !_screenWindow ) return; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2147 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2148 int charLine; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2149 int charColumn; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2150 getCharacterPosition(ev->pos(),charLine,charColumn); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2151 _iPntSel = QPoint(charColumn,charLine); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2152 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2153 _screenWindow->clearSelection(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2154 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2155 _lineSelectionMode = true; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2156 _wordSelectionMode = false; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2157 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2158 _actSel = 2; // within selection |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2159 emit isBusySelecting(true); // Keep it steady... |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2160 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2161 while (_iPntSel.y()>0 && (_lineProperties[_iPntSel.y()-1] & LINE_WRAPPED) ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2162 _iPntSel.ry()--; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2163 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2164 if (_tripleClickMode == SelectForwardsFromCursor) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2165 // find word boundary start |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2166 int i = loc(_iPntSel.x(),_iPntSel.y()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2167 int selClass = charClass(_image[i].character); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2168 int x = _iPntSel.x(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2169 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2170 while ( ((x>0) || |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2171 (_iPntSel.y()>0 && (_lineProperties[_iPntSel.y()-1] & LINE_WRAPPED) ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2172 ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2173 && charClass(_image[i-1].character) == selClass ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2174 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2175 i--; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2176 if (x>0) |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2177 x--; |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2178 else |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2179 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2180 x=_columns-1; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2181 _iPntSel.ry()--; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2182 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2183 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2184 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2185 _screenWindow->setSelectionStart( x , _iPntSel.y() , false ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2186 _tripleSelBegin = QPoint( x, _iPntSel.y() ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2187 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2188 else if (_tripleClickMode == SelectWholeLine) { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2189 _screenWindow->setSelectionStart( 0 , _iPntSel.y() , false ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2190 _tripleSelBegin = QPoint( 0, _iPntSel.y() ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2191 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2192 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2193 while (_iPntSel.y()<_lines-1 && (_lineProperties[_iPntSel.y()] & LINE_WRAPPED) ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2194 _iPntSel.ry()++; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2195 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2196 _screenWindow->setSelectionEnd( _columns - 1 , _iPntSel.y() ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2197 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2198 setSelection(_screenWindow->selectedText(_preserveLineBreaks)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2199 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2200 _iPntSel.ry() += _scrollBar->value(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2201 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2202 emit tripleClicked( _screenWindow->selectedText( _preserveLineBreaks ) ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2203 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2204 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2205 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2206 bool TerminalView::focusNextPrevChild( bool next ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2207 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2208 if (next) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2209 return false; // This disables changing the active part in konqueror |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2210 // when pressing Tab |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2211 return QWidget::focusNextPrevChild( next ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2212 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2213 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2214 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2215 int TerminalView::charClass(quint16 ch) const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2216 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2217 QChar qch=QChar(ch); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2218 if ( qch.isSpace() ) return ' '; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2219 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2220 if ( qch.isLetterOrNumber() || _wordCharacters.contains(qch, Qt::CaseInsensitive ) ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2221 return 'a'; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2222 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2223 // Everything else is weird |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2224 return 1; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2225 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2226 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2227 void TerminalView::setWordCharacters(const QString& wc) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2228 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2229 _wordCharacters = wc; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2230 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2231 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2232 void TerminalView::setUsesMouse(bool on) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2233 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2234 _mouseMarks = on; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2235 setCursor( _mouseMarks ? Qt::IBeamCursor : Qt::ArrowCursor ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2236 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2237 bool TerminalView::usesMouse() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2238 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2239 return _mouseMarks; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2240 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2241 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2242 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2243 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2244 /* Clipboard */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2245 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2246 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2247 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2248 #undef KeyPress |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2249 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2250 void TerminalView::emitSelection(bool useXselection,bool appendReturn) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2251 { |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2252 if ( !_screenWindow ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2253 return; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2254 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2255 // Paste Clipboard by simulating keypress events |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2256 QString text = QApplication::clipboard()->text(useXselection ? QClipboard::Selection : |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2257 QClipboard::Clipboard); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2258 if(appendReturn) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2259 text.append("\r"); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2260 if ( ! text.isEmpty() ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2261 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2262 text.replace("\n", "\r"); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2263 QKeyEvent e(QEvent::KeyPress, 0, Qt::NoModifier, text); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2264 emit keyPressedSignal(&e); // expose as a big fat keypress event |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2265 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2266 _screenWindow->clearSelection(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2267 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2268 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2269 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2270 void TerminalView::setSelection(const QString& t) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2271 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2272 QApplication::clipboard()->setText(t, QClipboard::Selection); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2273 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2274 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2275 void TerminalView::copyClipboard() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2276 { |
16881
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16794
diff
changeset
|
2277 if ( !_screenWindow || !hasFocus()) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2278 return; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2279 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2280 QString text = _screenWindow->selectedText(_preserveLineBreaks); |
16648
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
2281 |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
2282 if (text.isEmpty ()) |
17920
5c3f22dd0bbb
raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents:
17872
diff
changeset
|
2283 emit interrupt_signal (); |
16648
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
2284 else |
b04413e5a811
improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents:
16609
diff
changeset
|
2285 QApplication::clipboard()->setText(text); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2286 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2287 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2288 void TerminalView::pasteClipboard() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2289 { |
16881
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16794
diff
changeset
|
2290 if(hasFocus ()) |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16794
diff
changeset
|
2291 { |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16794
diff
changeset
|
2292 emitSelection(false,false); |
944ade6e7f66
Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents:
16794
diff
changeset
|
2293 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2294 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2295 |
18555
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2296 void TerminalView::selectAll() |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2297 { |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2298 if ( !_screenWindow || !hasFocus()) |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2299 return; |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2300 |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2301 _screenWindow->setSelectionStart(0,-_screenWindow->currentLine(), false); |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2302 //_screenWindow->setSelectionEnd(_screenWindow->windowColumns(), |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2303 // _screenWindow->windowLines()); |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2304 |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2305 _screenWindow->setSelectionEnd(_screenWindow->columnCount(), |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2306 _screenWindow->windowLines()); |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2307 } |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2308 |
2d5d0d86432e
gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents:
17920
diff
changeset
|
2309 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2310 void TerminalView::pasteSelection() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2311 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2312 emitSelection(true,false); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2313 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2314 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2315 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2316 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2317 /* Keyboard */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2318 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2319 /* ------------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2320 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2321 void TerminalView::keyPressEvent( QKeyEvent* event ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2322 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2323 //qDebug("%s %d keyPressEvent and key is %d", __FILE__, __LINE__, event->key()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2324 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2325 bool emitKeyPressSignal = true; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2326 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2327 // Keyboard-based navigation |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2328 if ( event->modifiers() == Qt::ShiftModifier ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2329 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2330 bool update = true; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2331 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2332 if ( event->key() == Qt::Key_PageUp ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2333 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2334 //qDebug("%s %d pageup", __FILE__, __LINE__); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2335 _screenWindow->scrollBy( ScreenWindow::ScrollPages , -1 ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2336 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2337 else if ( event->key() == Qt::Key_PageDown ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2338 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2339 //qDebug("%s %d pagedown", __FILE__, __LINE__); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2340 _screenWindow->scrollBy( ScreenWindow::ScrollPages , 1 ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2341 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2342 else if ( event->key() == Qt::Key_Up ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2343 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2344 //qDebug("%s %d keyup", __FILE__, __LINE__); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2345 _screenWindow->scrollBy( ScreenWindow::ScrollLines , -1 ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2346 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2347 else if ( event->key() == Qt::Key_Down ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2348 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2349 //qDebug("%s %d keydown", __FILE__, __LINE__); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2350 _screenWindow->scrollBy( ScreenWindow::ScrollLines , 1 ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2351 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2352 else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2353 update = false; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2354 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2355 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2356 if ( update ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2357 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2358 //qDebug("%s %d updating", __FILE__, __LINE__); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2359 _screenWindow->setTrackOutput( _screenWindow->atEndOfOutput() ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2360 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2361 updateLineProperties(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2362 updateImage(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2363 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2364 // do not send key press to terminal |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2365 emitKeyPressSignal = false; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2366 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2367 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2368 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2369 _screenWindow->setTrackOutput( true ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2370 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2371 _actSel=0; // Key stroke implies a screen update, so TerminalDisplay won't |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2372 // know where the current selection is. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2373 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2374 if (_hasBlinkingCursor) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2375 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2376 _blinkCursorTimer->start(BLINK_DELAY); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2377 if (_cursorBlinking) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2378 blinkCursorEvent(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2379 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2380 _cursorBlinking = false; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2381 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2382 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2383 if ( emitKeyPressSignal && !_readonly ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2384 emit keyPressedSignal(event); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2385 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2386 if (_readonly) { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2387 event->ignore(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2388 } |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2389 else { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2390 event->accept(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2391 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2392 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2393 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2394 void TerminalView::inputMethodEvent( QInputMethodEvent* event ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2395 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2396 QKeyEvent keyEvent(QEvent::KeyPress,0,Qt::NoModifier,event->commitString()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2397 emit keyPressedSignal(&keyEvent); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2398 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2399 _inputMethodData.preeditString = event->preeditString(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2400 update(preeditRect() | _inputMethodData.previousPreeditRect); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2401 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2402 event->accept(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2403 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2404 QVariant TerminalView::inputMethodQuery( Qt::InputMethodQuery query ) const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2405 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2406 const QPoint cursorPos = _screenWindow ? _screenWindow->cursorPosition() : QPoint(0,0); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2407 switch ( query ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2408 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2409 case Qt::ImMicroFocus: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2410 return imageToWidget(QRect(cursorPos.x(),cursorPos.y(),1,1)); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2411 break; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2412 case Qt::ImFont: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2413 return font(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2414 break; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2415 case Qt::ImCursorPosition: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2416 // return the cursor position within the current line |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2417 return cursorPos.x(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2418 break; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2419 case Qt::ImSurroundingText: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2420 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2421 // return the text from the current line |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2422 QString lineText; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2423 QTextStream stream(&lineText); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2424 PlainTextDecoder decoder; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2425 decoder.begin(&stream); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2426 decoder.decodeLine(&_image[loc(0,cursorPos.y())],_usedColumns,_lineProperties[cursorPos.y()]); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2427 decoder.end(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2428 return lineText; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2429 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2430 break; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2431 case Qt::ImCurrentSelection: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2432 return QString(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2433 break; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2434 default: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2435 break; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2436 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2437 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2438 return QVariant(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2439 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2440 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2441 bool TerminalView::event( QEvent *e ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2442 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2443 if ( e->type() == QEvent::ShortcutOverride ) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2444 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2445 QKeyEvent* keyEvent = static_cast<QKeyEvent *>( e ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2446 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2447 // a check to see if keyEvent->text() is empty is used |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2448 // to avoid intercepting the press of the modifier key on its own. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2449 // |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2450 // this is important as it allows a press and release of the Alt key |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2451 // on its own to focus the menu bar, making it possible to |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2452 // work with the menu without using the mouse |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2453 if ( (keyEvent->modifiers() == Qt::AltModifier) && |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2454 !keyEvent->text().isEmpty() ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2455 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2456 keyEvent->accept(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2457 return true; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2458 } |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2459 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2460 // Override any of the following shortcuts because |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2461 // they are needed by the terminal |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2462 int keyCode = keyEvent->key() | keyEvent->modifiers(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2463 switch ( keyCode ) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2464 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2465 // list is taken from the QLineEdit::event() code |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2466 case Qt::Key_Tab: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2467 case Qt::Key_Delete: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2468 case Qt::Key_Home: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2469 case Qt::Key_End: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2470 case Qt::Key_Backspace: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2471 case Qt::Key_Left: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2472 case Qt::Key_Right: |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2473 keyEvent->accept(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2474 return true; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2475 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2476 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2477 return QWidget::event( e ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2478 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2479 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2480 void TerminalView::setBellMode(int mode) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2481 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2482 _bellMode=mode; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2483 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2484 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2485 void TerminalView::enableBell() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2486 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2487 _allowBell = true; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2488 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2489 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2490 void TerminalView::swapColorTable() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2491 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2492 ColorEntry color = _colorTable[1]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2493 _colorTable[1]=_colorTable[0]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2494 _colorTable[0]= color; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2495 _colorsInverted = !_colorsInverted; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2496 update(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2497 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2498 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2499 void TerminalView::clearImage() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2500 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2501 // We initialize _image[_imageSize] too. See makeImage() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2502 for (int i = 0; i <= _imageSize; i++) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2503 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2504 _image[i].character = ' '; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2505 _image[i].foregroundColor = CharacterColor(COLOR_SPACE_DEFAULT, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2506 DEFAULT_FORE_COLOR); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2507 _image[i].backgroundColor = CharacterColor(COLOR_SPACE_DEFAULT, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2508 DEFAULT_BACK_COLOR); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2509 _image[i].rendition = DEFAULT_RENDITION; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2510 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2511 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2512 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2513 void TerminalView::calcGeometry() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2514 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2515 _scrollBar->resize(QApplication::style()->pixelMetric(QStyle::PM_ScrollBarExtent), |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2516 contentsRect().height()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2517 switch(_scrollbarLocation) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2518 { |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2519 case NoScrollBar : |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2520 _leftMargin = DEFAULT_LEFT_MARGIN; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2521 _contentWidth = contentsRect().width() - 2 * DEFAULT_LEFT_MARGIN; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2522 break; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2523 case ScrollBarLeft : |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2524 _leftMargin = DEFAULT_LEFT_MARGIN + _scrollBar->width(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2525 _contentWidth = contentsRect().width() - 2 * DEFAULT_LEFT_MARGIN - _scrollBar->width(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2526 _scrollBar->move(contentsRect().topLeft()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2527 break; |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2528 case ScrollBarRight: |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2529 _leftMargin = DEFAULT_LEFT_MARGIN; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2530 _contentWidth = contentsRect().width() - 2 * DEFAULT_LEFT_MARGIN - _scrollBar->width(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2531 _scrollBar->move(contentsRect().topRight() - QPoint(_scrollBar->width()-1,0)); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2532 break; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2533 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2534 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2535 _topMargin = DEFAULT_TOP_MARGIN; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2536 _contentHeight = contentsRect().height() - 2 * DEFAULT_TOP_MARGIN + /* mysterious */ 1; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2537 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2538 if (!_isFixedSize) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2539 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2540 // ensure that display is always at least one column wide |
17857
c17a3e43956b
avoid partial lines at top of command window
John W. Eaton <jwe@octave.org>
parents:
17852
diff
changeset
|
2541 _columns = qMax(1,qFloor(_contentWidth / _fontWidth)); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2542 _usedColumns = qMin(_usedColumns,_columns); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2543 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2544 // ensure that display is always at least one line high |
17857
c17a3e43956b
avoid partial lines at top of command window
John W. Eaton <jwe@octave.org>
parents:
17852
diff
changeset
|
2545 _lines = qMax(1, qFloor(_contentHeight / _fontHeight)); |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2546 _usedLines = qMin(_usedLines,_lines); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2547 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2548 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2549 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2550 void TerminalView::makeImage() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2551 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2552 //qDebug("%s %d makeImage", __FILE__, __LINE__); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2553 calcGeometry(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2554 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2555 // confirm that array will be of non-zero size, since the painting code |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2556 // assumes a non-zero array length |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2557 Q_ASSERT( _lines > 0 && _columns > 0 ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2558 Q_ASSERT( _usedLines <= _lines && _usedColumns <= _columns ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2559 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2560 _imageSize=_lines*_columns; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2561 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2562 // We over-commit one character so that we can be more relaxed in dealing with |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2563 // certain boundary conditions: _image[_imageSize] is a valid but unused position |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2564 _image = new Character[_imageSize+1]; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2565 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2566 clearImage(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2567 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2568 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2569 // calculate the needed size |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2570 void TerminalView::setSize(int columns, int lines) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2571 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2572 //FIXME - Not quite correct, a small amount of additional space |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2573 // will be used for margins, the scrollbar etc. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2574 // we need to allow for this so that '_size' does allow |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2575 // enough room for the specified number of columns and lines to fit |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2576 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2577 QSize newSize = QSize( columns * _fontWidth , |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2578 lines * _fontHeight ); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2579 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2580 if ( newSize != size() ) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2581 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2582 _size = newSize; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2583 updateGeometry(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2584 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2585 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2586 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2587 void TerminalView::setFixedSize(int cols, int lins) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2588 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2589 _isFixedSize = true; |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2590 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2591 //ensure that display is at least one line by one column in size |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2592 _columns = qMax(1,cols); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2593 _lines = qMax(1,lins); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2594 _usedColumns = qMin(_usedColumns,_columns); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2595 _usedLines = qMin(_usedLines,_lines); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2596 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2597 if (_image) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2598 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2599 delete[] _image; |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2600 makeImage(); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2601 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2602 setSize(cols, lins); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2603 QWidget::setFixedSize(_size); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2604 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2605 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2606 QSize TerminalView::sizeHint() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2607 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2608 return _size; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2609 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2610 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2611 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2612 /* --------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2613 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2614 /* Drag & Drop */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2615 /* */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2616 /* --------------------------------------------------------------------- */ |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2617 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2618 void TerminalView::dragEnterEvent(QDragEnterEvent* event) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2619 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2620 if (event->mimeData()->hasFormat("text/plain")) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2621 event->acceptProposedAction(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2622 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2623 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2624 void TerminalView::dropEvent(QDropEvent* event) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2625 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2626 // KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2627 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2628 QString dropText; |
18651
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2629 |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2630 if (event->mimeData ()->hasUrls ()) |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2631 { |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2632 foreach (QUrl url, event->mimeData ()->urls ()) |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2633 { |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2634 if(dropText.length () > 0) |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2635 dropText += "\n"; |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2636 dropText += url.toLocalFile (); |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2637 } |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2638 } |
992b6354c8c6
GUI: implement file drag and drop to command and edit window (Bug #41443)
John Donoghue
parents:
18555
diff
changeset
|
2639 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2640 /* if (!urls.isEmpty()) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2641 { |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2642 for ( int i = 0 ; i < urls.count() ; i++ ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2643 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2644 KUrl url = KIO::NetAccess::mostLocalUrl( urls[i] , 0 ); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2645 QString urlText; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2646 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2647 if (url.isLocalFile()) |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2648 urlText = url.path(); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2649 else |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2650 urlText = url.url(); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2651 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2652 // in future it may be useful to be able to insert file names with drag-and-drop |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2653 // without quoting them (this only affects paths with spaces in) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2654 urlText = KShell::quoteArg(urlText); |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2655 |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2656 dropText += urlText; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2657 |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2658 if ( i != urls.count()-1 ) |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2659 dropText += ' '; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2660 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2661 } |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2662 else |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2663 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2664 dropText = event->mimeData()->text(); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2665 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2666 */ |
15669
a8ff19a82906
Added copy&paste context menu in the unix implementation.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15653
diff
changeset
|
2667 if(event->mimeData()->hasFormat("text/plain")) |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2668 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2669 emit sendStringToEmu(dropText.toLocal8Bit()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2670 } |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2671 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2672 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2673 void TerminalView::doDrag() |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2674 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2675 dragInfo.state = diDragging; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2676 dragInfo.dragObject = new QDrag(this); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2677 QMimeData *mimeData = new QMimeData; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2678 mimeData->setText(QApplication::clipboard()->text(QClipboard::Selection)); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2679 dragInfo.dragObject->setMimeData(mimeData); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2680 dragInfo.dragObject->start(Qt::CopyAction); |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2681 // Don't delete the QTextDrag object. Qt will delete it when it's done with it. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2682 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2683 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2684 void TerminalView::outputSuspended(bool suspended) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2685 { |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2686 //create the label when this function is first called |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2687 if (!_outputSuspendedLabel) |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2688 { |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2689 //This label includes a link to an English language website |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2690 //describing the 'flow control' (Xon/Xoff) feature found in almost |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2691 //all terminal emulators. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2692 //If there isn't a suitable article available in the target language the link |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2693 //can simply be removed. |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2694 _outputSuspendedLabel = new QLabel( ("<qt>Output has been " |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2695 "<a href=\"http://en.wikipedia.org/wiki/XON\">suspended</a>" |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2696 " by pressing Ctrl+S." |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2697 " Press <b>Ctrl+Q</b> to resume.</qt>"), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2698 this ); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2699 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2700 QPalette palette(_outputSuspendedLabel->palette()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2701 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2702 palette.setColor(QPalette::Normal, QPalette::WindowText, QColor(Qt::white)); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2703 palette.setColor(QPalette::Normal, QPalette::Window, QColor(Qt::black)); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2704 // KColorScheme::adjustForeground(palette,KColorScheme::NeutralText); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2705 // KColorScheme::adjustBackground(palette,KColorScheme::NeutralBackground); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2706 _outputSuspendedLabel->setPalette(palette); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2707 _outputSuspendedLabel->setAutoFillBackground(true); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2708 _outputSuspendedLabel->setBackgroundRole(QPalette::Base); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2709 _outputSuspendedLabel->setFont(QApplication::font()); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2710 _outputSuspendedLabel->setMargin(5); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2711 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2712 //enable activation of "Xon/Xoff" link in label |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2713 _outputSuspendedLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse | |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2714 Qt::LinksAccessibleByKeyboard); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2715 _outputSuspendedLabel->setOpenExternalLinks(true); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2716 _outputSuspendedLabel->setVisible(false); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2717 |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2718 _gridLayout->addWidget(_outputSuspendedLabel); |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2719 _gridLayout->addItem( new QSpacerItem(0,0,QSizePolicy::Expanding, |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2720 QSizePolicy::Expanding), |
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2721 1,0); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2722 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2723 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2724 |
15671
14da85a0d1c3
Set terminal to fixed width, renamed some variables.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
15669
diff
changeset
|
2725 _outputSuspendedLabel->setVisible(suspended); |
15651
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2726 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2727 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2728 uint TerminalView::lineSpacing() const |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2729 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2730 return _lineSpacing; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2731 } |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2732 |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2733 void TerminalView::setLineSpacing(uint i) |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2734 { |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2735 _lineSpacing = i; |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2736 setVTFont(font()); // Trigger an update. |
845cebf281aa
Added files of QConsole.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
2737 } |
16794
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
2738 |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
2739 QString TerminalView::selectedText () |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
2740 { |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
2741 QString text = _screenWindow->selectedText (_preserveLineBreaks); |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
2742 return text; |
1d1f02e0f6b4
GUI: enable clipboard content detection for terminal window context menu
John Donoghue <john.donoghue@ieee.org>
parents:
16648
diff
changeset
|
2743 } |