| 1 | /* |
| 2 | * File: CommandLine.cpp |
| 3 | * |
| 4 | * Author: Jacob Dekel |
| 5 | * Created on: Aug 7, 2009 |
| 6 | * |
| 7 | * Copyright (c) 2009-2013 Jacob Dekel |
| 8 | * $Id$ |
| 9 | * |
| 10 | * This program is free software: you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation, either version 3 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include "CommandLine.h"cxx . . $ `<file>/HercStudio/CommandLine.h`/ |
| 26 | #include "Preferences.h"cxx . . $ `<file>/HercStudio/Preferences.h`/ |
| 27 | |
| 28 | #include <QKeyEvent> |
| 29 | |
| 30 | #include <iostream> |
| 31 | |
| 32 | CommandLinecxx . . $ CommandLine#::CommandLinecxx . . $ CommandLine#CommandLine(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget# * parent) |
| 33 | : QLineEditcxx . . $ QLineEdit#(parent), mHistoryPtrcxx . . $ CommandLine#mHistoryPtr.(-1) |
| 34 | { |
| 35 | setMaxLengthcxx . . $ QLineEdit#setMaxLength(d4f767463ce0a6b3).(512); |
| 36 | setFontcxx . . $ CommandLine#setFont(49f6e7a06ebc5aa8).(); |
| 37 | |
| 38 | } |
| 39 | |
| 40 | CommandLinecxx . . $ CommandLine#::~cxx . . $ CommandLine#`~CommandLine`(49f6e7a06ebc5aa8).CommandLinecxx . . $ CommandLine#() |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | QSizecxx . . $ QSize# CommandLinecxx . . $ CommandLine#::sizeHintcxx . . $ CommandLine#sizeHint(dc21773d1a733566).() |
| 45 | { |
| 46 | return QSizecxx . . $ QSize#QSize(3e454b8ccf442868).(1024, 50); |
| 47 | } |
| 48 | |
| 49 | void CommandLinecxx . . $ CommandLine#::enterPressedcxx . . $ CommandLine#enterPressed(3520e46b33348bf6).(const QStringcxx . . $ QString# & text1) |
| 50 | { |
| 51 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(4,"text1:"<< this->text().toStdString()); |
| 52 | mHistorycxx . . $ CommandLine#mHistory..insertcxx . . $ QVector#insert(33a0148ae801cb87).(mHistorycxx . . $ CommandLine#mHistory..begincxx . . $ QVector#begin(a488e68b8120152a).(),text1); |
| 53 | while (mHistorycxx . . $ CommandLine#mHistory..sizecxx . . $ QVector#size(455f465bc33b4cdf).() > 100) |
| 54 | mHistorycxx . . $ CommandLine#mHistory..erasecxx . . $ QVector#erase(1e77d4e25a0bf8ad).(mHistorycxx . . $ CommandLine#mHistory..endcxx . . $ QVector#end(a488e68b8120152a).()-1); |
| 55 | mHistoryPtrcxx . . $ CommandLine#mHistoryPtr. = -1; |
| 56 | this->setTextcxx . . $ QLineEdit#setText(3520e46b33348bf6).(""cxx . . $ QString#QString(85c52e162fed56f9).); |
| 57 | } |
| 58 | |
| 59 | void CommandLinecxx . . $ CommandLine#::keyPressEventcxx . . $ CommandLine#keyPressEvent(c92999c1b6b09cc0).(QKeyEventcxx . . $ QKeyEvent# * event) |
| 60 | { |
| 61 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(4, "key:" << event->key() << " " << (event->key() == Qt::Key_Up)); |
| 62 | QLineEditcxx . . $ QLineEdit#::keyPressEventcxx . . $ QLineEdit#keyPressEvent(c92999c1b6b09cc0).(event); |
| 63 | switch (event->keycxx . . $ QKeyEvent#key(455f465bc33b4cdf).()) |
| 64 | { |
| 65 | case Qtcxx . . $ Qt/::Key_Entercxx . . $ Qt/Key_Enter.: |
| 66 | case Qtcxx . . $ Qt/::Key_Returncxx . . $ Qt/Key_Return.: |
| 67 | enterPressedcxx . . $ CommandLine#enterPressed(3520e46b33348bf6).(this->textcxx . . $ QLineEdit#text(6ef7b6c27b00b43d).()); |
| 68 | break; |
| 69 | case Qtcxx . . $ Qt/::Key_Downcxx . . $ Qt/Key_Down.: |
| 70 | if (mHistoryPtrcxx . . $ CommandLine#mHistoryPtr. >= 0) mHistoryPtrcxx . . $ CommandLine#mHistoryPtr.--; |
| 71 | setLinecxx . . $ CommandLine#setLine(49f6e7a06ebc5aa8).(); |
| 72 | break; |
| 73 | case Qtcxx . . $ Qt/::Key_Upcxx . . $ Qt/Key_Up.: |
| 74 | mHistoryPtrcxx . . $ CommandLine#mHistoryPtr.++; |
| 75 | if (mHistoryPtrcxx . . $ CommandLine#mHistoryPtr. >= (signed) mHistorycxx . . $ CommandLine#mHistory..sizecxx . . $ QVector#size(455f465bc33b4cdf).()) mHistoryPtrcxx . . $ CommandLine#mHistoryPtr. = mHistorycxx . . $ CommandLine#mHistory..sizecxx . . $ QVector#size(455f465bc33b4cdf).()-1; |
| 76 | setLinecxx . . $ CommandLine#setLine(49f6e7a06ebc5aa8).(); |
| 77 | break; |
| 78 | case Qtcxx . . $ Qt/::Key_Ccxx . . $ Qt/Key_C.: |
| 79 | if (event->modifierscxx . . $ QKeyEvent#modifiers(bf228902b3e5e63b).() && Qtcxx . . $ Qt/::CTRLcxx . . $ Qt/CTRL.) |
| 80 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! ctrl_ccxx . . $ CommandLine#ctrl_c(49f6e7a06ebc5aa8).(); |
| 81 | break; |
| 82 | |
| 83 | default: |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | void CommandLinecxx . . $ CommandLine#::setLinecxx . . $ CommandLine#setLine(49f6e7a06ebc5aa8).() |
| 89 | { |
| 90 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(4,"setLine:" << mHistoryPtr << " size:" << mHistory.size() << " " << mHistory[mHistoryPtr].toStdString()); |
| 91 | if (mHistoryPtrcxx . . $ CommandLine#mHistoryPtr. < -1 || mHistoryPtrcxx . . $ CommandLine#mHistoryPtr. >= (signed) mHistorycxx . . $ CommandLine#mHistory..sizecxx . . $ QVector#size(455f465bc33b4cdf).()) |
| 92 | return; |
| 93 | if (mHistoryPtrcxx . . $ CommandLine#mHistoryPtr. != -1) |
| 94 | this->setTextcxx . . $ QLineEdit#setText(3520e46b33348bf6).(mHistorycxx . . $ CommandLine#mHistory.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).mHistoryPtrcxx . . $ CommandLine#mHistoryPtr.]); |
| 95 | else |
| 96 | this->setTextcxx . . $ QLineEdit#setText(3520e46b33348bf6).(""cxx . . $ QString#QString(85c52e162fed56f9).); |
| 97 | } |
| 98 | |
| 99 | void CommandLinecxx . . $ CommandLine#::setFontcxx . . $ CommandLine#setFont(49f6e7a06ebc5aa8).() |
| 100 | { |
| 101 | Preferencescxx . . $ Preferences#& pref = Preferencescxx . . $ Preferences#::getInstancecxx . . $ Preferences#getInstance(2e7be89de0a5bc0).(); |
| 102 | QFontcxx . . $ QFont# fontcxx . . $ QFont#QFont(7ae16150a604556).(prefcxx . . $ QString#QString(85c52e162fed56f9)..fontNamecxx . . $ Preferences#fontName(4f9fe96fc69d00d).(Preferencescxx . . $ Preferences#::CommandFontObjectcxx . . $ Preferences#CommandFontObject.).c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).(), |
| 103 | pref.fontSizecxx . . $ Preferences#fontSize(de63a260e3acfa17).(Preferencescxx . . $ Preferences#::CommandFontObjectcxx . . $ Preferences#CommandFontObject.), |
| 104 | (pref.fontIsBoldcxx . . $ Preferences#fontIsBold(104456de71e6e103).(Preferencescxx . . $ Preferences#::CommandFontObjectcxx . . $ Preferences#CommandFontObject.) ? QFontcxx . . $ QFont#::Boldcxx . . $ QFont#Bold. : QFontcxx . . $ QFont#::Normalcxx . . $ QFont#Normal.), |
| 105 | pref.fontIsItaliccxx . . $ Preferences#fontIsItalic(104456de71e6e103).(Preferencescxx . . $ Preferences#::CommandFontObjectcxx . . $ Preferences#CommandFontObject.)); |
| 106 | |
| 107 | font.setStyleHintcxx . . $ QFont#setStyleHint(5f69bb8fd37dc5d9).(QFontcxx . . $ QFont#::Couriercxx . . $ QFont#Courier.); |
| 108 | QLineEditcxx . . $ QLineEdit#::setFontcxx . . $ QWidget#setFont(d0a4bd0c8524b912).(font); |
| 109 | } |
| 110 | |
| 111 | bool CommandLinecxx . . $ CommandLine#::emptycxx . . $ CommandLine#empty(c9857a73d68e59ba).() |
| 112 | { |
| 113 | return (!(mHistorycxx . . $ CommandLine#mHistory..sizecxx . . $ QVector#size(455f465bc33b4cdf).() > 0)); |
| 114 | } |
| 115 | |
| 116 | void CommandLinecxx . . $ CommandLine#::savecxx . . $ CommandLine#save(49f6e7a06ebc5aa8).() |
| 117 | { |
| 118 | Preferencescxx . . $ Preferences#& pref = Preferencescxx . . $ Preferences#::getInstancecxx . . $ Preferences#getInstance(2e7be89de0a5bc0).(); |
| 119 | while(mHistorycxx . . $ CommandLine#mHistory..sizecxx . . $ QVector#size(455f465bc33b4cdf).() > 30) |
| 120 | mHistorycxx . . $ CommandLine#mHistory..pop_backcxx . . $ QVector#pop_back(49f6e7a06ebc5aa8).(); |
| 121 | pref.setHistorycxx . . $ Preferences#setHistory(4d3d02738a8bd7df).(mHistorycxx . . $ CommandLine#mHistory.); |
| 122 | } |
| 123 | |
| 124 | void CommandLinecxx . . $ CommandLine#::restorecxx . . $ CommandLine#restore(49f6e7a06ebc5aa8).() |
| 125 | { |
| 126 | Preferencescxx . . $ Preferences#& pref = Preferencescxx . . $ Preferences#::getInstancecxx . . $ Preferences#getInstance(2e7be89de0a5bc0).(); |
| 127 | pref.getHistorycxx . . $ Preferences#getHistory(4d3d02738a8bd7df).(mHistorycxx . . $ CommandLine#mHistory.); |
| 128 | |
| 129 | } |