changeset 13515:7eb8cd35454c

Removed unused code in order shrink down the terminal code and hopefully nearing the goal to replace it.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Mon, 18 Jul 2011 22:04:40 +0200
parents 9accc22fd9b0
children d53287c44e5a
files gui/octave-gui.pro gui/src/MainWindow.cpp gui/src/OctaveTerminal.cpp gui/src/terminal/LineFont.h gui/src/terminal/QTerminalWidget.cpp gui/src/terminal/QTerminalWidget.h gui/src/terminal/TerminalDisplay.cpp gui/src/terminal/TerminalDisplay.h gui/src/terminal/kprocess.cpp gui/src/terminal/kprocess.h
diffstat 10 files changed, 8 insertions(+), 380 deletions(-) [+]
line wrap: on
line diff
--- a/gui/octave-gui.pro
+++ b/gui/octave-gui.pro
@@ -103,7 +103,6 @@
         src/terminal/Vt102Emulation.h \
         src/terminal/TerminalDisplay.h \
         src/terminal/Filter.h \
-        src/terminal/LineFont.h \
         src/terminal/Pty.h \
         src/terminal/kpty.h \
         src/terminal/kpty_p.h \
--- a/gui/src/MainWindow.cpp
+++ b/gui/src/MainWindow.cpp
@@ -287,6 +287,7 @@
   dup2 (fds, 0);
   dup2 (fds, 1);
   dup2 (fds, 2);
+
   m_octaveTerminal->openTeletype (fdm);
   reportStatusMessage (tr ("Established link to Octave."));
 }
--- a/gui/src/OctaveTerminal.cpp
+++ b/gui/src/OctaveTerminal.cpp
@@ -34,6 +34,5 @@
 void
 OctaveTerminal::construct ()
 {
-  setScrollBarPosition (QTerminalWidget::ScrollBarRight);
   setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
 }
deleted file mode 100644
--- a/gui/src/terminal/LineFont.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* OctaveGUI - A graphical user interface for Octave
- * Copyright (C) 2011 Jacob Dawid
- * jacob.dawid@googlemail.com
- *
- * This file was autogenerated for the Konsole project.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-static const quint32 LineChars[] = {
-  0x00007c00, 0x000fffe0, 0x00421084, 0x00e739ce, 0x00000000, 0x00000000,
-    0x00000000, 0x00000000,
-  0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00427000, 0x004e7380,
-    0x00e77800, 0x00ef7bc0,
-  0x00421c00, 0x00439ce0, 0x00e73c00, 0x00e7bde0, 0x00007084, 0x000e7384,
-    0x000079ce, 0x000f7bce,
-  0x00001c84, 0x00039ce4, 0x00003dce, 0x0007bdee, 0x00427084, 0x004e7384,
-    0x004279ce, 0x00e77884,
-  0x00e779ce, 0x004f7bce, 0x00ef7bc4, 0x00ef7bce, 0x00421c84, 0x00439ce4,
-    0x00423dce, 0x00e73c84,
-  0x00e73dce, 0x0047bdee, 0x00e7bde4, 0x00e7bdee, 0x00427c00, 0x0043fce0,
-    0x004e7f80, 0x004fffe0,
-  0x004fffe0, 0x00e7fde0, 0x006f7fc0, 0x00efffe0, 0x00007c84, 0x0003fce4,
-    0x000e7f84, 0x000fffe4,
-  0x00007dce, 0x0007fdee, 0x000f7fce, 0x000fffee, 0x00427c84, 0x0043fce4,
-    0x004e7f84, 0x004fffe4,
-  0x00427dce, 0x00e77c84, 0x00e77dce, 0x0047fdee, 0x004e7fce, 0x00e7fde4,
-    0x00ef7f84, 0x004fffee,
-  0x00efffe4, 0x00e7fdee, 0x00ef7fce, 0x00efffee, 0x00000000, 0x00000000,
-    0x00000000, 0x00000000,
-  0x000f83e0, 0x00a5294a, 0x004e1380, 0x00a57800, 0x00ad0bc0, 0x004390e0,
-    0x00a53c00, 0x00a5a1e0,
-  0x000e1384, 0x0000794a, 0x000f0b4a, 0x000390e4, 0x00003d4a, 0x0007a16a,
-    0x004e1384, 0x00a5694a,
-  0x00ad2b4a, 0x004390e4, 0x00a52d4a, 0x00a5a16a, 0x004f83e0, 0x00a57c00,
-    0x00ad83e0, 0x000f83e4,
-  0x00007d4a, 0x000f836a, 0x004f93e4, 0x00a57d4a, 0x00ad836a, 0x00000000,
-    0x00000000, 0x00000000,
-  0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001c00, 0x00001084,
-    0x00007000, 0x00421000,
-  0x00039ce0, 0x000039ce, 0x000e7380, 0x00e73800, 0x000e7f80, 0x00e73884,
-    0x0003fce0, 0x004239ce
-};
--- a/gui/src/terminal/QTerminalWidget.cpp
+++ b/gui/src/terminal/QTerminalWidget.cpp
@@ -86,15 +86,6 @@
 }
 
 void
-QTerminalWidget::startShellProgram ()
-{
-  if (m_impl->m_session->isRunning ())
-    return;
-
-  m_impl->m_session->run ();
-}
-
-void
 QTerminalWidget::initialize ()
 {
   m_impl->m_terminalDisplay->setSize (80, 40);
@@ -103,8 +94,8 @@
   font.setFamily ("Monospace");
   font.setPointSize (10);
   font.setStyleHint (QFont::TypeWriter);
-  setTerminalFont (font);
-  setScrollBarPosition (NoScrollBar);
+  m_impl->m_terminalDisplay->setVTFont (font);
+  m_impl->m_terminalDisplay->setScrollBarPosition (TerminalDisplay::ScrollBarRight);
 
   m_impl->m_session->addView (m_impl->m_terminalDisplay);
 
@@ -118,22 +109,6 @@
 }
 
 void
-QTerminalWidget::setTerminalFont (QFont & font)
-{
-  if (!m_impl->m_terminalDisplay)
-    return;
-  m_impl->m_terminalDisplay->setVTFont (font);
-}
-
-void
-QTerminalWidget::setShellProgram (QString progname)
-{
-  if (!m_impl->m_session)
-    return;
-  m_impl->m_session->setProgram (progname);
-}
-
-void
 QTerminalWidget::openTeletype (int fd)
 {
   if (m_impl->m_session->isRunning ())
@@ -143,14 +118,6 @@
 }
 
 void
-QTerminalWidget::setArgs (QStringList & args)
-{
-  if (!m_impl->m_session)
-    return;
-  m_impl->m_session->setArguments (args);
-}
-
-void
 QTerminalWidget::setTextCodec (QTextCodec * codec)
 {
   if (!m_impl->m_session)
@@ -176,27 +143,12 @@
 }
 
 void
-QTerminalWidget::setScrollBarPosition (ScrollBarPosition pos)
-{
-  if (!m_impl->m_terminalDisplay)
-    return;
-  m_impl->m_terminalDisplay->
-    setScrollBarPosition ((TerminalDisplay::ScrollBarPosition) pos);
-}
-
-void
 QTerminalWidget::sendText (const QString & text)
 {
   m_impl->m_session->sendText (text);
 }
 
 void
-QTerminalWidget::installEventFilterOnDisplay (QObject * object)
-{
-  m_impl->m_terminalDisplay->installEventFilter (object);
-}
-
-void
 QTerminalWidget::resizeEvent (QResizeEvent *)
 {
   m_impl->m_terminalDisplay->resize (this->size ());
--- a/gui/src/terminal/QTerminalWidget.h
+++ b/gui/src/terminal/QTerminalWidget.h
@@ -28,33 +28,13 @@
   */
 class QTerminalWidget:public QWidget
 {
-Q_OBJECT public:
-    /**
-      * \enum ScrollBarPosition
-      * Defines the scrollbar position of the terminal.
-      */
-  enum ScrollBarPosition
-  {
-    NoScrollBar,
-    ScrollBarLeft,
-    ScrollBarRight
-  };
-
+Q_OBJECT
+  public:
     QTerminalWidget (int startnow = 1, QWidget * parent = 0);
    ~QTerminalWidget ();
 
-  void startShellProgram ();
   void openTeletype (int fd);
 
-    /** Default is application font with family Monospace, size 10. */
-  void setTerminalFont (QFont & font);
-
-    /**	Shell program, default is /bin/bash. */
-  void setShellProgram (QString progname);
-
-    /** Shell program args, default is none. */
-  void setArgs (QStringList & args);
-
     /** Text codec, default is UTF-8. */
   void setTextCodec (QTextCodec * codec);
 
@@ -64,15 +44,9 @@
     /** History size for scrolling, values below zero mean infinite. */
   void setHistorySize (int lines);
 
-    /** Presence of scrollbar. By default, there is no scrollbar present. */
-  void setScrollBarPosition (ScrollBarPosition);
-
     /** Send some text to the terminal. */
   void sendText (const QString & text);
 
-    /** Installs an event filter onto the display. */
-  void installEventFilterOnDisplay (QObject * object);
-
     signals:
     /** Emitted, when the current program has finished. */
   void finished ();
--- a/gui/src/terminal/TerminalDisplay.cpp
+++ b/gui/src/terminal/TerminalDisplay.cpp
@@ -430,100 +430,6 @@
   BotR = (1 << 23)
 };
 
-#include "LineFont.h"
-
-static void
-drawLineChar (QPainter & paint, int x, int y, int w, int h, uchar code)
-{
-  //Calculate cell midpoints, end points.
-  int cx = x + w / 2;
-  int cy = y + h / 2;
-  int ex = x + w - 1;
-  int ey = y + h - 1;
-
-  quint32 toDraw = LineChars[code];
-
-  //Top _lines:
-  if (toDraw & TopL)
-    paint.drawLine (cx - 1, y, cx - 1, cy - 2);
-  if (toDraw & TopC)
-    paint.drawLine (cx, y, cx, cy - 2);
-  if (toDraw & TopR)
-    paint.drawLine (cx + 1, y, cx + 1, cy - 2);
-
-  //Bot _lines:
-  if (toDraw & BotL)
-    paint.drawLine (cx - 1, cy + 2, cx - 1, ey);
-  if (toDraw & BotC)
-    paint.drawLine (cx, cy + 2, cx, ey);
-  if (toDraw & BotR)
-    paint.drawLine (cx + 1, cy + 2, cx + 1, ey);
-
-  //Left _lines:
-  if (toDraw & LeftT)
-    paint.drawLine (x, cy - 1, cx - 2, cy - 1);
-  if (toDraw & LeftC)
-    paint.drawLine (x, cy, cx - 2, cy);
-  if (toDraw & LeftB)
-    paint.drawLine (x, cy + 1, cx - 2, cy + 1);
-
-  //Right _lines:
-  if (toDraw & RightT)
-    paint.drawLine (cx + 2, cy - 1, ex, cy - 1);
-  if (toDraw & RightC)
-    paint.drawLine (cx + 2, cy, ex, cy);
-  if (toDraw & RightB)
-    paint.drawLine (cx + 2, cy + 1, ex, cy + 1);
-
-  //Intersection points.
-  if (toDraw & Int11)
-    paint.drawPoint (cx - 1, cy - 1);
-  if (toDraw & Int12)
-    paint.drawPoint (cx, cy - 1);
-  if (toDraw & Int13)
-    paint.drawPoint (cx + 1, cy - 1);
-
-  if (toDraw & Int21)
-    paint.drawPoint (cx - 1, cy);
-  if (toDraw & Int22)
-    paint.drawPoint (cx, cy);
-  if (toDraw & Int23)
-    paint.drawPoint (cx + 1, cy);
-
-  if (toDraw & Int31)
-    paint.drawPoint (cx - 1, cy + 1);
-  if (toDraw & Int32)
-    paint.drawPoint (cx, cy + 1);
-  if (toDraw & Int33)
-    paint.drawPoint (cx + 1, cy + 1);
-
-}
-
-void
-TerminalDisplay::drawLineCharString (QPainter & painter, int x, int y,
-				     const QString & str,
-				     const Character * attributes)
-{
-  const QPen & currentPen = painter.pen ();
-
-  if ((attributes->rendition & RE_BOLD) && _boldIntense)
-    {
-      QPen boldPen (currentPen);
-      boldPen.setWidth (3);
-      painter.setPen (boldPen);
-    }
-
-  for (int i = 0; i < str.length (); i++)
-    {
-      uchar code = str[i].cell ();
-      if (LineChars[code])
-	drawLineChar (painter, x + (_fontWidth * i), y, _fontWidth,
-		      _fontHeight, code);
-    }
-
-  painter.setPen (currentPen);
-}
-
 void
 TerminalDisplay::setKeyboardCursorShape (KeyboardCursorShape shape)
 {
@@ -536,46 +442,6 @@
 }
 
 void
-TerminalDisplay::setKeyboardCursorColor (bool useForegroundColor,
-					 const QColor & color)
-{
-  if (useForegroundColor)
-    _cursorColor = QColor ();	// an invalid color means that
-  // the foreground color of the
-  // current character should
-  // be used
-
-  else
-    _cursorColor = color;
-}
-
-QColor
-TerminalDisplay::keyboardCursorColor () const
-{
-  return _cursorColor;
-}
-
-void
-TerminalDisplay::setOpacity (qreal opacity)
-{
-  QColor color (_blendColor);
-  color.setAlphaF (opacity);
-
-  // enable automatic background filling to prevent the display
-  // flickering if there is no transparency
-  /*if ( color.alpha() == 255 ) 
-     {
-     setAutoFillBackground(true);
-     }
-     else
-     {
-     setAutoFillBackground(false);
-     } */
-
-  _blendColor = color.rgba ();
-}
-
-void
 TerminalDisplay::drawBackground (QPainter & painter, const QRect & rect,
 				 const QColor & backgroundColor,
 				 bool useOpacitySetting)
@@ -703,22 +569,10 @@
       painter.setPen (color);
     }
 
-  // draw text
-  if (isLineCharString (text))
-    drawLineCharString (painter, rect.x (), rect.y (), text, style);
+  if (_bidiEnabled)
+    painter.drawText (rect, 0, text);
   else
-    {
-      // the drawText(rect,flags,string) overload is used here with null flags
-      // instead of drawText(rect,string) because the (rect,string) overload causes 
-      // the application's default layout direction to be used instead of 
-      // the widget-specific layout direction, which should always be
-      // Qt::LeftToRight for this widget
-      // This was discussed in: http://lists.kde.org/?t=120552223600002&r=1&w=2
-      if (_bidiEnabled)
-	painter.drawText (rect, 0, text);
-      else
-	painter.drawText (rect, 0, LTR_OVERRIDE_CHAR + text);
-    }
+    painter.drawText (rect, 0, LTR_OVERRIDE_CHAR + text);
 }
 
 void
--- a/gui/src/terminal/TerminalDisplay.h
+++ b/gui/src/terminal/TerminalDisplay.h
@@ -44,8 +44,6 @@
 class QTimerEvent;
 class QWidget;
 
-class KMenu;
-
 extern unsigned short vt100_graphics[32];
 
 class ScreenWindow;
@@ -81,9 +79,6 @@
      */
   uint randomSeed () const;
 
-    /** Sets the opacity of the terminal display. */
-  void setOpacity (qreal opacity);
-
     /** 
      * This enum describes the location where the scroll bar is positioned in the display widget.
      */
@@ -228,28 +223,6 @@
   KeyboardCursorShape keyboardCursorShape () const;
 
     /**
-     * Sets the color used to draw the keyboard cursor.  
-     *
-     * The keyboard cursor defaults to using the foreground color of the character
-     * underneath it.
-     *
-     * @param useForegroundColor If true, the cursor color will change to match
-     * the foreground color of the character underneath it as it is moved, in this
-     * case, the @p color parameter is ignored and the color of the character
-     * under the cursor is inverted to ensure that it is still readable.
-     * @param color The color to use to draw the cursor.  This is only taken into
-     * account if @p useForegroundColor is false.
-     */
-  void setKeyboardCursorColor (bool useForegroundColor, const QColor & color);
-
-    /** 
-     * Returns the color of the keyboard cursor, or an invalid color if the keyboard
-     * cursor color is set to change according to the foreground color of the character
-     * underneath it. 
-     */
-  QColor keyboardCursorColor () const;
-
-    /**
      * Returns the number of lines of text which can be displayed in the widget.
      *
      * This will depend upon the height of the widget and the current font.
@@ -681,9 +654,6 @@
   void drawCharacters (QPainter & painter, const QRect & rect,
 		       const QString & text, const Character * style,
 		       bool invertCharacterColor);
-  // draws a string of line graphics
-  void drawLineCharString (QPainter & painter, int x, int y,
-			   const QString & str, const Character * attributes);
 
   // draws the preedit string for input methods
   void drawInputMethodPreeditString (QPainter & painter, const QRect & rect);
@@ -803,7 +773,6 @@
   QTimer *_blinkTimer;		// active when hasBlinker
   QTimer *_blinkCursorTimer;	// active when hasBlinkingCursor
 
-  KMenu *_drop;
   QString _dropText;
   int _dndFileCount;
 
--- a/gui/src/terminal/kprocess.cpp
+++ b/gui/src/terminal/kprocess.cpp
@@ -158,23 +158,9 @@
   return d->outputChannelMode;
 }
 
-void
-KProcess::setNextOpenMode (QIODevice::OpenMode mode)
-{
-  Q_D (KProcess);
-
-  d->openMode = mode;
-}
-
 #define DUMMYENV "_KPROCESS_DUMMY_="
 
 void
-KProcess::clearEnvironment ()
-{
-  setEnvironment (QStringList () << QString::fromLatin1 (DUMMYENV));
-}
-
-void
 KProcess::setEnv (const QString & name, const QString & value, bool overwrite)
 {
   QStringList env = environment ();
@@ -280,15 +266,6 @@
 #endif
 }
 
-void
-KProcess::setShellCommand (const QString & cmd)
-{
-  Q_D (KProcess);
-  d->args.clear ();
-  d->prog = QString::fromLatin1 ("/bin/sh");
-  d->args << QString::fromLatin1 ("-c") << cmd;
-}
-
 QStringList
 KProcess::program () const
 {
--- a/gui/src/terminal/kprocess.h
+++ b/gui/src/terminal/kprocess.h
@@ -94,17 +94,6 @@
   OutputChannelMode outputChannelMode () const;
 
     /**
-     * Set the QIODevice open mode the process will be opened in.
-     *
-     * This function must be called before starting the process, obviously.
-     *
-     * @param mode the open mode. Note that this mode is automatically
-     *   "reduced" according to the channel modes and redirections.
-     *   The default is QIODevice::ReadWrite.
-     */
-  void setNextOpenMode (QIODevice::OpenMode mode);
-
-    /**
      * Adds the variable @p name to the process' environment.
      *
      * This function must be called before starting the process.
@@ -127,16 +116,6 @@
   void unsetEnv (const QString & name);
 
     /**
-     * Empties the process' environment.
-     *
-     * Note that LD_LIBRARY_PATH/DYLD_LIBRARY_PATH is automatically added
-     * on *NIX.
-     *
-     * This function must be called before starting the process.
-     */
-  void clearEnvironment ();
-
-    /**
      * Set the program and the command line arguments.
      *
      * This function must be called before starting the process, obviously.
@@ -189,28 +168,6 @@
   void clearProgram ();
 
     /**
-     * Set a command to execute through a shell (a POSIX sh on *NIX
-     * and cmd.exe on Windows).
-     *
-     * Using this for anything but user-supplied commands is usually a bad
-     * idea, as the command's syntax depends on the platform.
-     * Redirections including pipes, etc. are better handled by the
-     * respective functions provided by QProcess.
-     *
-     * If KProcess determines that the command does not really need a
-     * shell, it will trasparently execute it without one for performance
-     * reasons.
-     *
-     * This function must be called before starting the process, obviously.
-     *
-     * @param cmd the command to execute through a shell.
-     *   The caller must make sure that all filenames etc. are properly
-     *   quoted when passed as argument. Failure to do so often results in
-     *   serious security holes. See KShell::quoteArg().
-     */
-  void setShellCommand (const QString & cmd);
-
-    /**
      * Obtain the currently set program and arguments.
      *
      * @return a list, the first element being the program, the remaining ones