summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp20
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp31
-rw-r--r--core/apps/embeddedkonsole/konsole.h4
3 files changed, 49 insertions, 6 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index f10bfb2..a56dc50 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -41,24 +41,25 @@
41 - 'font_a' not used in mouse events 41 - 'font_a' not used in mouse events
42 - add destructor 42 - add destructor
43*/ 43*/
44 44
45/* TODO 45/* TODO
46 - evtl. be sensitive to `paletteChange' while using default colors. 46 - evtl. be sensitive to `paletteChange' while using default colors.
47 - set different 'rounding' styles? I.e. have a mode to show clipped chars? 47 - set different 'rounding' styles? I.e. have a mode to show clipped chars?
48*/ 48*/
49 49
50// #include "config.h" 50// #include "config.h"
51#include "TEWidget.h" 51#include "TEWidget.h"
52#include "session.h" 52#include "session.h"
53#include <qpe/config.h>
53 54
54#include <qcursor.h> 55#include <qcursor.h>
55#include <qregexp.h> 56#include <qregexp.h>
56#include <qpainter.h> 57#include <qpainter.h>
57#include <qclipboard.h> 58#include <qclipboard.h>
58#include <qstyle.h> 59#include <qstyle.h>
59#include <qfile.h> 60#include <qfile.h>
60#include <qdragobject.h> 61#include <qdragobject.h>
61 62
62#include <stdio.h> 63#include <stdio.h>
63#include <stdlib.h> 64#include <stdlib.h>
64#include <unistd.h> 65#include <unistd.h>
@@ -143,25 +144,25 @@ const ColorEntry* TEWidget::getdefaultColorTable() const
143 144
144 145
145const QPixmap *TEWidget::backgroundPixmap() 146const QPixmap *TEWidget::backgroundPixmap()
146{ 147{
147 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 148 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
148 const QPixmap *pm = bg; 149 const QPixmap *pm = bg;
149 return pm; 150 return pm;
150} 151}
151 152
152void TEWidget::setColorTable(const ColorEntry table[]) 153void TEWidget::setColorTable(const ColorEntry table[])
153{ 154{
154 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 155 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
155 156
156 const QPixmap* pm = backgroundPixmap(); 157 const QPixmap* pm = backgroundPixmap();
157 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 158 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
158 update(); 159 update();
159} 160}
160 161
161//FIXME: add backgroundPixmapChanged. 162//FIXME: add backgroundPixmapChanged.
162 163
163/* ------------------------------------------------------------------------- */ 164/* ------------------------------------------------------------------------- */
164/* */ 165/* */
165/* Font */ 166/* Font */
166/* */ 167/* */
167/* ------------------------------------------------------------------------- */ 168/* ------------------------------------------------------------------------- */
@@ -276,25 +277,38 @@ void TEWidget::setFont(const QFont &)
276 277
277TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 278TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
278{ 279{
279#ifndef QT_NO_CLIPBOARD 280#ifndef QT_NO_CLIPBOARD
280 cb = QApplication::clipboard(); 281 cb = QApplication::clipboard();
281 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 282 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
282 this, SLOT(onClearSelection()) ); 283 this, SLOT(onClearSelection()) );
283#endif 284#endif
284 285
285 scrollbar = new QScrollBar(this); 286 scrollbar = new QScrollBar(this);
286 scrollbar->setCursor( arrowCursor ); 287 scrollbar->setCursor( arrowCursor );
287 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 288 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
288 scrollLoc = SCRNONE; 289
290 Config cfg("Konsole");
291 cfg.setGroup("ScrollBar");
292 switch( cfg.readNumEntry("Position",2)){
293 case 0:
294 scrollLoc = SCRNONE;
295 break;
296 case 1:
297 scrollLoc = SCRLEFT;
298 break;
299 case 2:
300 scrollLoc = SCRRIGHT;
301 break;
302 };
289 303
290 blinkT = new QTimer(this); 304 blinkT = new QTimer(this);
291 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 305 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
292 // blinking = FALSE; 306 // blinking = FALSE;
293 blinking = TRUE; 307 blinking = TRUE;
294 308
295 resizing = FALSE; 309 resizing = FALSE;
296 actSel = 0; 310 actSel = 0;
297 image = 0; 311 image = 0;
298 lines = 1; 312 lines = 1;
299 columns = 1; 313 columns = 1;
300 font_w = 1; 314 font_w = 1;
@@ -642,25 +656,25 @@ void TEWidget::mousePressEvent(QMouseEvent* ev)
642//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 656//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
643 if ( ev->button() == LeftButton) 657 if ( ev->button() == LeftButton)
644 { 658 {
645 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 659 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
646 660
647 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 661 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
648 662
649 if (mouse_marks || (ev->state() & ShiftButton)) 663 if (mouse_marks || (ev->state() & ShiftButton))
650 { 664 {
651 emit clearSelectionSignal(); 665 emit clearSelectionSignal();
652 iPntSel = pntSel = pos; 666 iPntSel = pntSel = pos;
653 actSel = 1; // left mouse button pressed but nothing selected yet. 667 actSel = 1; // left mouse button pressed but nothing selected yet.
654 grabMouse( /*crossCursor*/ ); // handle with care! 668 grabMouse( /*crossCursor*/ ); // handle with care!
655 } 669 }
656 else 670 else
657 { 671 {
658 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 672 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
659 } 673 }
660 } 674 }
661 if ( ev->button() == MidButton ) 675 if ( ev->button() == MidButton )
662 { 676 {
663 emitSelection(); 677 emitSelection();
664 } 678 }
665 if ( ev->button() == RightButton ) // Configure 679 if ( ev->button() == RightButton ) // Configure
666 { 680 {
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index d54fa1f..e2d4886 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -215,25 +215,26 @@ void Konsole::init(const char* _pgm, QStrList & _args)
215 215
216 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); 216 QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
217 217
218 fontList = new QPopupMenu( this ); 218 fontList = new QPopupMenu( this );
219 for(uint i = 0; i < fonts.count(); i++) { 219 for(uint i = 0; i < fonts.count(); i++) {
220 VTFont *fnt = fonts.at(i); 220 VTFont *fnt = fonts.at(i);
221 fontList->insertItem(fnt->getName(), i); 221 fontList->insertItem(fnt->getName(), i);
222 } 222 }
223 fontChanged(cfont); 223 fontChanged(cfont);
224 224
225 configMenu = new QPopupMenu( this); 225 configMenu = new QPopupMenu( this);
226 colorMenu = new QPopupMenu( this); 226 colorMenu = new QPopupMenu( this);
227 227 scrollMenu = new QPopupMenu( this);
228
228 bool listHidden; 229 bool listHidden;
229 cfg.setGroup("Menubar"); 230 cfg.setGroup("Menubar");
230 if( cfg.readEntry("Hidden","FALSE") == "TRUE") { 231 if( cfg.readEntry("Hidden","FALSE") == "TRUE") {
231 configMenu->insertItem("Show command list"); 232 configMenu->insertItem("Show command list");
232 listHidden=TRUE; 233 listHidden=TRUE;
233 } else { 234 } else {
234 configMenu->insertItem("Hide command list"); 235 configMenu->insertItem("Hide command list");
235 listHidden=FALSE; 236 listHidden=FALSE;
236 } 237 }
237 238
238 cfg.setGroup("Tabs"); 239 cfg.setGroup("Tabs");
239 tmp=cfg.readEntry("Position","Bottom"); 240 tmp=cfg.readEntry("Position","Bottom");
@@ -254,24 +255,25 @@ void Konsole::init(const char* _pgm, QStrList & _args)
254 colorMenu->insertItem("Red on Black"); 255 colorMenu->insertItem("Red on Black");
255 colorMenu->insertItem("Green on Yellow"); 256 colorMenu->insertItem("Green on Yellow");
256 colorMenu->insertItem("Blue on Magenta"); 257 colorMenu->insertItem("Blue on Magenta");
257 colorMenu->insertItem("Magenta on Blue"); 258 colorMenu->insertItem("Magenta on Blue");
258 colorMenu->insertItem("Cyan on White"); 259 colorMenu->insertItem("Cyan on White");
259 colorMenu->insertItem("White on Cyan"); 260 colorMenu->insertItem("White on Cyan");
260 colorMenu->insertItem("Blue on Black"); 261 colorMenu->insertItem("Blue on Black");
261 configMenu->insertItem("Colors",colorMenu); 262 configMenu->insertItem("Colors",colorMenu);
262 263
263 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 264 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
264 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 265 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
265 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); 266 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) ));
267 connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int)));
266 268
267 menuBar->insertItem( tr("Font"), fontList ); 269 menuBar->insertItem( tr("Font"), fontList );
268 menuBar->insertItem( tr("Options"), configMenu ); 270 menuBar->insertItem( tr("Options"), configMenu );
269 271
270 QPEToolBar *toolbar = new QPEToolBar( this ); 272 QPEToolBar *toolbar = new QPEToolBar( this );
271 273
272 QAction *a; 274 QAction *a;
273 275
274 // Button Commands 276 // Button Commands
275 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 277 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
276 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 278 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
277 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 279 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
@@ -307,24 +309,29 @@ void Konsole::init(const char* _pgm, QStrList & _args)
307 cfg.setGroup("Commands"); 309 cfg.setGroup("Commands");
308 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 310 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
309 311
310 for (int i = 0; commonCmds[i] != NULL; i++) { 312 for (int i = 0; commonCmds[i] != NULL; i++) {
311 commonCombo->insertItem( commonCmds[i], i ); 313 commonCombo->insertItem( commonCmds[i], i );
312 tmp = cfg.readEntry( QString::number(i),""); 314 tmp = cfg.readEntry( QString::number(i),"");
313 if(tmp != "") 315 if(tmp != "")
314 commonCombo->changeItem( tmp,i ); 316 commonCombo->changeItem( tmp,i );
315 } 317 }
316 318
317 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 319 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
318 320
321 scrollMenu->insertItem("None");
322 scrollMenu->insertItem("Left");
323 scrollMenu->insertItem("Right");
324 configMenu->insertItem("ScrollBar",scrollMenu);
325
319 // create applications ///////////////////////////////////////////////////// 326 // create applications /////////////////////////////////////////////////////
320 setCentralWidget(tab); 327 setCentralWidget(tab);
321 328
322 // load keymaps //////////////////////////////////////////////////////////// 329 // load keymaps ////////////////////////////////////////////////////////////
323 KeyTrans::loadAll(); 330 KeyTrans::loadAll();
324 for (int i = 0; i < KeyTrans::count(); i++) 331 for (int i = 0; i < KeyTrans::count(); i++)
325 { KeyTrans* s = KeyTrans::find(i); 332 { KeyTrans* s = KeyTrans::find(i);
326 assert( s ); 333 assert( s );
327 } 334 }
328 335
329 se_pgm = _pgm; 336 se_pgm = _pgm;
330 se_args = _args; 337 se_args = _args;
@@ -754,12 +761,34 @@ void Konsole::changeCommand(const QString &text, int c)
754 commonCombo->setCurrentItem(c); 761 commonCombo->setCurrentItem(c);
755 } 762 }
756} 763}
757 764
758void Konsole::setColor() 765void Konsole::setColor()
759{ 766{
760 Config cfg("Konsole"); 767 Config cfg("Konsole");
761 cfg.setGroup("Colors"); 768 cfg.setGroup("Colors");
762 int scheme = cfg.readNumEntry("Schema",1); 769 int scheme = cfg.readNumEntry("Schema",1);
763 if(scheme != 1) colorMenuSelected( -scheme); 770 if(scheme != 1) colorMenuSelected( -scheme);
764 771
765} 772}
773
774void Konsole::scrollMenuSelected(int index)
775{
776 TEWidget* te = getTe();
777Config cfg("Konsole");
778 cfg.setGroup("Scrollbar");
779 switch( index){
780 case -21:
781 te->setScrollbarLocation(0);
782 cfg.writeEntry("Position",0);
783 break;
784 case -22:
785 te->setScrollbarLocation(1);
786 cfg.writeEntry("Position",1);
787 break;
788 case -23:
789 te->setScrollbarLocation(2);
790 cfg.writeEntry("Position",2);
791 break;
792 };
793
794}
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h
index 40003d4..b4e5d87 100644
--- a/core/apps/embeddedkonsole/konsole.h
+++ b/core/apps/embeddedkonsole/konsole.h
@@ -61,25 +61,25 @@ private slots:
61 void configMenuSelected(int ); 61 void configMenuSelected(int );
62 void colorMenuSelected(int); 62 void colorMenuSelected(int);
63 void enterCommand(int); 63 void enterCommand(int);
64 void hitEnter(); 64 void hitEnter();
65 void hitSpace(); 65 void hitSpace();
66 void hitTab(); 66 void hitTab();
67 void hitPaste(); 67 void hitPaste();
68 void hitUp(); 68 void hitUp();
69 void hitDown(); 69 void hitDown();
70 void switchSession(QWidget *); 70 void switchSession(QWidget *);
71 void newSession(); 71 void newSession();
72 void changeCommand(const QString &, int); 72 void changeCommand(const QString &, int);
73 73 void scrollMenuSelected(int);
74private: 74private:
75 void init(const char* _pgm, QStrList & _args); 75 void init(const char* _pgm, QStrList & _args);
76 void initSession(const char* _pgm, QStrList & _args); 76 void initSession(const char* _pgm, QStrList & _args);
77 void runSession(TESession* s); 77 void runSession(TESession* s);
78 void setColorPixmaps(); 78 void setColorPixmaps();
79 void setHistory(bool); 79 void setHistory(bool);
80 QSize calcSize(int columns, int lines); 80 QSize calcSize(int columns, int lines);
81 TEWidget* getTe(); 81 TEWidget* getTe();
82 82
83private: 83private:
84 class VTFont 84 class VTFont
85 { 85 {
@@ -103,25 +103,25 @@ private:
103 private: 103 private:
104 QString name; 104 QString name;
105 QFont font; 105 QFont font;
106 }; 106 };
107 107
108 EKNumTabWidget* tab; 108 EKNumTabWidget* tab;
109 int nsessions; 109 int nsessions;
110 QList<VTFont> fonts; 110 QList<VTFont> fonts;
111 int cfont; 111 int cfont;
112 QCString se_pgm; 112 QCString se_pgm;
113 QStrList se_args; 113 QStrList se_args;
114 114
115 QPopupMenu* fontList,*configMenu,*colorMenu; 115 QPopupMenu* fontList,*configMenu,*colorMenu,*scrollMenu;
116 QComboBox *commonCombo; 116 QComboBox *commonCombo;
117 // history scrolling I think 117 // history scrolling I think
118 bool b_scroll; 118 bool b_scroll;
119 119
120 int n_keytab; 120 int n_keytab;
121 int n_scroll; 121 int n_scroll;
122 int n_render; 122 int n_render;
123 QString pmPath; // pixmap path 123 QString pmPath; // pixmap path
124 QString dropText; 124 QString dropText;
125 QFont defaultFont; 125 QFont defaultFont;
126 QSize defaultSize; 126 QSize defaultSize;
127 127