Skip to content

Commit

Permalink
Merge pull request #3 from nemomobile/qt5
Browse files Browse the repository at this point in the history
Qt5
  • Loading branch information
bwachter committed Jun 16, 2013
2 parents 8794f19 + f192f4c commit fed2dfb
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 56 deletions.
12 changes: 6 additions & 6 deletions fingerterm.pro
Expand Up @@ -5,7 +5,7 @@ contains(MEEGO_EDITION,harmattan): {
}

TEMPLATE = app
TARGET =
TARGET = fingerterm
DEPENDPATH += .
INCLUDEPATH += .
LIBS += -lutil
Expand Down Expand Up @@ -49,17 +49,17 @@ RESOURCES += \
resources.qrc

unix:!symbian:!maemo5 {
target.path = /opt/fingerterm/bin
target.path = /usr/bin
INSTALLS += target
}

maemo5 {
target.path = /opt/fingerterm/bin
target.path = /usr/bin
INSTALLS += target
}

contains(MEEGO_EDITION,harmattan) {
desktopfile.files = $${TARGET}fingerterm.desktop
desktopfile.files = $${TARGET}.desktop
desktopfile.path = /usr/share/applications
INSTALLS += desktopfile
}
Expand All @@ -71,8 +71,8 @@ contains(MEEGO_EDITION,harmattan) {
}

contains(MEEGO_EDITION,nemo) {
desktopfile.extra = cp $${TARGET}fingerterm.desktop.nemo fingerterm.desktop
desktopfile.extra = cp $${TARGET}.desktop.nemo $${TARGET}.desktop
desktopfile.path = /usr/share/applications
desktopfile.files = fingerterm.desktop
desktopfile.files = $${TARGET}.desktop
INSTALLS += desktopfile
}
8 changes: 4 additions & 4 deletions main.cpp
Expand Up @@ -84,13 +84,13 @@ int main(int argc, char *argv[])
exit(0);
char *ptrs[execParts.length()+1];
for(int i=0; i<execParts.length(); i++) {
ptrs[i] = new char[execParts.at(i).toAscii().length()+1];
memcpy(ptrs[i], execParts.at(i).toAscii().data(), execParts.at(i).toAscii().length());
ptrs[i][execParts.at(i).toAscii().length()] = 0;
ptrs[i] = new char[execParts.at(i).toLatin1().length()+1];
memcpy(ptrs[i], execParts.at(i).toLatin1().data(), execParts.at(i).toLatin1().length());
ptrs[i][execParts.at(i).toLatin1().length()] = 0;
}
ptrs[execParts.length()] = 0;

execvp(execParts.first().toAscii(), ptrs);
execvp(execParts.first().toLatin1(), ptrs);
exit(0);
}

Expand Down
2 changes: 1 addition & 1 deletion ptyiface.cpp
Expand Up @@ -78,7 +78,7 @@ PtyIFace::PtyIFace(int pid, int masterFd, Terminal *term, QString charset, QObje
fcntl(iMasterFd, F_SETFL, O_NONBLOCK); // reads from the descriptor should be non-blocking

if (!charset.isEmpty())
iTextCodec = QTextCodec::codecForName(charset.toAscii());
iTextCodec = QTextCodec::codecForName(charset.toLatin1());
if (!iTextCodec)
iTextCodec = QTextCodec::codecForName("UTF-8");
if (!iTextCodec)
Expand Down
9 changes: 6 additions & 3 deletions rpm/fingerterm.spec
Expand Up @@ -6,8 +6,11 @@ Group: System/Base
License: GPLv2
Source0: %{name}-%{version}.tar.gz
URL: https://github.com/nemomobile/fingerterm
BuildRequires: pkgconfig(QtCore)
BuildRequires: pkgconfig(QtOpenGL)
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Gui)
BuildRequires: pkgconfig(Qt5OpenGL)
BuildRequires: pkgconfig(Qt5Declarative)
Obsoletes: meego-terminal <= 0.2.2
Provides: meego-terminal > 0.2.2

Expand All @@ -26,7 +29,7 @@ Provides: meego-terminal > 0.2.2

%build
sed -i 's,/opt/fingerterm/,/usr/,' fingerterm.pro
qmake MEEGO_EDITION=nemo
qmake -qt=5 MEEGO_EDITION=nemo
make %{?_smp_mflags}


Expand Down
78 changes: 39 additions & 39 deletions terminal.cpp
Expand Up @@ -159,7 +159,7 @@ void Terminal::putString(QString str, bool unEscape)
int i = str.indexOf("\\0")+2;
QString num;
while(num.length() < 3 && str.length()>i &&
(str.at(i).toAscii() >= 48 && str.at(i).toAscii() <= 55)) { //accept only 0-7
(str.at(i).toLatin1() >= 48 && str.at(i).toLatin1() <= 55)) { //accept only 0-7
num.append(str.at(i));
i++;
}
Expand Down Expand Up @@ -188,7 +188,7 @@ void Terminal::keyPress(int key, int modifiers)
QString toWrite;

if( key <= 0xFF ) {
char asciiVal = c.toAscii();
char asciiVal = c.toLatin1();

if(modifiers & Qt::AltModifier)
toWrite.append(ch_ESC);
Expand All @@ -209,13 +209,13 @@ void Terminal::keyPress(int key, int modifiers)
cursorModif = 'O';

if( key==Qt::Key_Up )
toWrite += QString("%1%2A").arg(ch_ESC).arg(cursorModif).toAscii();
toWrite += QString("%1%2A").arg(ch_ESC).arg(cursorModif).toLatin1();
if( key==Qt::Key_Down )
toWrite += QString("%1%2B").arg(ch_ESC).arg(cursorModif).toAscii();
toWrite += QString("%1%2B").arg(ch_ESC).arg(cursorModif).toLatin1();
if( key==Qt::Key_Right )
toWrite += QString("%1%2C").arg(ch_ESC).arg(cursorModif).toAscii();
toWrite += QString("%1%2C").arg(ch_ESC).arg(cursorModif).toLatin1();
if( key==Qt::Key_Left )
toWrite += QString("%1%2D").arg(ch_ESC).arg(cursorModif).toAscii();
toWrite += QString("%1%2D").arg(ch_ESC).arg(cursorModif).toLatin1();

if( key==Qt::Key_Enter || key==Qt::Key_Return ) {
if(iNewLineMode)
Expand All @@ -229,15 +229,15 @@ void Terminal::keyPress(int key, int modifiers)
toWrite = "\t";

if( key==Qt::Key_PageUp )
toWrite += QString("%1[5~").arg(ch_ESC).toAscii();
toWrite += QString("%1[5~").arg(ch_ESC).toLatin1();
if( key==Qt::Key_PageDown )
toWrite += QString("%1[6~").arg(ch_ESC).toAscii();
toWrite += QString("%1[6~").arg(ch_ESC).toLatin1();
if( key==Qt::Key_Home )
toWrite += QString("%1OH").arg(ch_ESC).toAscii();
toWrite += QString("%1OH").arg(ch_ESC).toLatin1();
if( key==Qt::Key_End )
toWrite += QString("%1OF").arg(ch_ESC).toAscii();
toWrite += QString("%1OF").arg(ch_ESC).toLatin1();
if( key==Qt::Key_Delete )
toWrite += QString("%1[3~").arg(ch_ESC).toAscii();
toWrite += QString("%1[3~").arg(ch_ESC).toLatin1();

if( key==Qt::Key_Escape ) {
toWrite += QString(1,ch_ESC);
Expand All @@ -258,7 +258,7 @@ void Terminal::insertInBuffer(const QString& chars)

for(int i=0; i<chars.size(); i++) {
QChar ch = chars.at(i);
if(ch.toAscii()=='\n' || ch.toAscii()==11 || ch.toAscii()==12) { // line feed, vertical tab or form feed
if(ch.toLatin1()=='\n' || ch.toLatin1()==11 || ch.toLatin1()==12) { // line feed, vertical tab or form feed
if(cursorPos().y()==iMarginBottom) {
scrollFwd(1);
if(iNewLineMode)
Expand All @@ -272,13 +272,13 @@ void Terminal::insertInBuffer(const QString& chars)
setCursorPos(QPoint(cursorPos().x(), cursorPos().y()+1));
}
}
else if(ch.toAscii()=='\r') { // carriage return
else if(ch.toLatin1()=='\r') { // carriage return
setCursorPos(QPoint(1,cursorPos().y()));
}
else if(ch.toAscii()=='\b' || ch.toAscii()==127) { //backspace & del (only move cursor, don't erase)
else if(ch.toLatin1()=='\b' || ch.toLatin1()==127) { //backspace & del (only move cursor, don't erase)
setCursorPos(QPoint(cursorPos().x()-1,cursorPos().y()));
}
else if(ch.toAscii()=='\a') { // BEL
else if(ch.toLatin1()=='\a') { // BEL
if(escape==']') { // BEL also ends OSC sequence
escape=-1;
oscSequence(oscSeq);
Expand All @@ -287,7 +287,7 @@ void Terminal::insertInBuffer(const QString& chars)
iUtil->bellAlert();
}
}
else if(ch.toAscii()=='\t') { //tab
else if(ch.toLatin1()=='\t') { //tab
if(cursorPos().y() <= iTabStops.size()) {
for(int i=0; i<iTabStops[cursorPos().y()-1].count(); i++) {
if(iTabStops[cursorPos().y()-1][i] > cursorPos().x()) {
Expand All @@ -297,28 +297,28 @@ void Terminal::insertInBuffer(const QString& chars)
}
}
}
else if(ch.toAscii()==14 || ch.toAscii()==15) { //SI and SO, related to character set... ignore
else if(ch.toLatin1()==14 || ch.toLatin1()==15) { //SI and SO, related to character set... ignore
}
else {
if( escape>=0 ) {
if( escape==0 && (ch.toAscii()=='[') ) {
if( escape==0 && (ch.toLatin1()=='[') ) {
escape='['; //ansi sequence
escSeq += ch;
}
else if( escape==0 && (ch.toAscii()==']') ) {
else if( escape==0 && (ch.toLatin1()==']') ) {
escape=']'; //osc sequence
oscSeq += ch;
}
else if( escape==0 && multiCharEscapes.contains(ch.toAscii())) {
escape = ch.toAscii();
else if( escape==0 && multiCharEscapes.contains(ch.toLatin1())) {
escape = ch.toLatin1();
escSeq += ch;
}
else if( escape==0 && ch.toAscii()=='\\' ) { // ESC\ also ends OSC sequence
else if( escape==0 && ch.toLatin1()=='\\' ) { // ESC\ also ends OSC sequence
escape=-1;
oscSequence(oscSeq);
oscSeq.clear();
}
else if (ch.toAscii()==ch_ESC) {
else if (ch.toLatin1()==ch_ESC) {
escape = 0;
}
else if( escape=='[' || multiCharEscapes.contains(escape) ) {
Expand All @@ -331,11 +331,11 @@ void Terminal::insertInBuffer(const QString& chars)
escSeq += ch;
}
else {
escControlChar(QByteArray(1,ch.toAscii()));
escControlChar(QByteArray(1,ch.toLatin1()));
escape=-1;
}

if( escape=='[' && ch.toAscii() >= 64 && ch.toAscii() <= 126 && ch.toAscii() != '[' ) {
if( escape=='[' && ch.toLatin1() >= 64 && ch.toLatin1() <= 126 && ch.toLatin1() != '[' ) {
ansiSequence(escSeq);
escape=-1;
escSeq.clear();
Expand All @@ -348,10 +348,10 @@ void Terminal::insertInBuffer(const QString& chars)
} else {
if (ch.isPrint())
insertAtCursor(ch, !iReplaceMode);
else if (ch.toAscii()==ch_ESC)
else if (ch.toLatin1()==ch_ESC)
escape=0;
else
qDebug() << "unprintable char" << int(ch.toAscii());
qDebug() << "unprintable char" << int(ch.toLatin1());
}
}
}
Expand Down Expand Up @@ -475,7 +475,7 @@ void Terminal::ansiSequence(const QString& seq)

bool unhandled = false;

switch(cmdChar.toAscii())
switch(cmdChar.toLatin1())
{
case 'A': //cursor up
if(!extra.isEmpty()) {
Expand Down Expand Up @@ -679,7 +679,7 @@ void Terminal::ansiSequence(const QString& seq)
if(params.count()==0)
params.append(0);
if(params.count()==1 && params.at(0)==0) {
QString toWrite = QString("%1[?1;2c").arg(ch_ESC).toAscii();
QString toWrite = QString("%1[?1;2c").arg(ch_ESC).toLatin1();
if(iPtyIFace)
iPtyIFace->writeTerm(toWrite);
} else unhandled=true;
Expand Down Expand Up @@ -714,7 +714,7 @@ void Terminal::ansiSequence(const QString& seq)

case 'n':
if(params.count()>=1 && params.at(0)==6 && extra=="") { // write cursor pos
QString toWrite = QString("%1[%2;%3R").arg(ch_ESC).arg(cursorPos().y()).arg(cursorPos().x()).toAscii();
QString toWrite = QString("%1[%2;%3R").arg(ch_ESC).arg(cursorPos().y()).arg(cursorPos().x()).toLatin1();
if(iPtyIFace)
iPtyIFace->writeTerm(toWrite);
} else unhandled=true;
Expand Down Expand Up @@ -950,41 +950,41 @@ void Terminal::escControlChar(const QString& seq)
}
}

if(ch.toAscii()=='7') { //save cursor
if(ch.toLatin1()=='7') { //save cursor
iTermAttribs_saved = iTermAttribs;
}
else if(ch.toAscii()=='8') { //restore cursor
else if(ch.toLatin1()=='8') { //restore cursor
iTermAttribs = iTermAttribs_saved;
}
else if(ch.toAscii()=='>' || ch.toAscii()=='=') { //app keypad/normal keypad - ignore these for now...
else if(ch.toLatin1()=='>' || ch.toLatin1()=='=') { //app keypad/normal keypad - ignore these for now...
}

else if(ch.toAscii()=='H') { // set a tab stop at cursor position
else if(ch.toLatin1()=='H') { // set a tab stop at cursor position
while(iTabStops.size() < cursorPos().y())
iTabStops.append(QList<int>());

iTabStops[cursorPos().y()-1].append(cursorPos().x());
qSort(iTabStops[cursorPos().y()-1]);
}
else if(ch.toAscii()=='D') { // cursor down/scroll down one line
else if(ch.toLatin1()=='D') { // cursor down/scroll down one line
scrollFwd(1, cursorPos().y());
}
else if(ch.toAscii()=='M') { // cursor up/scroll up one line
else if(ch.toLatin1()=='M') { // cursor up/scroll up one line
scrollBack(1, cursorPos().y());
}

else if(ch.toAscii()=='E') { // new line
else if(ch.toLatin1()=='E') { // new line
if(cursorPos().y()==iMarginBottom) {
scrollFwd(1);
setCursorPos(QPoint(1,cursorPos().y()));
} else {
setCursorPos(QPoint(1,cursorPos().y()+1));
}
}
else if(ch.toAscii()=='c') { // full reset
else if(ch.toLatin1()=='c') { // full reset
resetTerminal();
}
else if(ch.toAscii()=='g') { // visual bell
else if(ch.toLatin1()=='g') { // visual bell
iUtil->bellAlert();
}
else {
Expand Down
6 changes: 3 additions & 3 deletions util.cpp
Expand Up @@ -22,6 +22,7 @@
#include <QtCore>
#include <QtGui>
#include <QDBusInterface>
#include <QApplication>

#include "mainwindow.h"
#include "terminal.h"
Expand Down Expand Up @@ -398,11 +399,10 @@ bool Util::charIsHexDigit(QChar ch)
{
if (ch.isDigit()) // 0-9
return true;
else if (ch.toAscii() >= 65 && ch.toAscii() <= 70) // A-F
else if (ch.toLatin1() >= 65 && ch.toLatin1() <= 70) // A-F
return true;
else if (ch.toAscii() >= 97 && ch.toAscii() <= 102) // a-f
else if (ch.toLatin1() >= 97 && ch.toLatin1() <= 102) // a-f
return true;

return false;
}

0 comments on commit fed2dfb

Please sign in to comment.