File indexing completed on 2025-01-12 06:47:25
0001 /*************************************************************************** 0002 cconsole.h - main displaying widget 0003 This file is a part of KMuddy distribution. 0004 ------------------- 0005 begin : So Jun 22 2017 0006 copyright : (C) 2002-2017 by Tomas Mecir 0007 email : mecirt@gmail.com 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 ***************************************************************************/ 0018 0019 #ifndef CCONSOLE_H 0020 #define CCONSOLE_H 0021 0022 #define TRANSCRIPT_PLAIN 2 0023 #define TRANSCRIPT_ANSI 3 0024 #define TRANSCRIPT_HTML 1 0025 0026 #include <kmuddy_export.h> 0027 0028 #include <QClipboard> 0029 #include <QFile> 0030 #include <QGraphicsView> 0031 #include <QStringList> 0032 class cTextChunk; 0033 0034 //maximum cache size 0035 #define MAXCACHE 50 0036 0037 /** 0038 Main console - displays output of the MUD server... 0039 This is a new version of the displaying widget, replacing the old QTableView-based widget. 0040 */ 0041 0042 class KMUDDY_EXPORT cConsole : public QGraphicsView { 0043 Q_OBJECT 0044 public: 0045 cConsole(QWidget *parent = Q_NULLPTR); 0046 ~cConsole() override; 0047 void setSession (int s); 0048 0049 /** set font */ 0050 void setFont (QFont f); 0051 /** get currently used font */ 0052 QFont font (); 0053 0054 void setDefaultBkColor (QColor color); 0055 QColor defaultBkColor (); 0056 0057 void setIndentation (int val); 0058 void setEnableBlinking (bool value); 0059 0060 /** return current number of rows */ 0061 int curRows(); 0062 /** return current number of columns */ 0063 int curCols(); 0064 0065 /** Is the scroll text visible? */ 0066 void setScrollTextVisible (bool vis); 0067 /** Size of the secondary console shown while scrolling */ 0068 void setScrollTextSize (int aconsize); 0069 0070 /** forces amission of dimensionsChanged signal; used by toolbar hiding 0071 functions, where this fails for unknown reasons */ 0072 void forceEmitSize (); 0073 /** dump all history buffer to that file */ 0074 void dumpBuffer (bool fromcurrent, QFile &file, char dumpType); 0075 void setHistorySize (int size); 0076 0077 /** How many lines in total does the console have currently? */ 0078 int totalLines(); 0079 QStringList words (QString prefix, int minLength = 3); 0080 /** clear the widget */ 0081 void clear (); 0082 /** adds line to the widget */ 0083 void addLine (cTextChunk *chunk); 0084 /** as addLine, but does not end line */ 0085 void addText (cTextChunk *chunk); 0086 /** ensure that our current position is at beginning of a line */ 0087 void forceBeginOfLine (); 0088 0089 /** expire all links with a given name, or all named links if no name given */ 0090 void expireNamedLinks (const QString &name = QString()); 0091 0092 public slots: 0093 /** adds selection to clipboard (adding to mouse selection buffer is done 0094 automatically) */ 0095 void addSelectionToClipboard (QClipboard::Mode clipboardMode); 0096 void linkHovered (const QString &link); 0097 void linkActivated (const QString &link); 0098 0099 /** shifting it around (SHIFT+keys) */ 0100 void lineUp (); 0101 void lineDown (); 0102 void pageUp (); 0103 void pageDown (); 0104 0105 signals: 0106 void dimensionsChanged (int cols, int rows); 0107 void sendCommand (const QString &command); 0108 void promptCommand (const QString &command); 0109 0110 protected slots: 0111 void sliderChanged (int val); 0112 void sceneChanged (const QList<QRectF> ®ion = QList<QRectF>()); 0113 0114 protected: 0115 void resizeEvent (QResizeEvent *e) override; 0116 bool viewportEvent(QEvent *event) override; 0117 void scrollContentsBy (int dx, int dy) override; 0118 /** called when resizing and when changing font */ 0119 void fixupOutput (bool sizeChanged = false); 0120 void adjustScrollBack (); 0121 0122 void addNewText (cTextChunk *chunk, bool endTheLine); 0123 0124 class Private; 0125 Private *d; 0126 }; 0127 0128 #endif