Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fingerterm
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Damien Caliste
fingerterm
Commits
9ff2af5f
Commit
9ff2af5f
authored
Jun 10, 2016
by
Pekka Vuorela
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose terminal rows and columns as properties
parent
caaf20b5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
31 deletions
+40
-31
ptyiface.cpp
ptyiface.cpp
+5
-5
ptyiface.h
ptyiface.h
+1
-3
qml/Main.qml
qml/Main.qml
+2
-5
qml/MenuFingerterm.qml
qml/MenuFingerterm.qml
+2
-4
terminal.cpp
terminal.cpp
+14
-4
terminal.h
terminal.h
+8
-2
textrender.cpp
textrender.cpp
+8
-8
No files found.
ptyiface.cpp
View file @
9ff2af5f
...
...
@@ -68,8 +68,8 @@ PtyIFace::PtyIFace(int pid, int masterFd, Terminal *term, QString charset, QObje
iTerm
->
setPtyIFace
(
this
);
resize
(
iTerm
->
termSize
());
connect
(
iTerm
,
SIGNAL
(
termSizeChanged
(
QSize
)),
this
,
SLOT
(
resize
(
QSize
)));
resize
(
iTerm
->
rows
(),
iTerm
->
columns
());
connect
(
iTerm
,
SIGNAL
(
termSizeChanged
(
int
,
int
)),
this
,
SLOT
(
resize
(
int
,
int
)));
iReadNotifier
=
new
QSocketNotifier
(
iMasterFd
,
QSocketNotifier
::
Read
,
this
);
connect
(
iReadNotifier
,
SIGNAL
(
activated
(
int
)),
this
,
SLOT
(
readActivated
()));
...
...
@@ -104,14 +104,14 @@ void PtyIFace::readActivated()
iTerm
->
insertInBuffer
(
iTextCodec
->
toUnicode
(
data
)
);
}
void
PtyIFace
::
resize
(
QSize
newSize
)
void
PtyIFace
::
resize
(
int
rows
,
int
columns
)
{
if
(
childProcessQuit
)
return
;
winsize
winp
;
winp
.
ws_col
=
newSize
.
width
()
;
winp
.
ws_row
=
newSize
.
height
()
;
winp
.
ws_col
=
columns
;
winp
.
ws_row
=
rows
;
ioctl
(
iMasterFd
,
TIOCSWINSZ
,
&
winp
);
}
...
...
ptyiface.h
View file @
9ff2af5f
...
...
@@ -38,10 +38,8 @@ public:
void
writeTerm
(
const
QString
&
chars
);
bool
failed
()
{
return
iFailed
;
}
public
slots
:
void
resize
(
QSize
newSize
);
private
slots
:
void
resize
(
int
rows
,
int
columns
);
void
readActivated
();
private:
...
...
qml/Main.qml
View file @
9ff2af5f
...
...
@@ -294,9 +294,6 @@ Item {
NotifyWin
{
id
:
aboutDialog
property
int
termW
property
int
termH
text
:
{
var
str
=
"
<font size=
\"
+3
\"
>FingerTerm
"
+
util
.
versionString
()
+
"
</font><br>
\n
"
+
"
<font size=
\"
+1
\"
>
"
+
...
...
@@ -304,11 +301,11 @@ Item {
"
Config files for adjusting settings are at:<br>
\n
"
+
util
.
configPath
()
+
"
/<br><br>
\n
"
+
"
Source code:<br>
\n
<a href=
\"
https://git.merproject.org/mer-core/fingerterm/
\"
>https://git.merproject.org/mer-core/fingerterm/</a>
"
if
(
term
H
!=
0
&&
termW
!=
0
)
{
if
(
term
.
rows
!=
0
&&
term
.
columns
!=
0
)
{
str
+=
"
<br><br>Current window title: <font color=
\"
gray
\"
>
"
+
util
.
windowTitle
.
substring
(
0
,
40
)
+
"
</font>
"
;
//cut long window title
if
(
util
.
windowTitle
.
length
>
40
)
str
+=
"
...
"
;
str
+=
"
<br>Current terminal size: <font color=
\"
gray
\"
>
"
+
term
W
+
"
x
"
+
termH
+
"
</font>
"
;
str
+=
"
<br>Current terminal size: <font color=
\"
gray
\"
>
"
+
term
.
columns
+
"
×
"
+
term
.
rows
+
"
</font>
"
;
str
+=
"
<br>Charset: <font color=
\"
gray
\"
>
"
+
util
.
charset
+
"
</font>
"
;
}
str
+=
"
</font>
"
;
...
...
qml/MenuFingerterm.qml
View file @
9ff2af5f
...
...
@@ -176,7 +176,7 @@ Item {
text
:
"
<font size=
\"
+3
\"
>+</font>
"
onClicked
:
{
util
.
fontSize
=
util
.
fontSize
+
window
.
pixelRatio
util
.
notifyText
(
term
.
termSize
().
width
+
"
x
"
+
term
.
termSize
().
height
);
util
.
notifyText
(
term
.
columns
+
"
×
"
+
term
.
rows
);
}
width
:
window
.
buttonWidthHalf
height
:
window
.
buttonHeightSmall
...
...
@@ -185,7 +185,7 @@ Item {
text
:
"
<font size=
\"
+3
\"
>-</font>
"
onClicked
:
{
util
.
fontSize
=
util
.
fontSize
-
window
.
pixelRatio
util
.
notifyText
(
term
.
termSize
().
width
+
"
x
"
+
term
.
termSize
().
height
);
util
.
notifyText
(
term
.
columns
+
"
×
"
+
term
.
rows
);
}
width
:
window
.
buttonWidthHalf
height
:
window
.
buttonHeightSmall
...
...
@@ -361,8 +361,6 @@ Item {
text
:
"
About
"
onClicked
:
{
menuWin
.
showing
=
false
;
aboutDialog
.
termW
=
term
.
termSize
().
width
aboutDialog
.
termH
=
term
.
termSize
().
height
aboutDialog
.
show
=
true
}
}
...
...
terminal.cpp
View file @
9ff2af5f
...
...
@@ -128,7 +128,7 @@ void Terminal::setTermSize(QSize size)
resetTabs
();
emit
termSizeChanged
(
size
);
emit
termSizeChanged
(
size
.
height
(),
size
.
width
()
);
}
}
...
...
@@ -349,7 +349,7 @@ void Terminal::insertInBuffer(const QString& chars)
if
(
iNewLineMode
)
setCursorPos
(
QPoint
(
1
,
cursorPos
().
y
()));
}
else
if
(
cursorPos
().
x
()
<=
termSize
().
width
())
// ignore newline after <termwidth> cols (terminfo: xenl)
else
if
(
cursorPos
().
x
()
<=
columns
())
// ignore newline after <termwidth> cols (terminfo: xenl)
{
if
(
iNewLineMode
)
setCursorPos
(
QPoint
(
1
,
cursorPos
().
y
()
+
1
));
...
...
@@ -1046,9 +1046,9 @@ void Terminal::escControlChar(const QString& seq)
return
;
if
(
seq
.
at
(
0
)
==
'#'
&&
seq
.
at
(
1
)
==
'8'
)
{
// test mode, fill screen with 'E'
clearAll
(
true
);
for
(
int
i
=
0
;
i
<
termSize
().
height
();
i
++
)
{
for
(
int
i
=
0
;
i
<
rows
();
i
++
)
{
QList
<
TermChar
>
line
;
for
(
int
j
=
0
;
j
<
termSize
().
width
();
j
++
)
{
for
(
int
j
=
0
;
j
<
columns
();
j
++
)
{
TermChar
c
=
zeroChar
;
c
.
c
=
'E'
;
line
.
append
(
c
);
...
...
@@ -1498,6 +1498,16 @@ void Terminal::clearSelection()
emit
selectionChanged
();
}
int
Terminal
::
rows
()
{
return
iTermSize
.
height
();
}
int
Terminal
::
columns
()
{
return
iTermSize
.
width
();
}
QRect
Terminal
::
selection
()
{
return
iSelection
;
...
...
terminal.h
View file @
9ff2af5f
...
...
@@ -53,6 +53,9 @@ struct TermAttribs {
class
Terminal
:
public
QObject
{
Q_OBJECT
Q_PROPERTY
(
int
rows
READ
rows
NOTIFY
termSizeChanged
)
Q_PROPERTY
(
int
columns
READ
columns
NOTIFY
termSizeChanged
)
public:
static
const
int
defaultFgColor
=
7
;
static
const
int
defaultBgColor
=
0
;
...
...
@@ -70,7 +73,7 @@ public:
void
setCursorPos
(
QPoint
pos
);
bool
showCursor
();
Q
_INVOKABLE
Q
Size
termSize
()
{
return
iTermSize
;
}
QSize
termSize
()
{
return
iTermSize
;
}
void
setTermSize
(
QSize
size
);
QList
<
QList
<
TermChar
>
>&
buffer
();
...
...
@@ -98,11 +101,14 @@ public:
Q_INVOKABLE
void
clearSelection
();
bool
hasSelection
();
int
rows
();
int
columns
();
TermChar
zeroChar
;
signals:
void
cursorPosChanged
(
QPoint
newPos
);
void
termSizeChanged
(
QSize
newSize
);
void
termSizeChanged
(
int
rows
,
int
columns
);
void
displayBufferChanged
();
void
selectionChanged
();
void
scrollBackBufferAdjusted
(
bool
reset
);
...
...
textrender.cpp
View file @
9ff2af5f
...
...
@@ -106,17 +106,17 @@ void TextRender::paint(QPainter* painter)
if
(
from
<
0
)
from
=
0
;
int
to
=
sTerm
->
backBuffer
().
size
();
if
(
to
-
from
>
sTerm
->
termSize
().
height
())
to
=
from
+
sTerm
->
termSize
().
height
();
if
(
to
-
from
>
sTerm
->
rows
())
to
=
from
+
sTerm
->
rows
();
paintFromBuffer
(
painter
,
sTerm
->
backBuffer
(),
from
,
to
,
y
);
if
(
to
-
from
<
sTerm
->
termSize
().
height
()
&&
sTerm
->
buffer
().
size
()
>
0
)
{
int
to2
=
sTerm
->
termSize
().
height
()
-
(
to
-
from
);
if
(
to
-
from
<
sTerm
->
rows
()
&&
sTerm
->
buffer
().
size
()
>
0
)
{
int
to2
=
sTerm
->
rows
()
-
(
to
-
from
);
if
(
to2
>
sTerm
->
buffer
().
size
())
to2
=
sTerm
->
buffer
().
size
();
paintFromBuffer
(
painter
,
sTerm
->
buffer
(),
0
,
to2
,
y
);
}
}
else
{
int
count
=
qMin
(
sTerm
->
termSize
().
height
(),
sTerm
->
buffer
().
size
());
int
count
=
qMin
(
sTerm
->
rows
(),
sTerm
->
buffer
().
size
());
paintFromBuffer
(
painter
,
sTerm
->
buffer
(),
0
,
count
,
y
);
}
...
...
@@ -145,12 +145,12 @@ void TextRender::paint(QPainter* painter)
end
.
x
()
-
start
.
x
()
+
fontWidth
(),
end
.
y
()
-
start
.
y
()
+
fontHeight
());
}
else
{
start
=
charsToPixels
(
selection
.
topLeft
());
end
=
charsToPixels
(
QPoint
(
sTerm
->
termSize
().
width
(),
selection
.
top
()));
end
=
charsToPixels
(
QPoint
(
sTerm
->
columns
(),
selection
.
top
()));
painter
->
drawRect
(
start
.
x
(),
start
.
y
(),
end
.
x
()
-
start
.
x
()
+
fontWidth
(),
end
.
y
()
-
start
.
y
()
+
fontHeight
());
start
=
charsToPixels
(
QPoint
(
1
,
selection
.
top
()
+
1
));
end
=
charsToPixels
(
QPoint
(
sTerm
->
termSize
().
width
(),
selection
.
bottom
()
-
1
));
end
=
charsToPixels
(
QPoint
(
sTerm
->
columns
(),
selection
.
bottom
()
-
1
));
painter
->
drawRect
(
start
.
x
(),
start
.
y
(),
end
.
x
()
-
start
.
x
()
+
fontWidth
(),
end
.
y
()
-
start
.
y
()
+
fontHeight
());
...
...
@@ -181,7 +181,7 @@ void TextRender::paintFromBuffer(QPainter* painter, QList<QList<TermChar> >& buf
else
painter
->
setOpacity
(
1.0
);
int
xcount
=
qMin
(
buffer
.
at
(
i
).
count
(),
sTerm
->
termSize
().
width
());
int
xcount
=
qMin
(
buffer
.
at
(
i
).
count
(),
sTerm
->
columns
());
// background for the current line
currentX
=
leftmargin
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment