# HG changeset patch # User Jordi Gutiérrez Hermoso # Date 1344868339 14400 # Node ID dbc43bd954776d68ecbf73fd938cb35aecb405ed # Parent a87fa9132b72c04c0ae90c4810c0c5f21edaa8d7# Parent ad9523348676b4ce393428580a38740b3e8925db Merge gui onto default \o/ diff -r a87fa9132b72 -r dbc43bd95477 .hgsub --- a/.hgsub Sat Aug 11 17:32:42 2012 -0400 +++ b/.hgsub Mon Aug 13 10:32:19 2012 -0400 @@ -1,1 +1,2 @@ gnulib = [git]git://git.sv.gnu.org/gnulib +gui/qterminal = [git]https://code.google.com/p/qterminal/ diff -r a87fa9132b72 -r dbc43bd95477 .hgsubstate --- a/.hgsubstate Sat Aug 11 17:32:42 2012 -0400 +++ b/.hgsubstate Mon Aug 13 10:32:19 2012 -0400 @@ -1,1 +1,2 @@ 0e3af50c9e20938bd1cea0182bf749ce61cb6782 gnulib +0f7cc1d7ef5c34b146ff71207ada3ec87a24097c gui/qterminal diff -r a87fa9132b72 -r dbc43bd95477 Makefile.am --- a/Makefile.am Sat Aug 11 17:32:42 2012 -0400 +++ b/Makefile.am Mon Aug 13 10:32:19 2012 -0400 @@ -67,8 +67,14 @@ include m4/module.mk +if AMCOND_BUILD_GUI +GUIDIR = gui +else +GUIDIR = +endif + # Subdirectories in which to run `make all'. -SUBDIRS = libgnu libcruft liboctave src scripts @DOCDIR@ examples test +SUBDIRS = libgnu libcruft liboctave $(GUIDIR) src scripts @DOCDIR@ examples test if ! AMCOND_BUILD_DOCS dist-hook: diff -r a87fa9132b72 -r dbc43bd95477 NEWS --- a/NEWS Sat Aug 11 17:32:42 2012 -0400 +++ b/NEWS Mon Aug 13 10:32:19 2012 -0400 @@ -1,3 +1,8 @@ +Summary of important user-visible changes for version 4.0: +--------------------------------------------------------- + + ** A new GUI is now available with Octave. + Summary of important user-visible changes for version 3.8: --------------------------------------------------------- diff -r a87fa9132b72 -r dbc43bd95477 build-aux/common.mk --- a/build-aux/common.mk Sat Aug 11 17:32:42 2012 -0400 +++ b/build-aux/common.mk Mon Aug 13 10:32:19 2012 -0400 @@ -568,6 +568,8 @@ -e "s|%OCTAVE_CONF_QRUPDATE_CPPFLAGS%|\"${QRUPDATE_CPPFLAGS}\"|" \ -e "s|%OCTAVE_CONF_QRUPDATE_LDFLAGS%|\"${QRUPDATE_LDFLAGS}\"|" \ -e "s|%OCTAVE_CONF_QRUPDATE_LIBS%|\"${QRUPDATE_LIBS}\"|" \ + -e "s|%OCTAVE_CONF_QT_INCDIR%|\"${QT_INCDIR}\"|" \ + -e "s|%OCTAVE_CONF_QT_LIBDIR%|\"${QT_LIBDIR}\"|" \ -e "s|%OCTAVE_CONF_RANLIB%|\"${RANLIB}\"|" \ -e "s|%OCTAVE_CONF_RDYNAMIC_FLAG%|\"${RDYNAMIC_FLAG}\"|" \ -e "s|%OCTAVE_CONF_READLINE_LIBS%|\"${READLINE_LIBS}\"|" \ diff -r a87fa9132b72 -r dbc43bd95477 configure.ac --- a/configure.ac Sat Aug 11 17:32:42 2012 -0400 +++ b/configure.ac Mon Aug 13 10:32:19 2012 -0400 @@ -2146,6 +2146,44 @@ AC_SUBST(WARN_CFLAGS) AC_SUBST(WARN_CXXFLAGS) +### GUI/Qt related tests. + +HAVE_QT=false +QT_INCDIR= +QT_LIBDIR= +build_gui=yes +win32_terminal=no +AC_ARG_ENABLE(gui, + [AS_HELP_STRING([--disable-gui], [build GUI (default is yes)])], + [if test "$enableval" = no; then build_gui=no; fi], [build_gui=yes]) + +if test $build_gui = yes; then + AC_CHECK_PROGS(QMAKE, [qmake qmake-qt4 qmake-qt5]) + if test -n "$QMAKE"; then + QT_INCDIR=`$QMAKE -query | sed -n -e 's/^QT_INSTALL_HEADERS://p'` + QT_LIBDIR=`$QMAKE -query | sed -n -e 's/^QT_INSTALL_LIBS://p'` + AC_CHECK_PROGS(MOC, [moc moc-qt4 moc-qt5]) + AC_CHECK_PROGS(UIC, [uic uic-qt4 uic-qt5]) + AC_CHECK_PROGS(RCC, [rcc]) + if test -n "$MOC" && test -n "$UIC" && test -n "$RCC"; then + HAVE_QT=true + AC_DEFINE([HAVE_QT], 1, [Define to 1 if Qt is available (must have moc, uic, and rcc programs and developer header files and libraries installed)]) + fi + fi + + case "$canonical_host_type" in + *-*-mingw* | *-*-msdosmsvc*) win32_terminal=yes ;; + *) + AC_CHECK_HEADERS([pty.h libutil.h util.h]) + AC_SEARCH_LIBS([openpty], [util], [AC_DEFINE([HAVE_OPENPTY], [], [Define whether openpty exists])]) + ;; + esac +fi +AM_CONDITIONAL([AMCOND_BUILD_GUI], [test $build_gui = yes]) +AM_CONDITIONAL([WIN32_TERMINAL], [test $win32_terminal = yes]) +AC_SUBST(QT_INCDIR) +AC_SUBST(QT_LIBDIR) + ### Run configure in subdirectories. export CC @@ -2321,6 +2359,8 @@ doc/liboctave/Makefile doc/refcard/Makefile examples/Makefile + gui/Makefile + gui/src/Makefile libcruft/Makefile libcruft/mkf77def libgnu/Makefile @@ -2405,6 +2445,8 @@ QHULL LDFLAGS: $QHULL_LDFLAGS QHULL libraries: $QHULL_LIBS QRUPDATE libraries: $QRUPDATE_LIBS + Qt headers: $QT_INCDIR + Qt libraries: $QT_LIBDIR READLINE libraries: $READLINE_LIBS REGEX libraries: $REGEX_LIBS TERM libraries: $TERM_LIBS diff -r a87fa9132b72 -r dbc43bd95477 doc/interpreter/contributors.in --- a/doc/interpreter/contributors.in Sat Aug 11 17:32:42 2012 -0400 +++ b/doc/interpreter/contributors.in Mon Aug 13 10:32:19 2012 -0400 @@ -294,3 +294,6 @@ Michael Zeising Federico Zenith Alex Zvoleff +Valentin Ortega-Clavero +Jacob Dawid +Júlio Hoffimann diff -r a87fa9132b72 -r dbc43bd95477 doc/interpreter/install.txi --- a/doc/interpreter/install.txi Sat Aug 11 17:32:42 2012 -0400 +++ b/doc/interpreter/install.txi Mon Aug 13 10:32:19 2012 -0400 @@ -275,6 +275,17 @@ provide improved performance for the functions @code{qrdelete}, @code{qrinsert}, @code{qrshift}, and @code{qrupdate}. +@item QScintilla +Source code highlighter and manipulator; a Qt port of Scintilla +(@url{http://www.riverbankcomputing.co.uk/software/qscintilla}). +QScintilla is used for syntax highlighting and code completion in the +GUI. + +@item Qt +GUI and utility libraries (@url{}). Qt is required for building the GUI. +It is a large framework, but the only components required are the GUI, +core, Webkit, and network modules. + @item SuiteSparse Sparse matrix factorization library (@url{http://www.cise.ufl.edu/research/sparse/SuiteSparse}). diff -r a87fa9132b72 -r dbc43bd95477 gui/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/Makefile.am Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,3 @@ +SUBDIRS = src + +octetc_DATA = default-qt-settings diff -r a87fa9132b72 -r dbc43bd95477 gui/default-qt-settings --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/default-qt-settings Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,37 @@ +[General] +connectOnStartup=true +showMessageOfTheDay=true +showTopic=true +autoIdentification=false +nickServPassword= +useCustomFileEditor=false +customFileEditor=emacs +showFilenames=true +showFileSize=false +showFileType=false +showLastModified=false +showHiddenFiles=false +useAlternatingRowColors=true +useProxyServer=false +proxyType= +proxyHostName=none +proxyPort=8080 +proxyUserName= +proxyPassword= + +[editor] +showLineNumbers=true +highlightCurrentLine=true +codeCompletion=true +fontName=Ubuntu Mono +fontSize=12 +shortWindowTitle=true +longWindowTitle=true + +[terminal] +fontSize=10 +fontName=Andale Mono + +[MainWindow] +geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x1\0\0\0\0\0\x31\0\0\0\x18\0\0\x4\xff\0\0\x3\xff\0\0\0\0\0\0\0\0\xff\xff\xff\xfe\xff\xff\xff\xfe\0\0\0\0\x2\0) +windowState=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x1\0\0\0\x1\0\0\x4\xcf\0\0\x3\x91\xfc\x2\0\0\0\x1\xfc\0\0\0\x41\0\0\x3\x91\0\0\x1\xc7\0\xff\xff\xff\xfc\x1\0\0\0\x3\xfc\0\0\0\0\0\0\x1.\0\0\0R\0\xff\xff\xff\xfc\x2\0\0\0\x2\xfb\0\0\0\x1a\0W\0o\0r\0k\0s\0p\0\x61\0\x63\0\x65\0V\0i\0\x65\0w\x1\0\0\0\x41\0\0\x1\xe8\0\0\0k\0\xff\xff\xff\xfb\0\0\0\"\0H\0i\0s\0t\0o\0r\0y\0\x44\0o\0\x63\0k\0W\0i\0\x64\0g\0\x65\0t\x1\0\0\x2/\0\0\x1\xa3\0\0\0\x8c\0\xff\xff\xff\xfc\0\0\x1\x34\0\0\x2\x81\0\0\x2\x81\0\0\x2\x81\xfa\0\0\0\0\x2\0\0\0\x2\xfb\0\0\0$\0T\0\x65\0r\0m\0i\0n\0\x61\0l\0\x44\0o\0\x63\0k\0W\0i\0\x64\0g\0\x65\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1\xa9\0\xff\xff\xff\xfb\0\0\0\x14\0\x46\0i\0l\0\x65\0\x45\0\x64\0i\0t\0o\0r\x1\0\0\x1\xf0\0\0\x1\xe2\0\0\0j\0\xff\xff\xff\xfb\0\0\0\x1e\0\x46\0i\0l\0\x65\0s\0\x44\0o\0\x63\0k\0W\0i\0\x64\0g\0\x65\0t\x1\0\0\x3\xbb\0\0\x1\x14\0\0\0P\0\xff\xff\xff\0\0\0\0\0\0\x3\x91\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\xff\xff\xff\xff\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0) diff -r a87fa9132b72 -r dbc43bd95477 gui/gui.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/gui.pro Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = qterminal src diff -r a87fa9132b72 -r dbc43bd95477 gui/kb-layouts/default.keytab --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/kb-layouts/default.keytab Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,133 @@ +# [README.default.Keytab] Buildin Keyboard Table +# +# To customize your keyboard, copy this file to something +# ending with .keytab and change it to meet you needs. +# Please read the README.KeyTab and the README.keyboard +# in this case. +# +# -------------------------------------------------------------- + +keyboard "Default (XFree 4)" + +# -------------------------------------------------------------- +# +# Note that this particular table is a "risc" version made to +# ease customization without bothering with obsolete details. +# See VT100.keytab for the more hairy stuff. +# +# -------------------------------------------------------------- + +# common keys + +key Escape : "\E" + +key Tab -Shift : "\t" +key Tab +Shift+Ansi : "\E[Z" +key Tab +Shift-Ansi : "\t" +key Backtab +Ansi : "\E[Z" +key Backtab -Ansi : "\t" + +key Return-Shift-NewLine : "\r" +key Return-Shift+NewLine : "\r\n" + +key Return+Shift : "\EOM" + +# Backspace and Delete codes are preserving CTRL-H. + +key Backspace : "\x7f" + +# Arrow keys in VT52 mode +# shift up/down are reserved for scrolling. +# shift left/right are reserved for switching between tabs (this is hardcoded). + +key Up -Shift-Ansi : "\EA" +key Down -Shift-Ansi : "\EB" +key Right-Shift-Ansi : "\EC" +key Left -Shift-Ansi : "\ED" + +# Arrow keys in ANSI mode with Application - and Normal Cursor Mode) + +key Up -Shift-AnyMod+Ansi+AppCuKeys : "\EOA" +key Down -Shift-AnyMod+Ansi+AppCuKeys : "\EOB" +key Right -Shift-AnyMod+Ansi+AppCuKeys : "\EOC" +key Left -Shift-AnyMod+Ansi+AppCuKeys : "\EOD" + +key Up -Shift-AnyMod+Ansi-AppCuKeys : "\E[A" +key Down -Shift-AnyMod+Ansi-AppCuKeys : "\E[B" +key Right -Shift-AnyMod+Ansi-AppCuKeys : "\E[C" +key Left -Shift-AnyMod+Ansi-AppCuKeys : "\E[D" + +key Up -Shift+AnyMod+Ansi : "\E[1;*A" +key Down -Shift+AnyMod+Ansi : "\E[1;*B" +key Right -Shift+AnyMod+Ansi : "\E[1;*C" +key Left -Shift+AnyMod+Ansi : "\E[1;*D" + +# other grey PC keys + +key Enter+NewLine : "\r\n" +key Enter-NewLine : "\r" + +key Home -AnyMod -AppCuKeys : "\E[H" +key End -AnyMod -AppCuKeys : "\E[F" +key Home -AnyMod +AppCuKeys : "\EOH" +key End -AnyMod +AppCuKeys : "\EOF" +key Home +AnyMod : "\E[1;*H" +key End +AnyMod : "\E[1;*F" + +key Insert -AnyMod : "\E[2~" +key Delete -AnyMod : "\E[3~" +key Insert +AnyMod : "\E[2;*~" +key Delete +AnyMod : "\E[3;*~" + +key Prior -Shift-AnyMod : "\E[5~" +key Next -Shift-AnyMod : "\E[6~" +key Prior -Shift+AnyMod : "\E[5;*~" +key Next -Shift+AnyMod : "\E[6;*~" + +# Function keys +key F1 -AnyMod : "\EOP" +key F2 -AnyMod : "\EOQ" +key F3 -AnyMod : "\EOR" +key F4 -AnyMod : "\EOS" +key F5 -AnyMod : "\E[15~" +key F6 -AnyMod : "\E[17~" +key F7 -AnyMod : "\E[18~" +key F8 -AnyMod : "\E[19~" +key F9 -AnyMod : "\E[20~" +key F10 -AnyMod : "\E[21~" +key F11 -AnyMod : "\E[23~" +key F12 -AnyMod : "\E[24~" + +key F1 +AnyMod : "\EO*P" +key F2 +AnyMod : "\EO*Q" +key F3 +AnyMod : "\EO*R" +key F4 +AnyMod : "\EO*S" +key F5 +AnyMod : "\E[15;*~" +key F6 +AnyMod : "\E[17;*~" +key F7 +AnyMod : "\E[18;*~" +key F8 +AnyMod : "\E[19;*~" +key F9 +AnyMod : "\E[20;*~" +key F10 +AnyMod : "\E[21;*~" +key F11 +AnyMod : "\E[23;*~" +key F12 +AnyMod : "\E[24;*~" + +# Work around dead keys + +key Space +Control : "\x00" + +# Some keys are used by konsole to cause operations. +# The scroll* operations refer to the history buffer. + +key Up +Shift-AppScreen : scrollLineUp +key Prior +Shift-AppScreen : scrollPageUp +key Down +Shift-AppScreen : scrollLineDown +key Next +Shift-AppScreen : scrollPageDown + +#key Up +Shift : scrollLineUp +#key Prior +Shift : scrollPageUp +#key Down +Shift : scrollLineDown +#key Next +Shift : scrollPageDown + +key ScrollLock : scrollLock + +# keypad characters are not offered differently by Qt. diff -r a87fa9132b72 -r dbc43bd95477 gui/kb-layouts/linux.keytab --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/kb-layouts/linux.keytab Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,133 @@ +# [linux.keytab] Konsole Keyboard Table (Linux console keys) +# +# -------------------------------------------------------------- + +# NOT TESTED, MAY NEED SOME CLEANUPS +keyboard "Linux console" + +# -------------------------------------------------------------- +# +# This configuration table allows to customize the +# meaning of the keys. +# +# The syntax is that each entry has the form : +# +# "key" Keyname { ("+"|"-") Modename } ":" (String|Operation) +# +# Keynames are those defined in with the +# "Qt::Key_" removed. (We'd better insert the list here) +# +# Mode names are : +# +# - Shift +# - Alt +# - Control +# +# The VT100 emulation has two modes that can affect the +# sequences emitted by certain keys. These modes are +# under control of the client program. +# +# - Newline : effects Return and Enter key. +# - Application : effects Up and Down key. +# +# - Ansi : effects Up and Down key (This is for VT52, really). +# +# Operations are +# +# - scrollUpLine +# - scrollUpPage +# - scrollDownLine +# - scrollDownPage +# +# - emitSelection +# +# If the key is not found here, the text of the +# key event as provided by QT is emitted, possibly +# preceeded by ESC if the Alt key is pressed. +# +# -------------------------------------------------------------- + +key Escape : "\E" +key Tab : "\t" + +# VT100 can add an extra \n after return. +# The NewLine mode is set by an escape sequence. + +key Return-NewLine : "\r" +key Return+NewLine : "\r\n" + +# Some desperately try to save the ^H. + +key Backspace : "\x7f" +key Delete : "\E[3~" + +# These codes are for the VT52 mode of VT100 +# The Ansi mode (i.e. VT100 mode) is set by +# an escape sequence + +key Up -Shift-Ansi : "\EA" +key Down -Shift-Ansi : "\EB" +key Right-Shift-Ansi : "\EC" +key Left -Shift-Ansi : "\ED" + +# VT100 emits a mode bit together +# with the arrow keys.The AppCuKeys +# mode is set by an escape sequence. + +key Up -Shift+Ansi+AppCuKeys : "\EOA" +key Down -Shift+Ansi+AppCuKeys : "\EOB" +key Right-Shift+Ansi+AppCuKeys : "\EOC" +key Left -Shift+Ansi+AppCuKeys : "\EOD" + +key Up -Shift+Ansi-AppCuKeys : "\E[A" +key Down -Shift+Ansi-AppCuKeys : "\E[B" +key Right-Shift+Ansi-AppCuKeys : "\E[C" +key Left -Shift+Ansi-AppCuKeys : "\E[D" + +# linux functions keys F1-F5 differ from xterm + +key F1 : "\E[[A" +key F2 : "\E[[B" +key F3 : "\E[[C" +key F4 : "\E[[D" +key F5 : "\E[[E" + +key F6 : "\E[17~" +key F7 : "\E[18~" +key F8 : "\E[19~" +key F9 : "\E[20~" +key F10 : "\E[21~" +key F11 : "\E[23~" +key F12 : "\E[24~" + +key Home : "\E[1~" +key End : "\E[4~" + +key Prior -Shift : "\E[5~" +key Next -Shift : "\E[6~" +key Insert-Shift : "\E[2~" + +# Keypad-Enter. See comment on Return above. + +key Enter+NewLine : "\r\n" +key Enter-NewLine : "\r" + +key Space +Control : "\x00" + +# some of keys are used by konsole. + +key Up +Shift : scrollLineUp +key Prior +Shift : scrollPageUp +key Down +Shift : scrollLineDown +key Next +Shift : scrollPageDown + +key ScrollLock : scrollLock + +#---------------------------------------------------------- + +# keypad characters as offered by Qt +# cannot be recognized as such. + +#---------------------------------------------------------- + +# Following other strings as emitted by konsole. diff -r a87fa9132b72 -r dbc43bd95477 gui/kb-layouts/vt420pc.keytab --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/kb-layouts/vt420pc.keytab Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,163 @@ +# [vt420pc.keytab] Konsole Keyboard Table (VT420pc keys) +# adapted by ferdinand gassauer f.gassauer@aon.at +# Nov 2000 +# +################################################################ +# +# The escape sequences emmited by the +# keys Shift+F1 to Shift+F12 might not fit your needs +# +################# IMPORTANT NOTICE ############################# +# the key bindings (Kcontrol -> look and feel -> keybindgs) +# overrule the settings in this file. The key bindings might be +# changed by the user WITHOUT notification of the maintainer of +# the keytab file. Konsole will not work as expected by +# the maintainer of the keytab file. +################################################################ +# +# -------------------------------------------------------------- + +keyboard "DEC VT420 Terminal" + +# -------------------------------------------------------------- +# +# This configuration table allows to customize the +# meaning of the keys. +# +# The syntax is that each entry has the form : +# +# "key" Keyname { ("+"|"-") Modename } ":" (String|Operation) +# +# Keynames are those defined in with the +# "Qt::Key_" removed. (We'd better insert the list here) +# +# Mode names are : +# +# - Shift +# - Alt +# - Control +# +# The VT100 emulation has two modes that can affect the +# sequences emitted by certain keys. These modes are +# under control of the client program. +# +# - Newline : effects Return and Enter key. +# - Application : effects Up and Down key. +# +# - Ansi : effects Up and Down key (This is for VT52, really). +# +# Operations are +# +# - scrollUpLine +# - scrollUpPage +# - scrollDownLine +# - scrollDownPage +# +# - emitSelection +# +# If the key is not found here, the text of the +# key event as provided by QT is emitted, possibly +# preceeded by ESC if the Alt key is pressed. +# +# -------------------------------------------------------------- + +key Escape : "\E" +key Tab : "\t" +key Backtab: "\E[Z" + +# VT100 can add an extra \n after return. +# The NewLine mode is set by an escape sequence. + +key Return-NewLine : "\r" +key Return+NewLine : "\r\n" + +# Some desperately try to save the ^H. +# may be not everyone wants this + +key Backspace : "\x08" # Control H +key Delete : "\x7f" + +# These codes are for the VT420pc +# The Ansi mode (i.e. VT100 mode) is set by +# an escape sequence + +key Up -Shift-Ansi : "\EA" +key Down -Shift-Ansi : "\EB" +key Right-Shift-Ansi : "\EC" +key Left -Shift-Ansi : "\ED" + +# VT100 emits a mode bit together +# with the arrow keys.The AppCuKeys +# mode is set by an escape sequence. + +key Up -Shift+Ansi+AppCuKeys : "\EOA" +key Down -Shift+Ansi+AppCuKeys : "\EOB" +key Right-Shift+Ansi+AppCuKeys : "\EOC" +key Left -Shift+Ansi+AppCuKeys : "\EOD" + +key Up -Shift+Ansi-AppCuKeys : "\E[A" +key Down -Shift+Ansi-AppCuKeys : "\E[B" +key Right-Shift+Ansi-AppCuKeys : "\E[C" +key Left -Shift+Ansi-AppCuKeys : "\E[D" + +# function keys + +key F1 -Shift : "\E[11~" +key F2 -Shift : "\E[12~" +key F3 -Shift : "\E[13~" +key F4 -Shift : "\E[14~" +key F5 -Shift : "\E[15~" +key F6 -Shift : "\E[17~" +key F7 -Shift : "\E[18~" +key F8 -Shift : "\E[19~" +key F9 -Shift : "\E[20~" +key F10-Shift : "\E[21~" +key F11-Shift : "\E[23~" +key F12-Shift : "\E[24~" +# +# Shift F1-F12 +# +key F1 +Shift : "\E[11;2~" +key F2 +Shift : "\E[12;2~" +key F3 +Shift : "\E[13;2~" +key F4 +Shift : "\E[14;2~" +key F5 +Shift : "\E[15;2~" +key F6 +Shift : "\E[17;2~" +key F7 +Shift : "\E[18;2~" +key F8 +Shift : "\E[19;2~" +key F9 +Shift : "\E[20;2~" +key F10+Shift : "\E[21;2~" +key F11+Shift : "\E[23;2~" +key F12+Shift : "\E[24;2~" + +key Home : "\E[H" +key End : "\E[F" + +key Prior -Shift : "\E[5~" +key Next -Shift : "\E[6~" +key Insert-Shift : "\E[2~" + +# Keypad-Enter. See comment on Return above. + +key Enter+NewLine : "\r\n" +key Enter-NewLine : "\r" + +key Space +Control : "\x00" + +# some of keys are used by konsole. + +key Up +Shift : scrollLineUp +key Prior +Shift : scrollPageUp +key Down +Shift : scrollLineDown +key Next +Shift : scrollPageDown + +key ScrollLock : scrollLock + +#---------------------------------------------------------- + +# keypad characters as offered by Qt +# cannot be recognized as such. + +#---------------------------------------------------------- + +# Following other strings as emitted by konsole. diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/de-de.qm Binary file gui/languages/de-de.qm has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/de-de.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/languages/de-de.ts Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,642 @@ + + + + + FileEditorMdiSubWindow + + + + File Editor + Dateieditor + + + + Cannot read file %1: +%2. + Konnte Datei %1 nicht lesen: +%2. + + + + File loaded. + Datei geladen. + + + + Do you want to save the current file +%1 ? + Möchten Sie die Datei %1 sichern ? + + + + Cannot write file %1: +%2. + Konnte Datei %1 nicht schreiben: +%2. + + + + File %1 saved + Datei %1 gesichert + + + + &Close File + &Datei schließen + + + + &New File + &Neue Datei + + + + &Open File + &Öffne Datei + + + + &Save File + &Sichere Datei + + + + Save File &As + Sichere Datei &als + + + + &Undo + &Rückgängig + + + + &Redo + &Wiederholen + + + + &Copy + &Kopieren + + + + Cu&t + &Ausschneiden + + + + &Paste + &Einfügen + + + + &Next Bookmark + &Nächstes Bookmark + + + + Pre&vious Bookmark + &Voriges Bookmark + + + + Toggle &Bookmark + &Bookmark setzen + + + + &Run File + &Ausführen + + + + &File + &Datei + + + + &Edit + &Editieren + + + + &Run + &Ausführen + + + + FilesDockWidget + + Current Folder + Aktuelles Verzeichnis + + + + Current Directory + Aktuelles Verzeichnis + + + + Move up one directory. + Ein Verzeichnis höher wechseln. + + + + Enter the path or filename. + Geben Sie einen Pfad oder Dateinamen ein. + + + + Doubleclick a file to open it. + Führen Sie einen Doppelklick aus, um eine Datei zu öffnen. + + + + HistoryDockWidget + + + Doubleclick a command to transfer it to the terminal. + Führen Sie einen Doppelklick aus, um den Befehl in das Terminal zu übertragen. + + + + Enter text to filter the command history. + Geben Sie Text ein, um die Befehlshistorie zu filtern. + + + + Command History + Befehlshistorie + + + History updated. + Befehlshistorie aktualisiert. + + + + LexerOctaveGui + + + Default + Standard + + + + Comment + Kommentar + + + + Command + Befehl + + + + Number + Zahl + + + + Keyword + Schlüsselwort + + + + Single-quoted string + Zeichenkette in einfachen Hochkommata + + + + Operator + Operator + + + + Identifier + Bezeichner + + + + Double-quoted string + Zeichenkette in doppelten Hochkommata + + + + MainWindow + + + Opening file. + Öffne Datei. + + + + Save Workspace + Speichere Arbeitsumgebung + + + + Load Workspace + Lade Arbeitsumgebung + + + + + About Octave + Über Octave + + + + Saving data and shutting down. + Speichere Daten und schließe. + + + + View the variables in the active workspace. + Sehen Sie die Variablen ein, die sich in der aktiven Arbeitsumgebung befinden. + + + + Browse and search the command history. + Durchsuchen Sie die Befehlshistorie. + + + + Browse your files. + Durchsuchen Sie Ihre Dateien. + + + + Terminal + Terminal + + + + Enter your commands into the Octave terminal. + Geben Sie Ihre Befehle in das Octave Terminal ein. + + + + Browse the Octave documentation for help. + Durchsuchen Sie die Octave Dokumentation, um Hilfe zu erhalten. + + + + Chat + Chat + + + + Instantly chat with other Octave users for help. + Tauschen Sie sich direkt mit anderen Octave Benutzern aus, um Hilfe zu erhalten. + + + + Octave + Octave + + + + Settings + Einstellungen + + + + Exit + Beenden + + + + Interface + Oberfläche + + + + Align Windows + Fenster ausrichten + + + + + Workspace + Arbeitsumgebung + + + + History + Befehlshistorie + + + + File Browser + Dateibrowser + + + + Open New Editor Window + Neues Editorfenster öffnen + + + + Load + Laden + + + + Save + Sichern + + + + Clear + Löschen + + + + Community + Gemeinschaft + + + + Report Bug + Fehler melden + + + + Agora + Agora + + + + Octave Forge + Octave Forge + + + + About Qt + Über Qt + + + Octave Toolbar + Octave Werkzeugleiste + + + Command Window + Konsolenfenster + + + File Editor + Dateieditor + + + + Documentation + Dokumentation + + + Service + Service + + + Established link to Octave. + Verbindung zu Octave hergestellt. + + + + NumberBar + + Stop Here + Stoppe hier + + + Current Line + Aktuelle Zeile + + + Error Line + Fehlerzeile + + + + NumberedCodeEdit + + This file name is not valid. + Dieser Dateiname ist nicht gültig. + + + Octave doesn't understand this file name: + + Octave versteht diesen Dateityp nicht: + + + +Please, change it. + Do you want to save your changes? + Bitte ändern Sie dies. Möchten Sie Ihre Änderungen sichern? + + + + SettingsDialog + + + Settings + Einstellungen + + + + Chat + Char + + + + Connect to #octave on startup + Beim Start mit #octave verbinden + + + + Show message of the day + Nachricht des Tages anzeigen (MOTD) + + + + Show topic + Thema des Chatkanals anzeigen + + + + Automatically identify on NickServ + Automatisch bei NickServ identifizieren + + + + Warning: Your password will be stored in ~/.octavegui in human-readable format. Do not enter your password if you worry about security issues. + Warnung: Ihre Passwort wird unter ~/.octave-gui in einem menschenlesbaren Format gesichert. Hinterlegen Sie nicht Ihr Password, wenn Sie Bedenken über die Sicherheit haben. + + + + + Password: + Passwort: + + + + Editor + Editor + + + + Use custom file editor: + Benutzerdefinierten Editor verwenden: + + + + emacs + emacs + + + + File Browser + Dateibrowser + + + + Show filenames + Dateinamen anzeigen + + + + Show file size + Dateigröße anzeigen + + + + Show file type + Dateityp anzeigen + + + + Show date of last modification + Datum der letzten Änderung anzeigen + + + + Show hidden files + Versteckte Dateien anzeigen + + + + Alternating row colors + Alternierende Farben verwenden + + + + Network + + + + + Use proxy server + + + + + Proxy Type: + + + + + HttpProxy + + + + + Socks5Proxy + + + + + Hostname: + + + + + Port: + + + + + Username: + + + + + Reset to defaults + Standardeinstellungen wiederherstellen + + + + Export + Exportieren + + + + Import + Importieren + + + + VariablesDockWidget + + + Name + Bezeichner + + + + Type + Typ + + + + Value + Wert + + + + Workspace + Arbeitsumgebung + + + Save + Sichern + + + Load + Laden + + + Clear + Löschen + + + + Local + Lokal + + + + Global + Global + + + + Persistent + Persistent + + + + Hidden + Versteckt + + + diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/es-es.qm Binary file gui/languages/es-es.qm has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/es-es.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/languages/es-es.ts Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,576 @@ + + + + + FileEditorMdiSubWindow + + + + File Editor + Editor de archivos + + + + Cannot read file %1: +%2. + No se puede leer archivo %1: +%2. + + + + File loaded. + Archivo cargado. + + + + Do you want to save the current file +%1 ? + ¿Desea guardar archivo actual +%1 ? + + + + Cannot write file %1: +%2. + No se puede escribir archivo %1: +%2. + + + + File %1 saved + Archivo %1 guardado + + + + &Close File + &Cerrar archivo + + + + &New File + Archivo &nuevo + + + + &Open File + &Abrir archivo + + + + &Save File + &Guardar archivo + + + + Save File &As + Search for proper shortcut for this command + Guardar archivo &como + + + + &Undo + &Deshacer + + + + &Redo + &Rehacer + + + + &Copy + &Copiar + + + + Cu&t + Cor&tar + + + + &Paste + &Pegar + + + + &Next Bookmark + + + + + Pre&vious Bookmark + + + + + Toggle &Bookmark + + + + + &Run File + &Ejecutar archivo + + + + &File + &Archivo + + + + &Edit + &Editar + + + + &Run + &Ejecutar + + + + FilesDockWidget + + Current Folder + Carpeta actual + + + + Current Directory + + + + + Move up one directory. + Subir un directorio. + + + + Enter the path or filename. + Introduzca dirección o nombre de archivo. + + + + Doubleclick a file to open it. + Haga doble clic para abir archivo. + + + + HistoryDockWidget + + + Doubleclick a command to transfer it to the terminal. + Haga doble clic para transferir el comando a la terminal. + + + + Enter text to filter the command history. + Introduzca texto para filtrar el historial de comandos. + + + + Command History + Historial de comandos + + + + LexerOctaveGui + + + Default + Valores predeterminados + + + + Comment + Comentario + + + + Command + Comando + + + + Number + Número + + + + Keyword + Contraseña + + + + Single-quoted string + Cadena entre comillas simples + + + + Operator + Operador + + + + Identifier + Identificador + + + + Double-quoted string + Cadena entre comillas dobles + + + + MainWindow + + + Opening file. + Abriendo archivo. + + + + Save Workspace + Guardar espacio de trabajo + + + + Load Workspace + Cargar espacio de trabajo + + + + + About Octave + Acerca de Octave + + + + Saving data and shutting down. + Guardando datos y cerrando el sistema. + + + + View the variables in the active workspace. + Ver variables en el espacio de trabajo activo. + + + + Browse and search the command history. + Navegar y buscar en el historial de comandos. + + + + Browse your files. + Explorar sus archivos. + + + + Terminal + Terminal + + + + Enter your commands into the Octave terminal. + Introducir su comando a la terminal de Octave. + + + + Documentation + Documentación + + + + Browse the Octave documentation for help. + Consultar la documentación de Octave para obtener ayuda. + + + + Chat + Chat/conversación instantanea + + + + Instantly chat with other Octave users for help. + Coversación instantanea con otros usuarios de octave para obtener ayuda. + + + + Octave + Octave + + + + Settings + Configuración + + + + Exit + Salir + + + + Interface + Interfase + + + + Align Windows + Alinear ventanas + + + + + Workspace + Espacio de trabajo + + + + History + Historial + + + + File Browser + Explorador de archivos + + + + Open New Editor Window + Abrir nueva ventana de editor + + + + Load + Cargar + + + + Save + Guardar + + + + Clear + Limpiar + + + + Community + Comunidad + + + + Report Bug + Reportar error de software/Bug + + + + Agora + Ágora + + + + Octave Forge + Octave Forge + + + + About Qt + Acerca de Qt + + + + SettingsDialog + + + Settings + Configuración + + + + Chat + Chat/conversación instantanea + + + + Connect to #octave on startup + Conectar a #octave en el arranque + + + + Show message of the day + Mostrar mensaje del día + + + + Show topic + Mostrar tema + + + + Automatically identify on NickServ + Identificar automáticamente el NickServ + + + + Warning: Your password will be stored in ~/.octavegui in human-readable format. Do not enter your password if you worry about security issues. + Advertencia: La contraseña se guarda en ~ / octavegui en formato legible. No introduzca su contraseña en caso de que le preocupen los aspectos de seguridad. + + + + + + Password: + Contraseña: + + + + Editor + Editor + + + + Use custom file editor: + Usar editor de archivos personalizados: + + + + emacs + emacs + + + + File Browser + Explorador de archivos + + + + Show filenames + Mostrar nombres de archivos + + + + Show file size + Mostrar tamaño de archivo + + + + Show file type + Mostrar tipo de archivo + + + + Show date of last modification + Mostrar fecha de la última modificación + + + + Show hidden files + Mostrar archivos ocultos + + + + Alternating row colors + Colores alternos de filas + + + + Network + + + + + Use proxy server + + + + + Proxy Type: + + + + + HttpProxy + + + + + Socks5Proxy + + + + + Hostname: + + + + + Port: + + + + + Username: + + + + + Reset to defaults + Restaurar los valores predeterminados + + + + Export + Exportar + + + + Import + Importar + + + + VariablesDockWidget + + + Workspace + Espacio de trabajo + + + + Name + Nombre + + + + Type + Tipo + + + + Value + Valor + + + + Local + Local + + + + Global + Global + + + + Persistent + Persistente + + + + Hidden + Oculto + + + diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/generic.qm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/languages/generic.qm Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,1 @@ + + + + + FileEditorMdiSubWindow + + + + File Editor + + + + + Cannot read file %1: +%2. + + + + + File loaded. + + + + + Do you want to save the current file +%1 ? + + + + + Cannot write file %1: +%2. + + + + + File %1 saved + + + + + &Close File + + + + + &New File + + + + + &Open File + + + + + &Save File + + + + + Save File &As + + + + + &Undo + + + + + &Redo + + + + + &Copy + + + + + Cu&t + + + + + &Paste + + + + + &Next Bookmark + + + + + Pre&vious Bookmark + + + + + Toggle &Bookmark + + + + + &Run File + + + + + &File + + + + + &Edit + + + + + &Run + + + + + FilesDockWidget + + + Current Directory + + + + + Move up one directory. + + + + + Enter the path or filename. + + + + + Doubleclick a file to open it. + + + + + HistoryDockWidget + + + Doubleclick a command to transfer it to the terminal. + + + + + Enter text to filter the command history. + + + + + Command History + + + + + LexerOctaveGui + + + Default + + + + + Comment + + + + + Command + + + + + Number + + + + + Keyword + + + + + Single-quoted string + + + + + Operator + + + + + Identifier + + + + + Double-quoted string + + + + + MainWindow + + + Opening file. + + + + + Save Workspace + + + + + Load Workspace + + + + + + About Octave + + + + + Saving data and shutting down. + + + + + View the variables in the active workspace. + + + + + Browse and search the command history. + + + + + Browse your files. + + + + + Terminal + + + + + Enter your commands into the Octave terminal. + + + + + Documentation + + + + + Browse the Octave documentation for help. + + + + + Chat + + + + + Instantly chat with other Octave users for help. + + + + + Octave + + + + + Settings + + + + + Exit + + + + + Interface + + + + + Align Windows + + + + + + Workspace + + + + + History + + + + + File Browser + + + + + Open New Editor Window + + + + + Load + + + + + Save + + + + + Clear + + + + + Community + + + + + Report Bug + + + + + Agora + + + + + Octave Forge + + + + + About Qt + + + + + SettingsDialog + + + Settings + + + + + Chat + + + + + Connect to #octave on startup + + + + + Show message of the day + + + + + Show topic + + + + + Automatically identify on NickServ + + + + + Warning: Your password will be stored in ~/.octavegui in human-readable format. Do not enter your password if you worry about security issues. + + + + + + Password: + + + + + Editor + + + + + Use custom file editor: + + + + + emacs + + + + + File Browser + + + + + Show filenames + + + + + Show file size + + + + + Show file type + + + + + Show date of last modification + + + + + Show hidden files + + + + + Alternating row colors + + + + + Network + + + + + Use proxy server + + + + + Proxy Type: + + + + + HttpProxy + + + + + Socks5Proxy + + + + + Hostname: + + + + + Port: + + + + + Username: + + + + + Reset to defaults + + + + + Export + + + + + Import + + + + + VariablesDockWidget + + + Workspace + + + + + Name + + + + + Type + + + + + Value + + + + + Local + + + + + Global + + + + + Persistent + + + + + Hidden + + + + diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/pt-br.qm Binary file gui/languages/pt-br.qm has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/pt-br.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/languages/pt-br.ts Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,571 @@ + + + + + FileEditorMdiSubWindow + + + + File Editor + Editor de Arquivos + + + + Cannot read file %1: +%2. + Não foi possível ler o arquivo %1: %2. + + + + File loaded. + Arquivo carregado. + + + + Do you want to save the current file +%1 ? + Você deseja salvar o arquivo atual %1 ? + + + + Cannot write file %1: +%2. + Não foi possível escrever no arquivo %1: %2. + + + + File %1 saved + Arquivo %1 salvo + + + + &Close File + &Fechar Arquivo + + + + &New File + &Novo Arquivo + + + + &Open File + &Abrir Arquivo + + + + &Save File + &Salvar Arquivo + + + + Save File &As + Salvar Arquivo &Como + + + + &Undo + &Desfazer + + + + &Redo + &Refazer + + + + &Copy + + + + + Cu&t + + + + + &Paste + + + + + &Next Bookmark + + + + + Pre&vious Bookmark + + + + + Toggle &Bookmark + + + + + &Run File + + + + + &File + + + + + &Edit + + + + + &Run + + + + + FilesDockWidget + + Current Folder + Diretório Atual + + + + Current Directory + + + + + Move up one directory. + Subir um diretório. + + + + Enter the path or filename. + Digite o caminho ou o nome do arquivo. + + + + Doubleclick a file to open it. + Clique duas vezes num arquivo para abrí-lo. + + + + HistoryDockWidget + + + Doubleclick a command to transfer it to the terminal. + Clique duas vezes num comando para transferí-lo ao terminal. + + + + Enter text to filter the command history. + Digite um texto para filtrar o hitórico de comandos. + + + + Command History + Histórico de Comandos + + + + LexerOctaveGui + + + Default + Padrão + + + + Comment + Comentário + + + + Command + Comando + + + + Number + Número + + + + Keyword + Palavra-Chave + + + + Single-quoted string + String com aspas simples + + + + Operator + Operador + + + + Identifier + Identificador + + + + Double-quoted string + String com aspas duplas + + + + MainWindow + + + Opening file. + Abrindo arquivo. + + + + Save Workspace + Salvar ambiente de trabalho + + + + Load Workspace + Carregar ambiente de trabalho + + + + + About Octave + Sobre o Octave + + + + Saving data and shutting down. + Salvando dados e encerrando a sessão. + + + + View the variables in the active workspace. + Visualizar variáveis no ambiente de trabalho. + + + + Browse and search the command history. + Pesquise no histórico de comandos. + + + + Browse your files. + Procure seus arquivos. + + + + Terminal + Terminal + + + + Enter your commands into the Octave terminal. + Digite seus comandos no terminal do Octave. + + + + Documentation + Documentação + + + + Browse the Octave documentation for help. + Procure na documentação do Octave. + + + + Chat + Chat + + + + Instantly chat with other Octave users for help. + Converse instantaneamente com outros usuários do Octave para pedir ajuda. + + + + Octave + Octave + + + + Settings + Configurações + + + + Exit + Sair + + + + Interface + Interface + + + + Align Windows + Alinhar Janelas + + + + + Workspace + Ambiente de trabalho + + + + History + Histórico + + + + File Browser + Navegador de Arquivos + + + + Open New Editor Window + Abrir nova janela de edição + + + + Load + Carregar + + + + Save + Salvar + + + + Clear + Limpar + + + + Community + Comunidade + + + + Report Bug + Reportar Bug + + + + Agora + Agora + + + + Octave Forge + Octave Forge + + + + About Qt + Sobre o Qt + + + + SettingsDialog + + + Settings + Configurações + + + + Chat + Chat + + + + Connect to #octave on startup + Conectar ao #octave ao iniciar + + + + Show message of the day + Mostrar mensagem do dia + + + + Show topic + Mostrar tópico + + + + Automatically identify on NickServ + Identificar-se automaticamente com o NickServ + + + + Warning: Your password will be stored in ~/.octavegui in human-readable format. Do not enter your password if you worry about security issues. + Aviso: Sua senha será salva em ~/.octavegui em um formato legível. Não digite sua senha se você tem problemas com segurança. + + + + + Password: + Senha: + + + + Editor + Editor + + + + Use custom file editor: + Usar editor de arquivos personalizado: + + + + emacs + emacs + + + + File Browser + Navegador de Arquivos + + + + Show filenames + Mostrar nomes de arquivo + + + + Show file size + Mostrar tamanho do arquivo + + + + Show file type + Mostrar tipo do arquivo + + + + Show date of last modification + Mostrar data de última modificação + + + + Show hidden files + Mostrar arquivos ocultos + + + + Alternating row colors + Alternar cores das linhas + + + + Network + + + + + Use proxy server + + + + + Proxy Type: + + + + + HttpProxy + + + + + Socks5Proxy + + + + + Hostname: + + + + + Port: + + + + + Username: + + + + + Reset to defaults + Resetar ao padrão + + + + Export + Exportar + + + + Import + Importar + + + + VariablesDockWidget + + + Workspace + Ambiente de trabalho + + + + Name + Nome + + + + Type + Tipo + + + + Value + Valor + + + + Local + Local + + + + Global + Global + + + + Persistent + Persistente + + + + Hidden + Oculto + + + diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/ru-ru.qm Binary file gui/languages/ru-ru.qm has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/ru-ru.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/languages/ru-ru.ts Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,574 @@ + + + + + FileEditorMdiSubWindow + + + + File Editor + Редактор файлов + + + + Cannot read file %1: +%2. + Не удалось прочитать файл %1: +%2. + + + + File loaded. + Файл загружен. + + + + Do you want to save the current file +%1 ? + Сохранить текущий файл +%1? + + + + Cannot write file %1: +%2. + Не удалось сохранить файл %1: +%2. + + + + File %1 saved + Файл %1 сохранён + + + + &Close File + &Закрыть + + + + &New File + Созд&ать + + + + &Open File + &Открыть + + + + &Save File + &Сохранить + + + + Save File &As + Сохранить &как + + + + &Undo + О&тменить + + + + &Redo + &Повторить + + + + &Copy + &Копировать + + + + Cu&t + Вы&резать + + + + &Paste + &Вставить + + + + &Next Bookmark + С&ледующая закладка + + + + Pre&vious Bookmark + Пр&едыдущая закладка + + + + Toggle &Bookmark + &Установить/снять закладку + + + + &Run File + &Запустить файл + + + + &File + &Файл + + + + &Edit + &Правка + + + + &Run + &Запуск + + + + FilesDockWidget + + Current Folder + Текущий каталог + + + + Current Directory + Текущий каталог + + + + Move up one directory. + Перейти на уровень выше. + + + + Enter the path or filename. + Введите путь или имя файла. + + + + Doubleclick a file to open it. + Двойной щелчок по файлу откроет его. + + + + HistoryDockWidget + + + Doubleclick a command to transfer it to the terminal. + Двойной щелчок по команде перенесёт её в командную строку. + + + + Enter text to filter the command history. + Введите текст для фильтрации выполненных команд. + + + + Command History + Журнал выполненных команд + + + + LexerOctaveGui + + + Default + По умолчанию + + + + Comment + Комментарий + + + + Command + Команда + + + + Number + Число + + + + Keyword + Зарезервированное слово + + + + Single-quoted string + Строка в одинарных кавычках + + + + Operator + Оператор + + + + Identifier + Идентификатор + + + + Double-quoted string + Строка в двойных кавычках + + + + MainWindow + + + Opening file. + Открывается файл. + + + + Save Workspace + Сохранить область переменных + + + + Load Workspace + Загрузить область переменных + + + + + About Octave + Об Octave + + + + Saving data and shutting down. + Сохранить и завершить работу. + + + + View the variables in the active workspace. + Просмотр содержимого текущей области переменных. + + + + Browse and search the command history. + Просмотр и поиск в журнале выполненных команд. + + + + Browse your files. + Просмотр файлов. + + + + Terminal + Командная строка + + + + Enter your commands into the Octave terminal. + Введите команды в командной строке Octave. + + + + Documentation + Документация + + + + Browse the Octave documentation for help. + Открыть документацию по Octave. + + + + Chat + Чат + + + + Instantly chat with other Octave users for help. + Чат с пользователями Octave. + + + + Octave + Octave + + + + Settings + Параметры + + + + Exit + Выход + + + + Interface + Интерфейс + + + + Align Windows + Выровнять окна + + + + + Workspace + Область переменных + + + + History + Журнал выполненных команд + + + + File Browser + Файловый менеджер + + + + Open New Editor Window + Открыть новое окно редактора + + + + Load + Загрузить + + + + Save + Сохранить + + + + Clear + Очистить + + + + Community + Сообщество + + + + Report Bug + Сообщить об ошибке + + + + Agora + Agora + + + + Octave Forge + Octave Forge + + + + About Qt + О Qt + + + + SettingsDialog + + + Settings + Параметры + + + + Chat + Чат + + + + Connect to #octave on startup + Подключиться к #octave при запуске + + + + Show message of the day + Показывать совет дня + + + + Show topic + Показывать тему обсуждения при подключении + + + + Automatically identify on NickServ + Автоматически идентифицироваться у NickServ + + + + Warning: Your password will be stored in ~/.octavegui in human-readable format. Do not enter your password if you worry about security issues. + Предупреждение: пароль будет сохранён в ~/.octavegui обычным текстом. Не вводите пароль, если переживаете о возможных уязвимостях в безопасности приложения. + + + + + Password: + Пароль: + + + + Editor + Редактор + + + + Use custom file editor: + Выбрать редактор: + + + + emacs + emacs + + + + File Browser + Файловый менеджер + + + + Show filenames + Показывать имена файлов + + + + Show file size + Показывать размер файлов + + + + Show file type + Показывать типы файлов + + + + Show date of last modification + Показывать дату последнего изменения + + + + Show hidden files + Показывать скрытые файлы + + + + Alternating row colors + Чередующиеся цвета строк + + + + Network + + + + + Use proxy server + + + + + Proxy Type: + + + + + HttpProxy + + + + + Socks5Proxy + + + + + Hostname: + + + + + Port: + + + + + Username: + + + + + Reset to defaults + Установить параметры по умолчанию + + + + Export + Экспортировать + + + + Import + Импортировать + + + + VariablesDockWidget + + + Workspace + Область переменных + + + + Name + Идентификатор + + + + Type + Тип + + + + Value + Значение + + + + Local + Локальная + + + + Global + Глобальная + + + + Persistent + Статическая + + + + Hidden + Скрытая + + + diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/uk-ua.qm Binary file gui/languages/uk-ua.qm has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/languages/uk-ua.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/languages/uk-ua.ts Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,574 @@ + + + + + FileEditorMdiSubWindow + + + + File Editor + Редактор файлів + + + + Cannot read file %1: +%2. + Не вдалося прочитати файл %1: +%2. + + + + File loaded. + Файл завантажено. + + + + Do you want to save the current file +%1 ? + Справді зберегти поточний файл +%1? + + + + Cannot write file %1: +%2. + Не вдалося зберегти файл %1: +%2. + + + + File %1 saved + Файл %1 збережено + + + + &Close File + За&крити + + + + &New File + &Створити + + + + &Open File + &Відкрити + + + + &Save File + &Зберегти + + + + Save File &As + Зберегти &як + + + + &Undo + В&ернути + + + + &Redo + П&овторити + + + + &Copy + &Копіювати + + + + Cu&t + Виріза&ти + + + + &Paste + &Вставити + + + + &Next Bookmark + До &наступної закладки + + + + Pre&vious Bookmark + До &попередньої закладки + + + + Toggle &Bookmark + В&становити/видалити закладку + + + + &Run File + &Виконати файл + + + + &File + &Файл + + + + &Edit + &Правка + + + + &Run + &Виконання + + + + FilesDockWidget + + Current Folder + Поточний каталог + + + + Current Directory + Поточний каталог + + + + Move up one directory. + Перейти вгору деревом каталогів. + + + + Enter the path or filename. + Введіть повний шлях до файлу або назву файлу. + + + + Doubleclick a file to open it. + Подвійне клацання відкриє файл. + + + + HistoryDockWidget + + + Doubleclick a command to transfer it to the terminal. + Подвійне клацання перенесе команду до командного рядку. + + + + Enter text to filter the command history. + Введіть текст для фільтрування історії виконаних команд. + + + + Command History + Історія виконаних команд + + + + LexerOctaveGui + + + Default + Стандартні налаштування + + + + Comment + Коментар + + + + Command + Команда + + + + Number + Число + + + + Keyword + Зарезервоване слово + + + + Single-quoted string + Рядок в одинарних лапках + + + + Operator + Оператор + + + + Identifier + Ідентифікатор + + + + Double-quoted string + Рядок у подвійних лапках + + + + MainWindow + + + Opening file. + Відкривається файл. + + + + Save Workspace + Зберегти область змінних + + + + Load Workspace + Завантажити область змінних + + + + + About Octave + Про Octave + + + + Saving data and shutting down. + Зберегти дані і завершити роботу. + + + + View the variables in the active workspace. + Перегляд змісту поточної області змінних. + + + + Browse and search the command history. + Перегляд і пошук серед історії виконаних команд. + + + + Browse your files. + Переглянути файли. + + + + Terminal + Командний рядок + + + + Enter your commands into the Octave terminal. + Введіть команди до командного рядка Octave. + + + + Documentation + Документація + + + + Browse the Octave documentation for help. + Переглянути документацію до Octave. + + + + Chat + Чат + + + + Instantly chat with other Octave users for help. + Чат з користувачами Octave. + + + + Octave + Octave + + + + Settings + Налаштування + + + + Exit + Вийти + + + + Interface + Інтерфейс + + + + Align Windows + Вирівняти вікна + + + + + Workspace + Область змінних + + + + History + Історія виконаних команд + + + + File Browser + Файловий менеджер + + + + Open New Editor Window + Відкрити нове вікно редактора + + + + Load + Завантажити + + + + Save + Зберегти + + + + Clear + Очистити + + + + Community + Спільнота + + + + Report Bug + Повідомити про помилку + + + + Agora + Agora + + + + Octave Forge + Octave Forge + + + + About Qt + Про Qt + + + + SettingsDialog + + + Settings + Налаштування + + + + Chat + Чат + + + + Connect to #octave on startup + З'єднатися з #octave при запуску + + + + Show message of the day + Показувати пораду дня + + + + Show topic + Показувати тему чату при з'єднанні + + + + Automatically identify on NickServ + Автоматично ідентифікуватися в NickServ + + + + Warning: Your password will be stored in ~/.octavegui in human-readable format. Do not enter your password if you worry about security issues. + Попередження: пароль буде збережено в ~/.octavegui звичайним текстом. Не вводьте пароль, якщо переймаєтесь потенційними проблемами із захистом даних в програмі. + + + + + Password: + Пароль: + + + + Editor + Редактор + + + + Use custom file editor: + Використовувати інший редактор: + + + + emacs + emacs + + + + File Browser + Файловий менеджер + + + + Show filenames + Показувати назви файлів + + + + Show file size + Показувати розмір файлів + + + + Show file type + Показувати типи файлів + + + + Show date of last modification + Показувати дату останньої зміни + + + + Show hidden files + Показувати приховані файли + + + + Alternating row colors + Чергувати колір рядків + + + + Network + + + + + Use proxy server + + + + + Proxy Type: + + + + + HttpProxy + + + + + Socks5Proxy + + + + + Hostname: + + + + + Port: + + + + + Username: + + + + + Reset to defaults + Встановити стандартні налаштування + + + + Export + Експортувати + + + + Import + Імпортувати + + + + VariablesDockWidget + + + Workspace + Область змінних + + + + Name + Ідентифікатор + + + + Type + Тип + + + + Value + Значення + + + + Local + Локальна + + + + Global + Глобальна + + + + Persistent + Статична + + + + Hidden + Прихована + + + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/Makefile.am Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,223 @@ +SRCDIRS = \ + m-editor \ + qtinfo \ + octave-adapter \ + ../qterminal/libqterminal/unix \ + ../qterminal/libqterminal/win32 \ + ../qterminal/libqterminal \ + ../qterminal + +moc-%.cc: %.h + test -d $(@D) || mkdir -p $(@D) + @MOC@ -o$@ $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liboctgui_la_CPPFLAGS) $< + +ui-%.h: %.ui + @UIC@ -o $@ $< + +qrc-%.cc: %.qrc + @RCC@ -o $@ $< + +octave_gui_MOC = \ + m-editor/moc-file-editor-interface.cc \ + m-editor/moc-file-editor-tab.cc \ + m-editor/moc-file-editor.cc \ + m-editor/moc-find-dialog.cc \ + m-editor/moc-lexer-octave-gui.cc \ + moc-documentation-dockwidget.cc \ + moc-files-dockwidget.cc \ + moc-history-dockwidget.cc \ + moc-main-window.cc \ + moc-octave-qt-event-listener.cc \ + moc-settings-dialog.cc \ + moc-terminal-dockwidget.cc \ + moc-welcome-wizard.cc \ + moc-workspace-model.cc \ + moc-workspace-view.cc \ + octave-adapter/moc-octave-main-thread.cc \ + qtinfo/moc-parser.cc \ + qtinfo/moc-webinfo.cc + +octave_gui_UI = \ + settings-dialog.ui \ + welcome-wizard.ui + +octave_gui_UI_H = $(patsubst %.ui, ui-%.h, $(octave_gui_UI)) + +octave_gui_RC = qrc-resource.cc + +octlib_LTLIBRARIES = liboctgui.la + +liboctgui_la_SOURCES = \ + documentation-dockwidget.cc \ + files-dockwidget.cc \ + history-dockwidget.cc \ + m-editor/file-editor-tab.cc \ + m-editor/file-editor.cc \ + m-editor/find-dialog.cc \ + m-editor/lexer-octave-gui.cc \ + main-window.cc \ + octave-adapter/octave-event.cc \ + octave-adapter/octave-link.cc \ + octave-adapter/octave-main-thread.cc \ + octave-gui.cc \ + octave-qt-event-listener.cc \ + qtinfo/parser.cc \ + qtinfo/webinfo.cc \ + resource-manager.cc \ + settings-dialog.cc \ + symbol-information.cc \ + terminal-dockwidget.cc \ + welcome-wizard.cc \ + workspace-model.cc \ + workspace-view.cc + +liboctgui_la_LIBADD = \ + libqterminal.la \ + -lQtCore \ + -lQtGui \ + -lQtNetwork \ + -lqscintilla2 + +nodist_liboctgui_la_SOURCES = $(octave_gui_MOC) $(octave_gui_RC) + +liboctgui_la_CPPFLAGS = \ + -I@QT_INCDIR@ \ + -I@QT_INCDIR@/QtCore \ + -I@QT_INCDIR@/QtGui \ + -I@QT_INCDIR@/QtNetwork \ + -I$(srcdir)/../qterminal/libqterminal \ + -I$(srcdir)/m-editor \ + -I$(srcdir)/octave-adapter \ + -I$(srcdir)/qtinfo \ + -I$(srcdir)/../../libcruft/misc \ + -I../../liboctave \ + -I$(srcdir)/../../liboctave \ + -I../../src \ + -I../../src/interp-core \ + -I../../src/interpfcn \ + -I../../src/parse-tree \ + -I$(srcdir)/../../src \ + -I$(srcdir)/../../src/interp-core \ + -I$(srcdir)/../../src/interpfcn \ + -I$(srcdir)/../../src/octave-value \ + -I$(srcdir)/../../src/operators \ + -I$(srcdir)/../../src/parse-tree + +liboctgui_la_LDFLAGS = -L@QT_LIBDIR@ + +noinst_HEADERS = \ + documentation-dockwidget.h \ + files-dockwidget.h \ + history-dockwidget.h \ + m-editor/file-editor-interface.h \ + m-editor/file-editor-tab.h \ + m-editor/file-editor.h \ + m-editor/find-dialog.h \ + m-editor/lexer-octave-gui.h \ + main-window.h \ + octave-adapter/octave-event-listener.h \ + octave-adapter/octave-event-observer.h \ + octave-adapter/octave-event.h \ + octave-adapter/octave-link.h \ + octave-adapter/octave-main-thread.h \ + octave-qt-event-listener.h \ + qtinfo/parser.h \ + qtinfo/webinfo.h \ + resource-manager.h \ + settings-dialog.h \ + symbol-information.h \ + terminal-dockwidget.h \ + welcome-wizard.h \ + workspace-model.h \ + workspace-view.h + +CLEANFILES = $(octave_gui_MOC) $(octave_gui_UI_H) $(octave_gui_RC) + +clean-local: + -if test "$(srcdir)" != "."; then \ + for d in $(SRCDIRS); do test -d $$d && rmdir $$d; done \ + fi + +BUILT_SOURCES = $(octave_gui_UI_H) + +EXTRA_DIST = $(octave_gui_UI) resource.qrc + +noinst_LTLIBRARIES = libqterminal.la + +noinst_HEADERS += ../qterminal/libqterminal/QTerminal.h \ + ../qterminal/libqterminal/QTerminalInterface.h \ + ../qterminal/libqterminal/win32/QTerminalColors.h \ + ../qterminal/libqterminal/win32/QWinTerminalImpl.h \ + ../qterminal/libqterminal/unix/BlockArray.h \ + ../qterminal/libqterminal/unix/Character.h \ + ../qterminal/libqterminal/unix/CharacterColor.h \ + ../qterminal/libqterminal/unix/Emulation.h \ + ../qterminal/libqterminal/unix/ExtendedDefaultTranslator.h \ + ../qterminal/libqterminal/unix/Filter.h \ + ../qterminal/libqterminal/unix/History.h \ + ../qterminal/libqterminal/unix/KeyboardTranslator.h \ + ../qterminal/libqterminal/unix/konsole_wcwidth.h \ + ../qterminal/libqterminal/unix/kpty.h \ + ../qterminal/libqterminal/unix/kpty_p.h \ + ../qterminal/libqterminal/unix/LineFont.h \ + ../qterminal/libqterminal/unix/QUnixTerminalImpl.h \ + ../qterminal/libqterminal/unix/Screen.h \ + ../qterminal/libqterminal/unix/ScreenWindow.h \ + ../qterminal/libqterminal/unix/TerminalCharacterDecoder.h \ + ../qterminal/libqterminal/unix/Vt102Emulation.h \ + ../qterminal/libqterminal/unix/SelfListener.h \ + ../qterminal/libqterminal/unix/TerminalModel.h \ + ../qterminal/libqterminal/unix/TerminalView.h + +libqterminal_la_CPPFLAGS = $(DEFS) \ + -I@QT_INCDIR@ \ + -I@QT_INCDIR@/QtCore \ + -I@QT_INCDIR@/QtGui \ + -I$(srcdir)/../qterminal/libqterminal + +libqterminal_la_MOC = \ + ../qterminal/libqterminal/moc-QTerminal.cc \ + ../qterminal/libqterminal/moc-QTerminalInterface.cc + +nodist_libqterminal_la_SOURCES = $(libqterminal_la_MOC) + +if WIN32_TERMINAL + +libqterminal_la_SOURCES = \ + ../qterminal/libqterminal/win32/QTerminalColors.cpp \ + ../qterminal/libqterminal/win32/QWinTerminalImpl.cpp + +libqterminal_la_MOC += ../qterminal/libqterminal/win32/moc-QWinTerminalImpl.cc + +else + +libqterminal_la_SOURCES = \ + ../qterminal/libqterminal/unix/BlockArray.cpp \ + ../qterminal/libqterminal/unix/Emulation.cpp \ + ../qterminal/libqterminal/unix/Filter.cpp \ + ../qterminal/libqterminal/unix/History.cpp \ + ../qterminal/libqterminal/unix/KeyboardTranslator.cpp \ + ../qterminal/libqterminal/unix/konsole_wcwidth.cpp \ + ../qterminal/libqterminal/unix/kpty.cpp \ + ../qterminal/libqterminal/unix/QUnixTerminalImpl.cpp \ + ../qterminal/libqterminal/unix/Screen.cpp \ + ../qterminal/libqterminal/unix/ScreenWindow.cpp \ + ../qterminal/libqterminal/unix/TerminalCharacterDecoder.cpp \ + ../qterminal/libqterminal/unix/Vt102Emulation.cpp \ + ../qterminal/libqterminal/unix/SelfListener.cpp \ + ../qterminal/libqterminal/unix/TerminalModel.cpp \ + ../qterminal/libqterminal/unix/TerminalView.cpp + +libqterminal_la_MOC += \ + ../qterminal/libqterminal/unix/moc-Emulation.cc \ + ../qterminal/libqterminal/unix/moc-Filter.cc \ + ../qterminal/libqterminal/unix/moc-QUnixTerminalImpl.cc \ + ../qterminal/libqterminal/unix/moc-ScreenWindow.cc \ + ../qterminal/libqterminal/unix/moc-SelfListener.cc \ + ../qterminal/libqterminal/unix/moc-TerminalModel.cc \ + ../qterminal/libqterminal/unix/moc-TerminalView.cc \ + ../qterminal/libqterminal/unix/moc-Vt102Emulation.cc + +endif + +CLEANFILES += $(libqterminal_la_MOC) diff -r a87fa9132b72 -r dbc43bd95477 gui/src/documentation-dockwidget.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/documentation-dockwidget.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,45 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "documentation-dockwidget.h" + +documentation_dock_widget::documentation_dock_widget (QWidget *parent) + : QDockWidget (parent) +{ + setObjectName ("DocumentationDockWidget"); + setWindowTitle (tr ("Documentation")); + + connect (this, SIGNAL (visibilityChanged (bool)), + this, SLOT (handle_visibility_changed (bool))); + + _webinfo = new webinfo (this); + setWidget (_webinfo); +} + +void +documentation_dock_widget::handle_visibility_changed (bool visible) +{ + if (visible) + emit active_changed (true); +} + +void +documentation_dock_widget::closeEvent (QCloseEvent *event) +{ + emit active_changed (false); + QDockWidget::closeEvent (event); +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/documentation-dockwidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/documentation-dockwidget.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,46 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef DOCUMENTATIONDOCKWIDGET_H +#define DOCUMENTATIONDOCKWIDGET_H + +#include +#include +#include "webinfo.h" + +class documentation_dock_widget : public QDockWidget +{ + Q_OBJECT +public: + documentation_dock_widget (QWidget *parent = 0); + +public slots: + /** Slot to steer changing visibility from outside. */ + void handle_visibility_changed (bool visible); + +signals: + /** Custom signal that tells if a user has clicked away that dock widget. */ + void active_changed (bool active); + +protected: + void closeEvent (QCloseEvent *event); + +private: + webinfo *_webinfo; +}; + +#endif // DOCUMENTATIONDOCKWIDGET_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/files-dockwidget.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/files-dockwidget.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,185 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "resource-manager.h" +#include "files-dockwidget.h" + +#include +#include +#include +#include +#include +#include + +files_dock_widget::files_dock_widget (QWidget *parent) + : QDockWidget (parent) +{ + setObjectName ("FilesDockWidget"); + setWindowTitle (tr ("Current Directory")); + setWidget (new QWidget (this)); + + // Create a toolbar + _navigation_tool_bar = new QToolBar ("", widget ()); + _navigation_tool_bar->setAllowedAreas (Qt::TopToolBarArea); + _navigation_tool_bar->setMovable (false); + _navigation_tool_bar->setIconSize (QSize (20, 20)); + + _directory_icon = QIcon(":/actions/icons/up.png"); + _directory_up_action = new QAction (_directory_icon, "", _navigation_tool_bar); + _directory_up_action->setStatusTip (tr ("Move up one directory.")); + + _last_current_directory = ""; + _current_directory = new QLineEdit (_navigation_tool_bar); + _current_directory->setStatusTip (tr ("Enter the path or filename.")); + + _navigation_tool_bar->addAction (_directory_up_action); + _navigation_tool_bar->addWidget (_current_directory); + connect (_directory_up_action, SIGNAL (triggered ()), this, + SLOT (do_up_directory ())); + + // TODO: Add other buttons for creating directories + + // Create the QFileSystemModel starting in the home directory + QString homePath = QDir::homePath (); + + _file_system_model = new QFileSystemModel (this); + _file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries); + QModelIndex rootPathIndex = _file_system_model->setRootPath (homePath); + + // Attach the model to the QTreeView and set the root index + _file_tree_view = new QTreeView (widget ()); + _file_tree_view->setModel (_file_system_model); + _file_tree_view->setRootIndex (rootPathIndex); + _file_tree_view->setSortingEnabled (true); + _file_tree_view->setAlternatingRowColors (true); + _file_tree_view->setAnimated (true); + _file_tree_view->setColumnHidden (1, true); + _file_tree_view->setColumnHidden (2, true); + _file_tree_view->setColumnHidden (3, true); + _file_tree_view->setStatusTip (tr ("Doubleclick a file to open it.")); + + _current_directory->setText(_file_system_model->fileInfo (rootPathIndex). + absoluteFilePath ()); + + connect (_file_tree_view, SIGNAL (doubleClicked (const QModelIndex &)), this, + SLOT (item_double_clicked (const QModelIndex &))); + + // Layout the widgets vertically with the toolbar on top + QVBoxLayout * + layout = new QVBoxLayout (); + layout->setSpacing (0); + layout->addWidget (_navigation_tool_bar); + layout->addWidget (_file_tree_view); + layout->setMargin (1); + widget ()->setLayout (layout); + // TODO: Add right-click contextual menus for copying, pasting, deleting files (and others) + + connect (_current_directory, SIGNAL (returnPressed ()), + this, SLOT (handle_directory_entered ())); + + QCompleter * + completer = new QCompleter (_file_system_model, this); + _current_directory->setCompleter (completer); + + connect (this, SIGNAL (visibilityChanged (bool)), + this, SLOT (handle_visibility_changed (bool))); + + setFocusProxy (_current_directory); +} + +void +files_dock_widget::item_double_clicked (const QModelIndex & index) +{ + // Retrieve the file info associated with the model index. + QFileInfo fileInfo = _file_system_model->fileInfo (index); + display_directory (fileInfo.absoluteFilePath ()); +} + +void +files_dock_widget::set_current_directory (QString currentDirectory) +{ + display_directory (currentDirectory); +} + +void +files_dock_widget::handle_directory_entered () +{ + display_directory (_current_directory->text ()); +} + +void +files_dock_widget::do_up_directory () +{ + QDir dir = QDir (_file_system_model->filePath (_file_tree_view->rootIndex ())); + dir.cdUp (); + display_directory (dir.absolutePath ()); +} + +void +files_dock_widget::display_directory (QString directory) +{ + QFileInfo fileInfo (directory); + if (fileInfo.exists ()) + { + if (fileInfo.isDir ()) + { + _file_tree_view->setRootIndex (_file_system_model-> + index (fileInfo.absoluteFilePath ())); + _file_system_model->setRootPath (fileInfo.absoluteFilePath ()); + _current_directory->setText (fileInfo.absoluteFilePath ()); + + if (_last_current_directory != fileInfo.absoluteFilePath ()) + { + emit displayed_directory_changed (fileInfo.absoluteFilePath ()); + } + + _last_current_directory = fileInfo.absoluteFilePath (); + } + else + { + if (QFile::exists (fileInfo.absoluteFilePath ())) + emit open_file (fileInfo.absoluteFilePath ()); + } + } +} + +void +files_dock_widget::notice_settings () +{ + QSettings *settings = resource_manager::instance ()->get_settings (); + _file_tree_view->setColumnHidden (0, !settings->value ("showFilenames").toBool ()); + _file_tree_view->setColumnHidden (1, !settings->value ("showFileSize").toBool ()); + _file_tree_view->setColumnHidden (2, !settings->value ("showFileType").toBool ()); + _file_tree_view->setColumnHidden (3, !settings->value ("showLastModified").toBool ()); + _file_tree_view->setAlternatingRowColors (settings->value ("useAlternatingRowColors").toBool ()); + //if (settings.value ("showHiddenFiles").toBool ()) + // TODO: React on option for hidden files. +} + +void +files_dock_widget::handle_visibility_changed (bool visible) +{ + if (visible) + emit active_changed (true); +} + +void +files_dock_widget::closeEvent (QCloseEvent *event) +{ + emit active_changed (false); + QDockWidget::closeEvent (event); +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/files-dockwidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/files-dockwidget.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,102 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef FILESDOCKWIDGET_H +#define FILESDOCKWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/** + \class files_dock_widget + \brief Dock widget to display files in the current directory. + */ +class files_dock_widget : public QDockWidget +{ + Q_OBJECT +public: + /** Constructs a new files_dock_widget. */ + files_dock_widget (QWidget *parent = 0); + +public slots: + /** Slot for handling a change in directory via double click. */ + void item_double_clicked (const QModelIndex & index); + + /** Slot for handling the up-directory button in the toolbar. */ + void do_up_directory (); + + /** Sets the current directory being displayed. */ + void set_current_directory (QString currentDirectory); + + /** Accepts user input a the line edit for the current directory. */ + void handle_directory_entered (); + + void display_directory (QString directory); + + /** Tells the widget to react on changed settings. */ + void notice_settings (); + + /** Slot to steer changing visibility from outside. */ + void handle_visibility_changed (bool visible); + +signals: + /** Emitted, whenever the user requested to open a file. */ + void open_file (QString fileName); + + /** Emitted, whenever the currently displayed directory changed. */ + void displayed_directory_changed (QString directory); + + /** Custom signal that tells if a user has clicke away that dock widget. */ + void active_changed (bool active); + +protected: + void closeEvent (QCloseEvent *event); + +private: + // TODO: Add toolbar with buttons for navigating the path, creating dirs, etc + + QString _last_current_directory; + + /** Toolbar for file and directory manipulation. */ + QToolBar * _navigation_tool_bar; + + /** Variables for the up-directory action. */ + QIcon _directory_icon; + QAction * _directory_up_action; + QToolButton * _up_directory_button; + + /** The file system model. */ + QFileSystemModel *_file_system_model; + + /** The file system view. */ + QTreeView * _file_tree_view; + QLineEdit * _current_directory; +}; + +#endif // FILESDOCKWIDGET_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/history-dockwidget.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/history-dockwidget.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,151 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "cmd-hist.h" + +#include "history-dockwidget.h" + +history_dock_widget::history_dock_widget (QWidget * parent) + : QDockWidget (parent), octave_event_observer () +{ + setObjectName ("HistoryDockWidget"); + construct (); +} + +void +history_dock_widget::event_accepted (octave_event *e) +{ + if (dynamic_cast (e)) + { + // Determine the client's (our) history length and the one of the server. + int clientHistoryLength = _history_model->rowCount (); + int serverHistoryLength = command_history::length (); + + // If were behind the server, iterate through all new entries and add + // them to our history. + if (clientHistoryLength < serverHistoryLength) + { + for (int i = clientHistoryLength; i < serverHistoryLength; i++) + { + _history_model->insertRow (0); + _history_model->setData (_history_model->index (0), + QString (command_history::get_entry (i).c_str ())); + } + } + } + + // Post a new update event in a given time. This prevents flooding the + // event queue. + _update_history_model_timer.start (); + delete e; +} + +void +history_dock_widget::event_reject (octave_event *e) +{ + delete e; +} + +void +history_dock_widget::construct () +{ + _history_model = new QStringListModel (); + _sort_filter_proxy_model.setSourceModel (_history_model); + _history_list_view = new QListView (this); + _history_list_view->setModel (&_sort_filter_proxy_model); + _history_list_view->setAlternatingRowColors (true); + _history_list_view->setEditTriggers (QAbstractItemView::NoEditTriggers); + _history_list_view->setStatusTip (tr ("Doubleclick a command to transfer it to the terminal.")); + _filter_line_edit = new QLineEdit (this); + _filter_line_edit->setStatusTip (tr ("Enter text to filter the command history.")); + QVBoxLayout *layout = new QVBoxLayout (); + + setWindowTitle (tr ("Command History")); + setWidget (new QWidget ()); + + layout->addWidget (_history_list_view); + layout->addWidget (_filter_line_edit); + layout->setMargin (2); + + widget ()->setLayout (layout); + + connect (_filter_line_edit, + SIGNAL (textEdited (QString)), + &_sort_filter_proxy_model, + SLOT (setFilterWildcard (QString))); + + connect (_history_list_view, + SIGNAL (doubleClicked (QModelIndex)), + this, + SLOT (handle_double_click (QModelIndex))); + + connect (this, + SIGNAL (visibilityChanged (bool)), + this, + SLOT (handle_visibility_changed (bool))); + + _update_history_model_timer.setInterval (200); + _update_history_model_timer.setSingleShot (true); + + connect (&_update_history_model_timer, + SIGNAL (timeout ()), + this, + SLOT (request_history_model_update ())); + + _update_history_model_timer.start (); + + setFocusProxy (_filter_line_edit); +} + +void +history_dock_widget::handle_double_click (QModelIndex modelIndex) +{ + emit command_double_clicked (modelIndex.data().toString()); +} + +void +history_dock_widget::handle_visibility_changed (bool visible) +{ + if (visible) + emit active_changed (true); +} + +void +history_dock_widget::request_history_model_update () +{ + octave_link::instance () + ->post_event (new octave_update_history_event (*this)); +} + +void +history_dock_widget::reset_model () +{ + _history_model->setStringList (QStringList ()); +} + +void +history_dock_widget::closeEvent (QCloseEvent *event) +{ + emit active_changed (false); + QDockWidget::closeEvent (event); +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/history-dockwidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/history-dockwidget.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,70 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef HISTORYDOCKWIDGET_H +#define HISTORYDOCKWIDGET_H + +#include +#include +#include +#include +#include +#include + +#include "octave-link.h" +#include "octave-event-observer.h" + +class history_dock_widget : public QDockWidget, public octave_event_observer +{ +Q_OBJECT +public: + history_dock_widget (QWidget *parent = 0); + + void event_accepted (octave_event *e); + void event_reject (octave_event *e); + +public slots: + void handle_visibility_changed (bool visible); + void request_history_model_update (); + void reset_model (); + +signals: + void information (QString message); + + /** Emitted, whenever the user double-clicked a command in the history. */ + void command_double_clicked (QString command); + + /** Custom signal that tells if a user has clicked away that dock widget. */ + void active_changed (bool active); +protected: + void closeEvent (QCloseEvent *event); +private slots: + void handle_double_click (QModelIndex modelIndex); + +private: + void construct (); + QListView *_history_list_view; + QLineEdit *_filter_line_edit; + QSortFilterProxyModel _sort_filter_proxy_model; + + /** Stores the current history_model. */ + QStringListModel *_history_model; + + QTimer _update_history_model_timer; +}; + +#endif // HISTORYDOCKWIDGET_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/arrow_right.png Binary file gui/src/icons/arrow_right.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/artsbuilderexecute.png Binary file gui/src/icons/artsbuilderexecute.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/bookmark.png Binary file gui/src/icons/bookmark.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/bp_next.png Binary file gui/src/icons/bp_next.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/bp_prev.png Binary file gui/src/icons/bp_prev.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/bp_rm_all.png Binary file gui/src/icons/bp_rm_all.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/bp_toggle.png Binary file gui/src/icons/bp_toggle.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/chat.png Binary file gui/src/icons/chat.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/configure.png Binary file gui/src/icons/configure.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/db_cont.png Binary file gui/src/icons/db_cont.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/db_step.png Binary file gui/src/icons/db_step.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/db_step_in.png Binary file gui/src/icons/db_step_in.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/db_step_out.png Binary file gui/src/icons/db_step_out.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/db_stop.png Binary file gui/src/icons/db_stop.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/editcopy.png Binary file gui/src/icons/editcopy.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/editcut.png Binary file gui/src/icons/editcut.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/editpaste.png Binary file gui/src/icons/editpaste.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/filenew.png Binary file gui/src/icons/filenew.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/fileopen.png Binary file gui/src/icons/fileopen.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/filesave.png Binary file gui/src/icons/filesave.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/filesaveas.png Binary file gui/src/icons/filesaveas.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/find.png Binary file gui/src/icons/find.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/help_index.png Binary file gui/src/icons/help_index.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/icons_license --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/icons/icons_license Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,323 @@ +Icons license for: chat.png help_index.png terminal.png +jabber_protocol.png + +by http://www.everaldo.com/ on 17.07.2011: + +The Crystal Project are released under LGPL. GNU General Public License. + +This License Agreement applies to any software library or other program +which contains a notice placed by the copyright holder or other +authorized party saying it may be distributed under the terms of this +Lesser General Public License (also called "this License"). Each +licensee is addressed as "you". + +A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which +has been distributed under these terms. A "work based on the Library" +means either the Library or any derivative work under copyright law: +that is to say, a work containing the Library or a portion of it, either +verbatim or with modifications and/or translated straightforwardly into +another language. (Hereinafter, translation is included without +limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making +modifications to it. For a library, complete source code means all the +source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and +installation of the library. + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of running +a program using the Library is not restricted, and output from such a +program is covered only if its contents constitute a work based on the +Library (independent of the use of the Library in a tool for writing +it). Whether that is true depends on what the Library does and what the +program that uses the Library does. + +You may copy and distribute verbatim copies of the Library's complete +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the notices +that refer to this License and to the absence of any warranty; and +distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +You may modify your copy or copies of the Library or any portion of it, +thus forming a work based on the Library, and copy and distribute such +modifications or work under the terms of Section 1 above, provided that +you also meet all of these conditions: + +The modified work must itself be a software library. You must cause the +files modified to carry prominent notices stating that you changed the +files and the date of any change. You must cause the whole of the work +to be licensed at no charge to all third parties under the terms of this +License. If a facility in the modified Library refers to a function or a +table of data to be supplied by an application program that uses the +facility, other than as an argument passed when the facility is invoked, +then you must make a good faith effort to ensure that, in the event an +application does not supply such function or table, the facility still +operates, and performs whatever part of its purpose remains meaningful. +(For example, a function in a library to compute square roots has a +purpose that is entirely well-defined independent of the application. +Therefore, Subsection 2d requires that any application-supplied function +or table used by this function must be optional: if the application does +not supply it, the square root function must still compute square +roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, and +can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based on +the Library, the distribution of the whole must be on the terms of this +License, whose permissions for other licensees extend to the entire +whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of a +storage or distribution medium does not bring the other work under the +scope of this License. + +You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so that +they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in these +notices. + +Once this change is made in a given copy, it is irreversible for that +copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the +Library into a program that is not a library. + +You may copy and distribute the Library (or a portion or derivative of +it, under Section 2) in object code or executable form under the terms +of Sections 1 and 2 above provided that you accompany it with the +complete corresponding machine-readable source code, which must be +distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a +designated place, then offering equivalent access to copy the source +code from the same place satisfies the requirement to distribute the +source code, even though third parties are not compelled to copy the +source along with the object code. + +A program that contains no derivative of any portion of the Library, but +is designed to work with the Library by being compiled or linked with +it, is called a "work that uses the Library". Such a work, in isolation, +is not a derivative work of the Library, and therefore falls outside the +scope of this License. + +However, linking a "work that uses the Library" with the Library creates +an executable that is a derivative of the Library (because it contains +portions of the Library), rather than a "work that uses the library". +The executable is therefore covered by this License. Section 6 states +terms for distribution of such executables. When a "work that uses the +Library" uses material from a header file that is part of the Library, +the object code for the work may be a derivative work of the Library +even though the source code is not. Whether this is true is especially +significant if the work can be linked without the Library, or if the +work is itself a library. The threshold for this to be true is not +precisely defined by law. + +If such an object file uses only numerical parameters, data structure +layouts and accessors, and small macros and small inline functions (ten +lines or less in length), then the use of the object file is +unrestricted, regardless of whether it is legally a derivative work. +(Executables containing this object code plus portions of the Library +will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, whether +or not they are linked directly with the Library itself. + +As an exception to the Sections above, you may also combine or link a +"work that uses the Library" with the Library to produce a work +containing portions of the Library, and distribute that work under terms +of your choice, provided that the terms permit modification of the work +for the customer's own use and reverse engineering for debugging such +modifications. + +You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work during +execution displays copyright notices, you must include the copyright +notice for the Library among them, as well as a reference directing the +user to the copy of this License. Also, you must do one of these things: + +Accompany the work with the complete corresponding machine-readable +source code for the Library including whatever changes were used in the +work (which must be distributed under Sections 1 and 2 above); and, if +the work is an executable linked with the Library, with the complete +machine-readable "work that uses the Library", as object code and/or +source code, so that the user can modify the Library and then relink to +produce a modified executable containing the modified Library. (It is +understood that the user who changes the contents of definitions files +in the Library will not necessarily be able to recompile the application +to use the modified definitions.) . Use a suitable shared library +mechanism for linking with the Library. A suitable mechanism is one that +(1) uses at run time a copy of the library already present on the user's +computer system, rather than copying library functions into the +executable, and (2) will operate properly with a modified version of the +library, if the user installs one, as long as the modified version is +interface-compatible with the version that the work was made with. +Accompany the work with a written offer, valid for at least three years, +to give the same user the materials specified in Subsection 6a, above, +for a charge no more than the cost of performing this distribution. If +distribution of the work is made by offering access to copy from a +designated place, offer equivalent access to copy the above specified +materials from the same place. Verify that the user has already received +a copy of these materials or that you have already sent this user a +copy. For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, the +materials to be distributed need not include anything that is normally +distributed (in either source or binary form) with the major components +(compiler, kernel, and so on) of the operating system on which the +executable runs, unless that component itself accompanies the +executable. + +It may happen that this requirement contradicts the license restrictions +of other proprietary libraries that do not normally accompany the +operating system. Such a contradiction means you cannot use both them +and the Library together in an executable that you distribute. + +You may place library facilities that are a work based on the Library +side-by-side in a single library together with other library facilities +not covered by this License, and distribute such a combined library, +provided that the separate distribution of the work based on the Library +and of the other library facilities is otherwise permitted, and provided +that you do these two things: + +Accompany the combined library with a copy of the same work based on the +Library, uncombined with any other library facilities. This must be +distributed under the terms of the Sections above. + +Give prominent notice with the combined library of the fact that part of +it is a work based on the Library, and explaining where to find the +accompanying uncombined form of the same work. + +You may not copy, modify, sublicense, link with, or distribute the +Library except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, link with, or distribute the +Library is void, and will automatically terminate your rights under this +License. However, parties who have received copies, or rights, from you +under this License will not have their licenses terminated so long as +such parties remain in full compliance. + +You are not required to accept this License, since you have not signed +it. However, nothing else grants you permission to modify or distribute +the Library or its derivative works. These actions are prohibited by law +if you do not accept this License. Therefore, by modifying or +distributing the Library (or any work based on the Library), you +indicate your acceptance of this License to do so, and all its terms and +conditions for copying, distributing or modifying the Library or works +based on it. + +Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + +If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot distribute +so as to satisfy simultaneously your obligations under this License and +any other pertinent obligations, then as a consequence you may not +distribute the Library at all. For example, if a patent license would +not permit royalty-free redistribution of the Library by all those who +receive copies directly or indirectly through you, then the only way you +could satisfy both it and this License would be to refrain entirely from +distribution of the Library. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply, and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is implemented +by public license practices. Many people have made generous +contributions to the wide range of software distributed through that +system in reliance on consistent application of that system; it is up to +the author/donor to decide if he or she is willing to distribute +software through any other system and a licensee cannot impose that +choice. + +This section is intended to make thoroughly clear what is believed to be +a consequence of the rest of this License. + +If the distribution and/or use of the Library is restricted in certain +countries either by patents or by copyrighted interfaces, the original +copyright holder who places the Library under this License may add an +explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + +The Free Software Foundation may publish revised and/or new versions of +the Lesser General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in +detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a license +version number, you may choose any version ever published by the Free +Software Foundation. + +If you wish to incorporate parts of the Library into other free programs +whose distribution conditions are incompatible with these, write to the +author to ask for permission. For software which is copyrighted by the +Free Software Foundation, write to the Free Software Foundation; we +sometimes make exceptions for this. Our decision will be guided by the +two goals of preserving the free status of all derivatives of our free +software and of promoting the sharing and reuse of software generally. + +No Warranty + +Because the library is licensed free of charge, there is no warranty for +the library, to the extent permitted by applicable law. Except when +otherwise stated in writing the copyright holders and/or other parties +provide the library "as is" without warranty of any kind, either +expressed or implied, including, but not limited to, the implied +warranties of merchantability and fitness for a particular purpose. The +entire risk as to the quality and performance of the library is with +you. Should the library prove defective, you assume the cost of all +necessary servicing, repair or correction. + +In no event unless required by applicable law or agreed to in writing +will any copyright holder, or any other party who may modify and/or +redistribute the library as permitted above, be liable to you for +damages, including any general, special, incidental or consequential +damages arising out of the use or inability to use the library +(including but not limited to loss of data or data being rendered +inaccurate or losses sustained by you or third parties or a failure of +the library to operate with any other software), even if such holder or +other party has been advised of the possibility of such damages. diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/jabber_protocol.png Binary file gui/src/icons/jabber_protocol.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/logo.png Binary file gui/src/icons/logo.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/question.png Binary file gui/src/icons/question.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/redled.png Binary file gui/src/icons/redled.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/redo.png Binary file gui/src/icons/redo.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/search.png Binary file gui/src/icons/search.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/star.png Binary file gui/src/icons/star.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/stop.png Binary file gui/src/icons/stop.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/terminal.png Binary file gui/src/icons/terminal.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/undo.png Binary file gui/src/icons/undo.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/up.png Binary file gui/src/icons/up.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/zoom-in.png Binary file gui/src/icons/zoom-in.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/icons/zoom-out.png Binary file gui/src/icons/zoom-out.png has changed diff -r a87fa9132b72 -r dbc43bd95477 gui/src/m-editor/file-editor-interface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/m-editor/file-editor-interface.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,78 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef FILEEDITORINTERFACE_H +#define FILEEDITORINTERFACE_H + +#include +#include +#include + +class QTerminal; +class main_window; + +class file_editor_interface : public QDockWidget +{ + Q_OBJECT + + public: + file_editor_interface (QTerminal *terminal, main_window *mainWindow) + : QDockWidget ((QWidget*)mainWindow) // QDockWidget constructor is explicit, hence the cast. + { + setObjectName ("FileEditor"); + _terminal = terminal; + _main_window = mainWindow; + + connect (this, SIGNAL (visibilityChanged (bool)), this, + SLOT (handle_visibility_changed (bool))); + } + + virtual ~file_editor_interface () { } + + virtual QMenu *debug_menu () = 0; + virtual QToolBar *toolbar () = 0; + + virtual void handle_entered_debug_mode () = 0; + virtual void handle_quit_debug_mode () = 0; + + public slots: + virtual void request_new_file () = 0; + virtual void request_open_file () = 0; + virtual void request_open_file (QString fileName) = 0; + + signals: + void active_changed (bool active); + + protected: + QTerminal* _terminal; + main_window* _main_window; + + void closeEvent (QCloseEvent *event) + { + emit active_changed (false); + QDockWidget::closeEvent (event); + } + + protected slots: + void handle_visibility_changed (bool visible) + { + if (visible) + emit active_changed (true); + } +}; + +#endif // FILEEDITORINTERFACE_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/m-editor/file-editor-tab.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/m-editor/file-editor-tab.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,811 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "file-editor-tab.h" +#include "file-editor.h" +#include "find-dialog.h" +#include "octave-link.h" + + +#include +// Not available in the Debian repos yet! +// #include +#include "lexer-octave-gui.h" +#include +#include +#include +#include +#include +#include "resource-manager.h" +#include +#include + +file_editor_tab::file_editor_tab(file_editor *fileEditor) + : QWidget ((QWidget*)fileEditor), octave_event_observer () +{ + QSettings *settings = resource_manager::instance ()->get_settings (); + _file_editor = fileEditor; + _file_name = ""; + _edit_area = new QsciScintilla (this); + + // symbols + _edit_area->setMarginType (1, QsciScintilla::SymbolMargin); + _edit_area->setMarginSensitivity (1, true); + _edit_area->markerDefine (QsciScintilla::RightTriangle, bookmark); + _edit_area->markerDefine (QPixmap (":/actions/icons/redled.png"), + breakpoint); + _edit_area->markerDefine (QPixmap (":/actions/icons/arrow_right.png"), + debugger_position); + + connect (_edit_area, SIGNAL (marginClicked (int, int, + Qt::KeyboardModifiers)), + this, SLOT (handle_margin_clicked (int, int, + Qt::KeyboardModifiers))); + + // line numbers + _edit_area->setMarginsForegroundColor(QColor(96,96,96)); + _edit_area->setMarginsBackgroundColor(QColor(232,232,220)); + if (settings->value ("editor/showLineNumbers",true).toBool ()) + { + QFont marginFont( settings->value ("editor/fontName","Courier").toString () , + settings->value ("editor/fontSize",10).toInt () ); + _edit_area->setMarginsFont( marginFont ); + QFontMetrics metrics(marginFont); + _edit_area->setMarginType (2, QsciScintilla::TextMargin); + _edit_area->setMarginWidth(2, metrics.width("9999")); + _edit_area->setMarginLineNumbers (2, true); + } + + // code folding + _edit_area->setMarginType (3, QsciScintilla::SymbolMargin); + _edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3); + + // other features + if (settings->value ("editor/highlightCurrentLine",true).toBool ()) + { + _edit_area->setCaretLineVisible(true); + _edit_area->setCaretLineBackgroundColor(QColor(245,245,245)); + } + _edit_area->setBraceMatching (QsciScintilla::StrictBraceMatch); + _edit_area->setAutoIndent (true); + _edit_area->setIndentationWidth (2); + _edit_area->setIndentationsUseTabs (false); + if (settings->value ("editor/codeCompletion",true).toBool ()) + { + _edit_area->autoCompleteFromAll (); + _edit_area->setAutoCompletionSource(QsciScintilla::AcsAll); + _edit_area->setAutoCompletionThreshold (1); + } + _edit_area->setUtf8 (true); + + QVBoxLayout *layout = new QVBoxLayout (); + layout->addWidget (_edit_area); + layout->setMargin (0); + setLayout (layout); + + // connect modified signal + connect (_edit_area, SIGNAL (modificationChanged (bool)), + this, SLOT (update_window_title (bool))); + connect (_edit_area, SIGNAL (copyAvailable (bool)), + this, SLOT (handle_copy_available (bool))); + connect (&_file_system_watcher, SIGNAL (fileChanged (QString)), + this, SLOT (file_has_changed (QString))); + + _file_name = ""; + update_window_title (false); +} + +bool +file_editor_tab::copy_available () +{ + return _copy_available; +} + +void +file_editor_tab::event_accepted (octave_event *e) +{ + if (dynamic_cast (e)) + { + // File was run successfully. + } + + if (octave_add_breakpoint_event *abe + = dynamic_cast (e)) + { + // TODO: Check file. + _edit_area->markerAdd (abe->get_line (), breakpoint); + } + + if (octave_remove_breakpoint_event *rbe + = dynamic_cast (e)) + { + // TODO: Check file. + _edit_area->markerDelete (rbe->get_line (), breakpoint); + } + + if (octave_remove_all_breakpoints_event *rabe + = dynamic_cast (e)) + { + Q_UNUSED (rabe); + _edit_area->markerDeleteAll (breakpoint); + } + + delete e; +} + +void +file_editor_tab::event_reject (octave_event *e) +{ + if (dynamic_cast (e)) + { + // Running file failed. + } + delete e; +} + +void +file_editor_tab::closeEvent (QCloseEvent *event) +{ + if (_file_editor->get_main_window ()->is_closing ()) + { + // close whole application: save file or not if modified + check_file_modified ("Closing Octave", 0); // no cancel possible + event->accept (); + } + else + { + // ignore close event if file is not saved and user cancels + // closing this window + if (check_file_modified ("Close File", + QMessageBox::Cancel) == QMessageBox::Cancel) + { + event->ignore (); + } + else + { + event->accept(); + } + } +} + +void +file_editor_tab::set_file_name (QString fileName) +{ + _file_name = fileName; + update_lexer (); + update_tracked_file (); +} + +void +file_editor_tab::handle_margin_clicked(int margin, int line, + Qt::KeyboardModifiers state) +{ + Q_UNUSED (state); + if (margin == 1) + { + unsigned int mask = _edit_area->markersAtLine (line); + + if (state & Qt::ControlModifier) + { + if (mask && (1 << bookmark)) + _edit_area->markerDelete(line,bookmark); + else + _edit_area->markerAdd(line,bookmark); + } + else + { + if (mask && (1 << breakpoint)) + { + request_remove_breakpoint (line); + } + else + { + request_add_breakpoint (line); + } + } + } +} + +void +file_editor_tab::update_lexer () +{ + QsciLexer *lexer = _edit_area->lexer (); + delete lexer; + + if (_file_name.endsWith (".m") || _file_name.endsWith (".M")) + { + lexer = new lexer_octave_gui (); + + // The API info that is used for auto completion + // TODO: Where to store a file with API info (raw or prepared?)? + // TODO: Also provide infos on octave-forge functions? + // TODO: Also provide infos on function parameters? + // By now, use the keywords-list from syntax highlighting + + QsciAPIs *lexer_api = new QsciAPIs (lexer); + + QString keyword; + QStringList keywordList; + + // get whole string with all keywords + keyword = lexer->keywords (1); + // split into single strings + keywordList = keyword.split (QRegExp ("\\s+")); + + int i; + for (i = 0; i < keywordList.size (); i++) + { + // add single strings to the API + lexer_api->add (keywordList.at (i)); + } + // prepare API info ... this make take some time + lexer_api->prepare (); + } + else if (_file_name.endsWith (".c") + || _file_name.endsWith (".cc") + || _file_name.endsWith (".cpp") + || _file_name.endsWith (".cxx") + || _file_name.endsWith (".c++") + || _file_name.endsWith (".h") + || _file_name.endsWith (".hh") + || _file_name.endsWith (".hpp") + || _file_name.endsWith (".h++")) + { + lexer = new QsciLexerCPP (); + } + else if (_file_name.endsWith (".pl")) + { + lexer = new QsciLexerPerl (); + } + else if (_file_name.endsWith (".bat")) + { + lexer = new QsciLexerBatch (); + } + else if (_file_name.endsWith (".diff")) + { + lexer = new QsciLexerDiff (); + } + else // Default to bash lexer. + { + lexer = new QsciLexerBash (); + } + + QSettings *settings = resource_manager::instance ()->get_settings (); + + // Editor font (default or from settings) + lexer->setDefaultFont (QFont ( + settings->value ("editor/fontName", + "Courier").toString (), + settings->value ("editor/fontSize", + 10).toInt ())); + + // TODO: Autoindent not working as it should + lexer->setAutoIndentStyle (QsciScintilla::AiMaintain || + QsciScintilla::AiOpening || + QsciScintilla::AiClosing); + + _edit_area->setLexer (lexer); +} + +void +file_editor_tab::request_add_breakpoint (int line) +{ + QFileInfo file_info (_file_name); + QString path = file_info.absolutePath (); + QString function_name = file_info.fileName (); + + // We have to cut off the suffix, because octave appends it. + function_name.chop (file_info.suffix ().length () + 1); + + octave_link::instance ()->post_event + (new octave_add_breakpoint_event (*this, + path.toStdString (), + function_name.toStdString (), + line)); +} + +void +file_editor_tab::request_remove_breakpoint (int line) +{ + QFileInfo file_info (_file_name); + QString path = file_info.absolutePath (); + QString function_name = file_info.fileName (); + + // We have to cut off the suffix, because octave appends it. + function_name.chop (file_info.suffix ().length () + 1); + + octave_link::instance ()->post_event + (new octave_remove_breakpoint_event (*this, + path.toStdString (), + function_name.toStdString (), + line)); +} + +void +file_editor_tab::comment_selected_text () +{ + do_comment_selected_text (true); +} + +void +file_editor_tab::uncomment_selected_text () +{ + do_comment_selected_text (false); +} + +void +file_editor_tab::do_comment_selected_text (bool comment) +{ + if ( _edit_area->hasSelectedText() ) + { + int lineFrom, lineTo, colFrom, colTo, i; + _edit_area->getSelection (&lineFrom,&colFrom,&lineTo,&colTo); + if ( colTo == 0 ) // the beginning of last line is not selected + lineTo--; // stop at line above + _edit_area->beginUndoAction (); + for ( i=lineFrom; i<=lineTo; i++ ) + { + if ( comment ) + _edit_area->insertAt("%",i,0); + else + { + QString line(_edit_area->text(i)); + if ( line.startsWith("%") ) + { + _edit_area->setSelection(i,0,i,1); + _edit_area->removeSelectedText(); + } + } + } + _edit_area->endUndoAction (); + } +} + +void +file_editor_tab::find () +{ + find_dialog dialog (_edit_area); + dialog.exec (); +} + +void +file_editor_tab::update_window_title (bool modified) +{ + QString title(_file_name); + if ( !_long_title ) + { + QFileInfo file(_file_name); + title = file.fileName(); + } + + if ( modified ) + { + emit file_name_changed (title.prepend("* ")); + } + else + emit file_name_changed (title); +} + +void +file_editor_tab::handle_copy_available(bool enableCopy) +{ + _copy_available = enableCopy; + emit editor_state_changed (); +} + +void +file_editor_tab::update_tracked_file () +{ + QStringList trackedFiles = _file_system_watcher.files (); + if (!trackedFiles.isEmpty ()) + _file_system_watcher.removePaths (trackedFiles); + + if (_file_name != UNNAMED_FILE) + _file_system_watcher.addPath (_file_name); +} + +int +file_editor_tab::check_file_modified (QString msg, int cancelButton) +{ + int decision = QMessageBox::Yes; + if (_edit_area->isModified ()) + { + // file is modified but not saved, aks user what to do + decision = QMessageBox::warning (this, + msg, + tr ("The file %1\n" + "has been modified. Do you want to save the changes?"). + arg (_file_name), + QMessageBox::Save, + QMessageBox::Discard, cancelButton ); + if (decision == QMessageBox::Save) + { + save_file (); + if (_edit_area->isModified ()) + { + // If the user attempted to save the file, but it's still + // modified, then probably something went wrong, so return + // cancel for cancel this operation or try to save files + // as if cancel not possible + if ( cancelButton ) + return (QMessageBox::Cancel); + else + save_file_as (); + } + } + } + return (decision); +} + +void +file_editor_tab::remove_bookmark () +{ + _edit_area->markerDeleteAll (bookmark); +} + +void +file_editor_tab::toggle_bookmark () +{ + int line, cur; + _edit_area->getCursorPosition (&line,&cur); + if ( _edit_area->markersAtLine (line) && (1 << bookmark) ) + _edit_area->markerDelete (line, bookmark); + else + _edit_area->markerAdd (line, bookmark); +} + +void +file_editor_tab::next_bookmark() +{ + int line, cur, nextline; + _edit_area->getCursorPosition (&line, &cur); + if ( _edit_area->markersAtLine (line) && (1 << bookmark) ) + line++; // we have a breakpoint here, so start search from next line + nextline = _edit_area->markerFindNext (line, (1 << bookmark)); + _edit_area->setCursorPosition (nextline, 0); +} + +void +file_editor_tab::previous_bookmark () +{ + int line, cur, prevline; + _edit_area->getCursorPosition (&line, &cur); + if ( _edit_area->markersAtLine (line) && (1 << bookmark) ) + line--; // we have a breakpoint here, so start search from prev line + prevline = _edit_area->markerFindPrevious (line, (1 << bookmark)); + _edit_area->setCursorPosition (prevline, 0); +} + +void +file_editor_tab::remove_all_breakpoints () +{ + QFileInfo file_info (_file_name); + QString path = file_info.absolutePath (); + QString function_name = file_info.fileName (); + + // We have to cut off the suffix, because octave appends it. + function_name.chop (file_info.suffix ().length () + 1); + + octave_link::instance ()->post_event + (new octave_remove_all_breakpoints_event (*this, + path.toStdString (), + function_name.toStdString ())); +} + +void +file_editor_tab::toggle_breakpoint () +{ + int line, cur; + _edit_area->getCursorPosition (&line, &cur); + if ( _edit_area->markersAtLine (line) && (1 << breakpoint) ) + request_remove_breakpoint (line); + else + request_add_breakpoint (line); +} + +void +file_editor_tab::next_breakpoint () +{ + int line, cur, nextline; + _edit_area->getCursorPosition (&line, &cur); + if ( _edit_area->markersAtLine (line) && (1 << breakpoint) ) + line++; // we have a breakpoint here, so start search from next line + nextline = _edit_area->markerFindNext (line, (1 << breakpoint)); + _edit_area->setCursorPosition (nextline, 0); +} + +void +file_editor_tab::previous_breakpoint () +{ + int line, cur, prevline; + _edit_area->getCursorPosition (&line, &cur); + if ( _edit_area->markersAtLine (line) && (1 << breakpoint) ) + line--; // we have a breakpoint here, so start search from prev line + prevline = _edit_area->markerFindPrevious (line, (1 << breakpoint)); + _edit_area->setCursorPosition (prevline, 0); +} + +void +file_editor_tab::cut () +{ + _edit_area->cut (); +} + +void +file_editor_tab::copy () +{ + _edit_area->copy (); +} + +void +file_editor_tab::paste () +{ + _edit_area->paste (); +} + +void +file_editor_tab::undo () +{ + _edit_area->undo (); +} + +void +file_editor_tab::redo () +{ + _edit_area->redo (); +} + +void +file_editor_tab::set_debugger_position (int line) +{ + _edit_area->markerDeleteAll (debugger_position); + if (line > 0) + { + _edit_area->markerAdd (line, debugger_position); + } +} + +void +file_editor_tab::set_modified (bool modified) +{ + _edit_area->setModified (modified); +} + +bool +file_editor_tab::open_file () +{ + QString openFileName; + QFileDialog fileDialog(this); + fileDialog.setNameFilter(SAVE_FILE_FILTER); + fileDialog.setAcceptMode(QFileDialog::AcceptOpen); + fileDialog.setViewMode(QFileDialog::Detail); + if (fileDialog.exec () == QDialog::Accepted) + { + openFileName = fileDialog.selectedFiles().at(0); + if (openFileName.isEmpty ()) + return false; + + load_file(openFileName); + return true; + } + else + { + return false; + } +} + +void +file_editor_tab::load_file (QString fileName) +{ + if (!_file_editor->isVisible ()) + { + _file_editor->show (); + } + + QFile file (fileName); + if (!file.open (QFile::ReadOnly)) + { + QMessageBox::warning (this, tr ("Octave Editor"), + tr ("Could not open file %1 for read:\n%2.").arg (fileName). + arg (file.errorString ())); + return; + } + + QTextStream in (&file); + QApplication::setOverrideCursor (Qt::WaitCursor); + _edit_area->setText (in.readAll ()); + QApplication::restoreOverrideCursor (); + + set_file_name (fileName); + update_tracked_file (); + + + update_window_title (false); // window title (no modification) + _edit_area->setModified (false); // loaded file is not modified yet +} + +void +file_editor_tab::new_file () +{ + if (!_file_editor->isVisible ()) + { + _file_editor->show (); + } + + set_file_name (UNNAMED_FILE); + update_window_title (false); // window title (no modification) + _edit_area->setText (""); + _edit_area->setModified (false); // new file is not modified yet +} + +bool file_editor_tab::save_file() +{ + return save_file (_file_name); +} + +bool +file_editor_tab::save_file (QString saveFileName) +{ + // it is a new file with the name "" -> call saveFielAs + if (saveFileName == UNNAMED_FILE || saveFileName.isEmpty ()) + { + return save_file_as(); + } + + QStringList watched_files = _file_system_watcher.files(); + if (!watched_files.isEmpty ()) + _file_system_watcher.removePaths(watched_files); + + // open the file for writing + QFile file (saveFileName); + if (!file.open (QFile::WriteOnly)) + { + QMessageBox::warning (this, tr ("Octave Editor"), + tr ("Could not open file %1 for write:\n%2."). + arg (saveFileName).arg (file.errorString ())); + _file_system_watcher.addPaths (watched_files); + return false; + } + + // save the contents into the file + QTextStream out (&file); + QApplication::setOverrideCursor (Qt::WaitCursor); + out << _edit_area->text (); + QApplication::restoreOverrideCursor (); + + // save file name for later use + _file_name = saveFileName; + // set the window title to actual file name (not modified) + update_window_title (false); + // files is save -> not modified + _edit_area->setModified (false); + file.close(); + + if (!watched_files.isEmpty ()) + _file_system_watcher.addPaths (watched_files); + return true; +} + +bool +file_editor_tab::save_file_as () +{ + QString saveFileName(_file_name); + QFileDialog fileDialog(this); + if (saveFileName == UNNAMED_FILE || saveFileName.isEmpty ()) + { + QString directory = QString::fromStdString + (octave_link::instance ()->get_last_working_directory ()); + + if (directory.isEmpty ()) + { + directory = QDir::homePath (); + } + + fileDialog.setDirectory (directory); + } + else + { + fileDialog.selectFile (saveFileName); + } + fileDialog.setNameFilter (SAVE_FILE_FILTER); + fileDialog.setDefaultSuffix ("m"); + fileDialog.setAcceptMode (QFileDialog::AcceptSave); + fileDialog.setViewMode (QFileDialog::Detail); + + if (fileDialog.exec ()) + { + saveFileName = fileDialog.selectedFiles ().at (0); + if (saveFileName.isEmpty ()) + return false; + + return save_file (saveFileName); + } + + return false; +} + +void +file_editor_tab::run_file () +{ + if (_edit_area->isModified ()) + save_file(_file_name); + + QFileInfo file_info (_file_name); + QString path = file_info.absolutePath (); + //QString current_path = QString::fromStdString + (octave_link::instance ()->get_last_working_directory ()); + QString function_name = file_info.fileName (); + + // We have to cut off the suffix, because octave appends it. + function_name.chop (file_info.suffix ().length () + 1); + _file_editor->terminal ()->sendText (QString ("cd \'%1\'\n%2\n") + .arg(path).arg (function_name)); + // TODO: Sending a run event crashes for long scripts. Find out why. + // octave_link::instance () + // ->post_event (new octave_run_file_event (*this, _file_name.toStdString ())); +} + +void +file_editor_tab::file_has_changed (QString fileName) +{ + Q_UNUSED (fileName); + if (QFile::exists (_file_name)) + { + // Prevent popping up multiple message boxes when the file has + // been changed multiple times. + static bool alreadyAsking = false; + if (!alreadyAsking) + { + alreadyAsking = true; + + int decision = + QMessageBox::warning (this, tr ("Octave Editor"), + tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?"). + arg (_file_name), QMessageBox::Yes, + QMessageBox::No); + + if (decision == QMessageBox::Yes) + { + load_file (_file_name); + } + + alreadyAsking = false; + } + } + else + { + int decision = + QMessageBox::warning (this, tr ("Octave Editor"), + tr ("It seems that \'%1\' has been deleted or renamed. Do you want to save it now?"). + arg (_file_name), QMessageBox::Save, + QMessageBox::Close); + if (decision == QMessageBox::Save) + { + if (!save_file_as ()) + { + set_file_name (UNNAMED_FILE); + update_window_title (true); // window title (no modification) + set_modified (true); + update_tracked_file (); + } + } + else + { + emit close_request (); + } + } +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/m-editor/file-editor-tab.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/m-editor/file-editor-tab.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,102 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef FILEEDITORTAB_H +#define FILEEDITORTAB_H + +#include +#include +#include +#include +#include "octave-event-observer.h" + +class file_editor; +class file_editor_tab : public QWidget, public octave_event_observer +{ + Q_OBJECT +public: + file_editor_tab (file_editor *fileEditor); + bool copy_available (); + + void event_accepted (octave_event *e); + void event_reject (octave_event *e); + +public slots: + void update_window_title(bool modified); + void handle_copy_available(bool enableCopy); + void handle_margin_clicked (int line, int margin, Qt::KeyboardModifiers state); + void comment_selected_text (); + void uncomment_selected_text (); + void find (); + void remove_bookmark (); + void toggle_bookmark (); + void next_bookmark (); + void previous_bookmark (); + void remove_all_breakpoints (); + void toggle_breakpoint (); + void next_breakpoint (); + void previous_breakpoint (); + void cut (); + void copy (); + void paste (); + void undo (); + void redo (); + void set_debugger_position (int line); + + void set_modified (bool modified = true); + + bool open_file (); + void load_file (QString fileName); + void new_file (); + bool save_file (); + bool save_file(QString saveFileName); + bool save_file_as(); + void run_file (); + + void file_has_changed (QString fileName); + +signals: + void file_name_changed (QString fileName); + void editor_state_changed (); + void close_request (); + +protected: + void closeEvent (QCloseEvent *event); + void set_file_name (QString fileName); + +private: + void update_lexer (); + void request_add_breakpoint (int line); + void request_remove_breakpoint (int line); + + void update_tracked_file (); + int check_file_modified (QString msg, int cancelButton); + void do_comment_selected_text (bool comment); + + file_editor * _file_editor; + QsciScintilla * _edit_area; + + QString _file_name; + QString _file_name_short; + + bool _long_title; + bool _copy_available; + + QFileSystemWatcher _file_system_watcher; +}; + +#endif // FILEEDITORTAB_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/m-editor/file-editor.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/m-editor/file-editor.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,558 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "file-editor.h" +#include +#include +#include +#include +#include +#include +#include +#include + +file_editor::file_editor (QTerminal *terminal, main_window *m) + : file_editor_interface(terminal, m) +{ + construct (); + + _terminal = terminal; + _main_window = m; + setVisible (false); +} + +file_editor::~file_editor () +{ +} + +QTerminal * +file_editor::terminal () +{ + return _terminal; +} + +main_window * +file_editor::get_main_window () +{ + return _main_window; +} + +QMenu * +file_editor::debug_menu () +{ + return _debug_menu; +} + +QToolBar * +file_editor::toolbar () +{ + return _tool_bar; +} + +void +file_editor::handle_entered_debug_mode () +{ + _run_action->setEnabled (false); +} + +void +file_editor::handle_quit_debug_mode () +{ + _run_action->setEnabled (true); +} + +void +file_editor::request_new_file () +{ + file_editor_tab *fileEditorTab = new file_editor_tab (this); + if (fileEditorTab) + { + add_file_editor_tab (fileEditorTab); + fileEditorTab->new_file (); + } +} + +void +file_editor::request_open_file () +{ + file_editor_tab *fileEditorTab = new file_editor_tab (this); + if (fileEditorTab) + { + add_file_editor_tab (fileEditorTab); + if (!fileEditorTab->open_file ()) + { + // If no file was loaded, remove the tab again. + _tab_widget->removeTab (_tab_widget->indexOf (fileEditorTab)); + } + } +} + +void +file_editor::request_open_file (QString fileName) +{ + if (!isVisible ()) + { + show (); + } + + file_editor_tab *fileEditorTab = new file_editor_tab (this); + if (fileEditorTab) + { + add_file_editor_tab (fileEditorTab); + fileEditorTab->load_file (fileName); + } +} + +void +file_editor::request_undo () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->undo (); +} + +void +file_editor::request_redo () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->redo (); +} + +void +file_editor::request_copy () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->copy (); +} + +void +file_editor::request_cut () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->cut (); +} + +void +file_editor::request_paste () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->paste (); +} + +void +file_editor::request_save_file () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->save_file (); +} + +void +file_editor::request_save_file_as () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->save_file_as (); +} + +void +file_editor::request_run_file () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->run_file (); +} + +void +file_editor::request_toggle_bookmark () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->toggle_bookmark (); +} + +void +file_editor::request_next_bookmark () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->next_bookmark (); +} + +void +file_editor::request_previous_bookmark () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->previous_bookmark (); +} + +void +file_editor::request_remove_bookmark () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->remove_bookmark (); +} + +void +file_editor::request_toggle_breakpoint () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->toggle_breakpoint (); +} + +void +file_editor::request_next_breakpoint () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->next_breakpoint (); +} + +void +file_editor::request_previous_breakpoint () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->previous_breakpoint (); +} + +void +file_editor::request_remove_breakpoint () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->remove_all_breakpoints (); +} + +void +file_editor::request_comment_selected_text () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->comment_selected_text (); +} + +void +file_editor::request_uncomment_selected_text () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->uncomment_selected_text (); +} + +void +file_editor::request_find () +{ + file_editor_tab *_active_file_editor_tab = active_editor_tab (); + if (_active_file_editor_tab) + _active_file_editor_tab->find (); +} + +void +file_editor::handle_file_name_changed (QString fileName) +{ + QObject *senderObject = sender (); + file_editor_tab *fileEditorTab + = dynamic_cast (senderObject); + if (fileEditorTab) + { + for(int i = 0; i < _tab_widget->count (); i++) + { + if (_tab_widget->widget (i) == fileEditorTab) + { + _tab_widget->setTabText (i, fileName); + } + } + } +} + +void +file_editor::handle_tab_close_request (int index) +{ + file_editor_tab *fileEditorTab + = dynamic_cast (_tab_widget->widget (index)); + if (fileEditorTab) + if (fileEditorTab->close ()) + { + _tab_widget->removeTab (index); + delete fileEditorTab; + } +} + +void +file_editor::handle_tab_close_request () +{ + file_editor_tab *fileEditorTab = dynamic_cast (sender ()); + if (fileEditorTab) + if (fileEditorTab->close ()) + { + _tab_widget->removeTab (_tab_widget->indexOf (fileEditorTab)); + delete fileEditorTab; + } +} + +void +file_editor::active_tab_changed (int index) +{ + Q_UNUSED (index); + handle_editor_state_changed (); +} + +void +file_editor::handle_editor_state_changed () +{ + file_editor_tab *f = active_editor_tab (); + if (f) + { + bool copy_available = f->copy_available (); + _copy_action->setEnabled (copy_available); + _cut_action->setEnabled (copy_available); + setFocusProxy (f); + } +} + +void +file_editor::construct () +{ + QWidget *widget = new QWidget (this); + QStyle *style = QApplication::style (); + + _menu_bar = new QMenuBar (widget); + _tool_bar = new QToolBar (widget); + _tab_widget = new QTabWidget (widget); + _tab_widget->setTabsClosable (true); + + QAction *new_action = new QAction (QIcon(":/actions/icons/filenew.png"), + tr("&New File"), _tool_bar); + + QAction *open_action = new QAction (QIcon(":/actions/icons/fileopen.png"), + tr("&Open File"), _tool_bar); + + QAction *save_action = new QAction (QIcon(":/actions/icons/filesave.png"), + tr("&Save File"), _tool_bar); + + QAction *save_as_action + = new QAction (QIcon(":/actions/icons/filesaveas.png"), + tr("Save File &As"), _tool_bar); + + QAction *undo_action = new QAction (QIcon(":/actions/icons/undo.png"), + tr("&Undo"), _tool_bar); + + QAction *redo_action = new QAction (QIcon(":/actions/icons/redo.png"), + tr("&Redo"), _tool_bar); + + _copy_action = new QAction (QIcon(":/actions/icons/editcopy.png"), + tr ("&Copy"), _tool_bar); + + _cut_action = new QAction (QIcon(":/actions/icons/editcut.png"), + tr ("Cu&t"), _tool_bar); + + QAction *paste_action + = new QAction (QIcon (":/actions/icons/editpaste.png"), + tr("Paste"), _tool_bar); + QAction *next_bookmark_action = new QAction (tr ("&Next Bookmark"),_tool_bar); + QAction *previous_bookmark_action = new QAction (tr ("Pre&vious Bookmark"),_tool_bar); + QAction *toggle_bookmark_action = new QAction (tr ("Toggle &Bookmark"),_tool_bar); + QAction *remove_bookmark_action = new QAction (tr ("&Remove All Bookmarks"),_tool_bar); + + QAction *next_breakpoint_action + = new QAction (QIcon (":/actions/icons/bp_next.png"), + tr ("&Next breakpoint"), _tool_bar); + QAction *previous_breakpoint_action + = new QAction (QIcon (":/actions/icons/bp_prev.png"), + tr ("Pre&vious breakpoint"), _tool_bar); + QAction *toggle_breakpoint_action + = new QAction (QIcon (":/actions/icons/bp_toggle.png"), + tr ("Toggle &breakpoint"), _tool_bar); + QAction *remove_all_breakpoints_action + = new QAction (QIcon (":/actions/icons/bp_rm_all.png"), + tr ("&Remove All breakpoints"), _tool_bar); + + QAction *comment_selection_action = new QAction (tr ("&Comment Selected Text"),_tool_bar); + QAction *uncomment_selection_action = new QAction (tr ("&Uncomment Selected Text"),_tool_bar); + + QAction *find_action = new QAction (QIcon(":/actions/icons/find.png"), + tr ("&Find and Replace"), _tool_bar); + + _run_action = new QAction (QIcon(":/actions/icons/artsbuilderexecute.png"), + tr("Save File And Run"), _tool_bar); + + // some actions are disabled from the beginning + _copy_action->setEnabled(false); + _cut_action->setEnabled(false); + _run_action->setShortcut (Qt::ControlModifier+ Qt::Key_R); + _run_action->setShortcutContext (Qt::WindowShortcut); + next_bookmark_action->setShortcut (Qt::Key_F2); + next_bookmark_action->setShortcutContext (Qt::WindowShortcut); + previous_bookmark_action->setShortcut (Qt::SHIFT + Qt::Key_F2); + previous_bookmark_action->setShortcutContext (Qt::WindowShortcut); + toggle_bookmark_action->setShortcut (Qt::Key_F7); + toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); + comment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_7); + comment_selection_action->setShortcutContext (Qt::WindowShortcut); + uncomment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_8); + uncomment_selection_action->setShortcutContext(Qt::WindowShortcut); + find_action->setShortcut (Qt::ControlModifier+Qt::Key_F); + find_action->setShortcutContext (Qt::WindowShortcut); + + // toolbar + _tool_bar->addAction (new_action); + _tool_bar->addAction (open_action); + _tool_bar->addAction (save_action); + _tool_bar->addAction (save_as_action); + _tool_bar->addSeparator (); + _tool_bar->addAction (undo_action); + _tool_bar->addAction (redo_action); + _tool_bar->addAction (_copy_action); + _tool_bar->addAction (_cut_action); + _tool_bar->addAction (paste_action); + _tool_bar->addSeparator (); + _tool_bar->addAction (find_action); + _tool_bar->addAction (_run_action); + _tool_bar->addSeparator (); + _tool_bar->addAction (toggle_breakpoint_action); + _tool_bar->addAction (next_breakpoint_action); + _tool_bar->addAction (previous_breakpoint_action); + _tool_bar->addAction (remove_all_breakpoints_action); + + // menu bar + QMenu *fileMenu = new QMenu (tr ("&File"), _menu_bar); + fileMenu->addAction (new_action); + fileMenu->addAction (open_action); + fileMenu->addAction (save_action); + fileMenu->addAction (save_as_action); + fileMenu->addSeparator (); + _menu_bar->addMenu (fileMenu); + + QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); + editMenu->addAction (undo_action); + editMenu->addAction (redo_action); + editMenu->addSeparator (); + editMenu->addAction (_copy_action); + editMenu->addAction (_cut_action); + editMenu->addAction (paste_action); + editMenu->addSeparator (); + editMenu->addAction (find_action); + editMenu->addSeparator (); + editMenu->addAction (comment_selection_action); + editMenu->addAction (uncomment_selection_action); + editMenu->addSeparator (); + editMenu->addAction (toggle_bookmark_action); + editMenu->addAction (next_bookmark_action); + editMenu->addAction (previous_bookmark_action); + editMenu->addAction (remove_bookmark_action); + _menu_bar->addMenu (editMenu); + + _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); + _debug_menu->addAction (toggle_breakpoint_action); + _debug_menu->addAction (next_breakpoint_action); + _debug_menu->addAction (previous_breakpoint_action); + _debug_menu->addAction (remove_all_breakpoints_action); + _debug_menu->addSeparator (); + // The other debug actions will be added by the main window. + _menu_bar->addMenu (_debug_menu); + + QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); + _run_menu->addAction (_run_action); + _menu_bar->addMenu (_run_menu); + + QVBoxLayout *layout = new QVBoxLayout (); + layout->addWidget (_menu_bar); + layout->addWidget (_tool_bar); + layout->addWidget (_tab_widget); + layout->setMargin (0); + widget->setLayout (layout); + setWidget (widget); + + connect (new_action, + SIGNAL (triggered ()), this, SLOT (request_new_file ())); + connect (open_action, + SIGNAL (triggered ()), this, SLOT (request_open_file ())); + connect (undo_action, + SIGNAL (triggered ()), this, SLOT (request_undo ())); + connect (redo_action, + SIGNAL (triggered ()), this, SLOT (request_redo ())); + connect (_copy_action, + SIGNAL (triggered ()), this, SLOT (request_copy ())); + connect (_cut_action, + SIGNAL (triggered ()), this, SLOT (request_cut ())); + connect (paste_action, + SIGNAL (triggered ()), this, SLOT (request_paste ())); + connect (save_action, + SIGNAL (triggered ()), this, SLOT (request_save_file ())); + connect (save_as_action, + SIGNAL (triggered ()), this, SLOT (request_save_file_as ())); + connect (_run_action, + SIGNAL (triggered ()), this, SLOT (request_run_file ())); + connect (toggle_bookmark_action, + SIGNAL (triggered ()), this, SLOT (request_toggle_bookmark ())); + connect (next_bookmark_action, + SIGNAL (triggered ()), this, SLOT (request_next_bookmark ())); + connect (previous_bookmark_action, + SIGNAL (triggered ()), this, SLOT (request_previous_bookmark ())); + connect (remove_bookmark_action, + SIGNAL (triggered ()), this, SLOT (request_remove_bookmark ())); + connect (toggle_breakpoint_action, + SIGNAL (triggered ()), this, SLOT (request_toggle_breakpoint ())); + connect (next_breakpoint_action, + SIGNAL (triggered ()), this, SLOT (request_next_breakpoint ())); + connect (previous_breakpoint_action, + SIGNAL (triggered ()), this, SLOT (request_previous_breakpoint ())); + connect (remove_all_breakpoints_action, + SIGNAL (triggered ()), this, SLOT (request_remove_breakpoint ())); + connect (comment_selection_action, + SIGNAL (triggered ()), this, SLOT (request_comment_selected_text ())); + connect (uncomment_selection_action, + SIGNAL (triggered ()), this, SLOT (request_uncomment_selected_text ())); + connect (find_action, + SIGNAL (triggered ()), this, SLOT (request_find ())); + connect (_tab_widget, + SIGNAL (tabCloseRequested (int)), this, SLOT (handle_tab_close_request (int))); + connect (_tab_widget, + SIGNAL (currentChanged(int)), this, SLOT (active_tab_changed (int))); + + resize (500, 400); + setWindowIcon (QIcon::fromTheme ("accessories-text-editor", + style->standardIcon (QStyle::SP_FileIcon))); + setWindowTitle ("Octave Editor"); +} + +void +file_editor::add_file_editor_tab (file_editor_tab *f) +{ + _tab_widget->addTab (f, ""); + connect (f, SIGNAL (file_name_changed(QString)), + this, SLOT(handle_file_name_changed(QString))); + connect (f, SIGNAL (editor_state_changed ()), + this, SLOT (handle_editor_state_changed ())); + connect (f, SIGNAL (close_request ()), + this, SLOT (handle_tab_close_request ())); + _tab_widget->setCurrentWidget (f); +} + +file_editor_tab * +file_editor::active_editor_tab () +{ + return dynamic_cast (_tab_widget->currentWidget ()); +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/m-editor/file-editor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/m-editor/file-editor.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,107 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef FILEEDITORMDISUBWINDOW_H +#define FILEEDITORMDISUBWINDOW_H + +#include +#include +#include +#include +#include +#include + +#include "main-window.h" +#include "file-editor-interface.h" +#include "file-editor-tab.h" + +const char UNNAMED_FILE[] = ""; +const char SAVE_FILE_FILTER[] = "Octave Files (*.m);;All Files (*.*)"; +enum editor_markers + { + bookmark, + breakpoint, + debugger_position + }; + +class file_editor : public file_editor_interface +{ +Q_OBJECT + +public: + file_editor (QTerminal *terminal, main_window *m); + ~file_editor (); + void loadFile (QString fileName); + + QTerminal * terminal (); + main_window * get_main_window (); + + QMenu * debug_menu (); + QToolBar * toolbar (); + + void handle_entered_debug_mode (); + void handle_quit_debug_mode (); + +public slots: + void request_new_file (); + void request_open_file (); + void request_open_file (QString fileName); + + void request_undo (); + void request_redo (); + void request_copy (); + void request_cut (); + void request_paste (); + void request_save_file (); + void request_save_file_as (); + void request_run_file (); + void request_toggle_bookmark (); + void request_next_bookmark (); + void request_previous_bookmark (); + void request_remove_bookmark (); + + void request_toggle_breakpoint (); + void request_next_breakpoint (); + void request_previous_breakpoint (); + void request_remove_breakpoint (); + + void request_comment_selected_text (); + void request_uncomment_selected_text (); + void request_find (); + + void handle_file_name_changed (QString fileName); + void handle_tab_close_request (int index); + void handle_tab_close_request (); + void active_tab_changed (int index); + void handle_editor_state_changed (); + +private: + void construct (); + void add_file_editor_tab(file_editor_tab *f); + file_editor_tab *active_editor_tab(); + + QMenuBar * _menu_bar; + QToolBar * _tool_bar; + QMenu * _debug_menu; + QAction * _copy_action; + QAction * _cut_action; + QAction * _run_action; + QTabWidget * _tab_widget; + int _marker_breakpoint; +}; + +#endif // FILEEDITORMDISUBWINDOW_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/m-editor/find-dialog.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/m-editor/find-dialog.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,195 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "find-dialog.h" + +find_dialog::find_dialog (QsciScintilla* edit_area, QWidget *parent) + : QDialog (parent) +{ + setWindowTitle ("Find and Replace"); + setWindowIcon (QIcon(":/actions/icons/logo.png")); + + _search_label = new QLabel (tr ("Find &what:")); + _search_line_edit = new QLineEdit; + _search_label->setBuddy (_search_line_edit); + _replace_label = new QLabel (tr ("Re&place with:")); + _replace_line_edit = new QLineEdit; + _replace_label->setBuddy (_replace_line_edit); + + _case_check_box = new QCheckBox (tr ("Match &case")); + _from_start_check_box = new QCheckBox (tr ("Search from &start")); + _wrap_check_box = new QCheckBox (tr ("&Wrap while searching")); + _wrap_check_box->setChecked(true); + _find_next_button = new QPushButton (tr ("&Find Next")); + _find_next_button->setDefault (true); + _replace_button = new QPushButton (tr ("&Replace")); + _replace_all_button = new QPushButton (tr ("Replace &All")); + + _more_button = new QPushButton (tr ("&More")); + _more_button->setCheckable (true); + _more_button->setAutoDefault (false); + + _button_box = new QDialogButtonBox (Qt::Vertical); + _button_box->addButton (_find_next_button, QDialogButtonBox::ActionRole); + _button_box->addButton (_replace_button, QDialogButtonBox::ActionRole); + _button_box->addButton (_replace_all_button, QDialogButtonBox::ActionRole); + _button_box->addButton (_more_button, QDialogButtonBox::ActionRole); + + _extension = new QWidget (this); + _whole_words_check_box = new QCheckBox (tr ("&Whole words")); + _regex_check_box = new QCheckBox (tr ("Regular E&xpressions")); + _backward_check_box = new QCheckBox (tr ("Search &backward")); + _search_selection_check_box = new QCheckBox (tr ("Search se&lection")); + _search_selection_check_box->setCheckable (false); // TODO: Not implemented. + _search_selection_check_box->setEnabled (false); + + _edit_area = edit_area; + connect (_find_next_button, SIGNAL (clicked ()), + this, SLOT (search_next ())); + connect (_more_button, SIGNAL (toggled (bool)), + _extension, SLOT (setVisible (bool))); + connect (_replace_button, SIGNAL (clicked ()), + this, SLOT (replace ())); + connect (_replace_all_button, SIGNAL (clicked ()), + this, SLOT (replace_all ())); + + QVBoxLayout *extension_layout = new QVBoxLayout (); + extension_layout->setMargin (0); + extension_layout->addWidget (_whole_words_check_box); + extension_layout->addWidget (_backward_check_box); + extension_layout->addWidget (_search_selection_check_box); + _extension->setLayout (extension_layout); + + QGridLayout *top_left_layout = new QGridLayout; + top_left_layout->addWidget (_search_label, 1, 1); + top_left_layout->addWidget (_search_line_edit, 1, 2); + top_left_layout->addWidget (_replace_label, 2, 1); + top_left_layout->addWidget (_replace_line_edit, 2, 2); + + QVBoxLayout *left_layout = new QVBoxLayout; + left_layout->addLayout (top_left_layout); + left_layout->insertStretch (1, 5); + left_layout->addWidget (_case_check_box); + left_layout->addWidget (_from_start_check_box); + left_layout->addWidget (_wrap_check_box); + left_layout->addWidget (_regex_check_box); + + QGridLayout *main_layout = new QGridLayout; + main_layout->setSizeConstraint (QLayout::SetFixedSize); + main_layout->addLayout (left_layout, 0, 0); + main_layout->addWidget (_button_box, 0, 1); + main_layout->addWidget (_extension, 1, 0, 1, 2); + setLayout (main_layout); + + _extension->hide (); +} + +void +find_dialog::search_next () +{ + int line = -1, col = -1; + + _find_result_available = false; + if (_from_start_check_box->isChecked ()) + { + line = 1; + col = 1; + } + + if (_edit_area) + { + _find_result_available = _edit_area->findFirst (_search_line_edit->text (), + _regex_check_box->isChecked (), + _case_check_box->isChecked (), + _whole_words_check_box->isChecked (), + _wrap_check_box->isChecked (), + !_backward_check_box->isChecked (), + line,col, + true, + true + ); + } +} + + +void +find_dialog::replace () +{ + if (_edit_area) + { + _edit_area->replace (_replace_line_edit->text ()); + _edit_area->findNext(); + } +} + +void +find_dialog::replace_all () +{ + int count = 0; + + // check whether find & replace srings are different (avoid endless loop!) + int strDiff; + Qt::CaseSensitivity cs; + if (_case_check_box->isChecked()) + { + cs = Qt::CaseSensitive; + } + else + { + cs = Qt::CaseInsensitive; + } + strDiff = QString::compare(_search_line_edit->text(),_replace_line_edit->text(),cs); + + // replace all if strings are different + if (_edit_area && strDiff ) + { + search_next (); // find first occurence + while (_find_result_available) // while search string is found + { + _edit_area->replace (_replace_line_edit->text ()); // replace + count++; // inc counter + _find_result_available = _edit_area->findNext(); // and find next + } + } + // TODO: Show number of replaced strings +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/m-editor/find-dialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/m-editor/find-dialog.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FIND_DIALOG_H +#define FIND_DIALOG_H + +#include +#include + +class QCheckBox; +class QDialogButtonBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; + +class find_dialog : public QDialog +{ + Q_OBJECT +public: + find_dialog (QsciScintilla* edit_area, QWidget *parent = 0); + +private slots: + void search_next (); + void replace (); + void replace_all (); + +private: + QLabel *_search_label; + QLineEdit *_search_line_edit; + QLabel *_replace_label; + QLineEdit *_replace_line_edit; + QCheckBox *_case_check_box; + QCheckBox *_from_start_check_box; + QCheckBox *_wrap_check_box; + QCheckBox *_whole_words_check_box; + QCheckBox *_regex_check_box; + QCheckBox *_search_selection_check_box; + QCheckBox *_backward_check_box; + QDialogButtonBox *_button_box; + QPushButton *_find_next_button; + QPushButton *_replace_button; + QPushButton *_replace_all_button; + QPushButton *_more_button; + QWidget *_extension; + QsciScintilla *_edit_area; + bool _find_result_available; +}; + +#endif // FIND_DIALOG_H + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/m-editor/lexer-octave-gui.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/m-editor/lexer-octave-gui.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,141 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "lexer-octave-gui.h" +#include +#include + +// ----------------------------------------------------- +// Some basic functions +// ----------------------------------------------------- +lexer_octave_gui::lexer_octave_gui(QObject *parent) + : QsciLexer(parent) // inherit from base lexer +{ +} + +lexer_octave_gui::~lexer_octave_gui() +{ +} + +const char *lexer_octave_gui::language() const +{ + return "Octave"; // return the name of the language +} + +const char *lexer_octave_gui::lexer() const +{ + return "octave"; // return the name of the lexer +} + +// ----------------------------------------------------- +// The colors for syntax highlighting +// ----------------------------------------------------- +QColor lexer_octave_gui::defaultColor(int style) const +{ + switch (style) + { + case Default: // black + return QColor(0x00,0x00,0x00); + case Operator: // red + return QColor(0xef,0x00,0x00); + case Comment: // gray + return QColor(0x7f,0x7f,0x7f); + case Command: // blue-green + return QColor(0x00,0x7f,0x7f); + case Number: // orange + return QColor(0x7f,0x7f,0x00); + case Keyword: // blue + return QColor(0x00,0x00,0xbf); + case SingleQuotedString: // green + return QColor(0x00,0x7f,0x00); + case DoubleQuotedString: // green-yellow + return QColor(0x4f,0x7f,0x00); + } + return QsciLexer::defaultColor(style); +} + + +// ----------------------------------------------------- +// The font decorations for highlighting +// ----------------------------------------------------- +QFont lexer_octave_gui::defaultFont(int style) const +{ + QFont f; + + switch (style) + { + case Comment: // default but italic + f = QsciLexer::defaultFont(style); + f.setItalic(true); + break; + case Keyword: // default + f = QsciLexer::defaultFont(style); + break; + case Operator: // default + f = QsciLexer::defaultFont(style); + break; + default: // default + f = QsciLexer::defaultFont(style); + break; + } + return f; // return the selected font +} + + +// ----------------------------------------------------- +// Style names +// ----------------------------------------------------- +QString lexer_octave_gui::description(int style) const +{ + switch (style) + { + case Default: + return tr("Default"); + case Comment: + return tr("Comment"); + case Command: + return tr("Command"); + case Number: + return tr("Number"); + case Keyword: + return tr("Keyword"); + case SingleQuotedString: + return tr("Single-quoted string"); + case Operator: + return tr("Operator"); + case Identifier: + return tr("Identifier"); + case DoubleQuotedString: + return tr("Double-quoted string"); + } + return QString(); +} + + +// ----------------------------------------------------- +// The set of keywords for highlighting +// TODO: How to define a second set? +// ----------------------------------------------------- +const char *lexer_octave_gui::keywords(int set) const +{ + if (set == 1) + { + return resource_manager::instance ()->octave_keywords (); + } + return 0; +} + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/m-editor/lexer-octave-gui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/m-editor/lexer-octave-gui.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,60 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef LEXEROCTAVE_H +#define LEXEROCTAVE_H + +#include "resource-manager.h" +#include +#include +#include + + +class lexer_octave_gui : public QsciLexer +{ + Q_OBJECT + +public: + // the used styles + enum + { + Default = 0, + Comment = 1, + Command = 2, + Number = 3, + Keyword = 4, + SingleQuotedString = 5, + Operator = 6, + Identifier = 7, + DoubleQuotedString = 8 + }; + + lexer_octave_gui (QObject *parent = 0); + virtual ~lexer_octave_gui (); + const char *language () const; + const char *lexer () const; + QColor defaultColor (int style) const; + QFont defaultFont (int style) const; + const char *keywords (int set) const; + QString description (int style) const; + +private: + lexer_octave_gui (const lexer_octave_gui &); + lexer_octave_gui &operator= (const lexer_octave_gui &); +}; + +#endif diff -r a87fa9132b72 -r dbc43bd95477 gui/src/main-window.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/main-window.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,857 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "main-window.h" +#include "file-editor.h" +#include "settings-dialog.h" + +main_window::main_window (QWidget * parent) + : QMainWindow (parent), octave_event_observer () +{ + // We have to set up all our windows, before we finally launch octave. + construct (); + octave_link::instance ()->launch_octave(); +} + +main_window::~main_window () +{ +} + +void +main_window::event_accepted (octave_event *e) +{ + if (dynamic_cast (e)) + { + // After clearing the history, we need to reset the model. + _history_dock_widget->reset_model (); + } + delete e; +} + +void +main_window::event_reject (octave_event *e) +{ + delete e; +} + +void +main_window::new_file () +{ + _file_editor->request_new_file (); + focus_editor (); +} + +void +main_window::open_file () +{ + _file_editor->request_open_file (); + focus_editor (); +} + +void +main_window::open_file (QString file_name) +{ + _file_editor->request_open_file (file_name); + focus_editor (); +} + +void +main_window::report_status_message (QString statusMessage) +{ + _status_bar->showMessage (statusMessage, 1000); +} + +void +main_window::handle_save_workspace_request () +{ + QString selectedFile = + QFileDialog::getSaveFileName (this, tr ("Save Workspace"), + resource_manager::instance ()->get_home_path ()); + if (!selectedFile.isEmpty ()) + { + octave_link::instance () + ->post_event (new octave_save_workspace_event (*this, + selectedFile.toStdString())); + } +} + +void +main_window::handle_load_workspace_request () +{ + QString selectedFile = + QFileDialog::getOpenFileName (this, tr ("Load Workspace"), + resource_manager::instance ()->get_home_path ()); + if (!selectedFile.isEmpty ()) + { + octave_link::instance () + ->post_event (new octave_load_workspace_event (*this, + selectedFile.toStdString())); + } +} + +void +main_window::handle_clear_workspace_request () +{ + octave_link::instance () + ->post_event (new octave_clear_workspace_event (*this)); +} + +void +main_window::handle_clear_history_request() +{ + octave_link::instance () + ->post_event (new octave_clear_history_event (*this)); +} + +void +main_window::handle_command_double_clicked (QString command) +{ + _terminal->sendText (command); + _terminal->setFocus (); +} + +void +main_window::open_bug_tracker_page () +{ + QDesktopServices::openUrl (QUrl ("http://bugs.octave.org")); +} + +void +main_window::open_agora_page () +{ + QDesktopServices::openUrl (QUrl ("http://agora.octave.org/")); +} + +void +main_window::open_octave_forge_page () +{ + QDesktopServices::openUrl (QUrl ("http://octave.sourceforge.net/")); +} + +void +main_window::process_settings_dialog_request () +{ + settings_dialog *settingsDialog = new settings_dialog (this); + settingsDialog->exec (); + delete settingsDialog; + emit settings_changed (); +} + +void +main_window::notice_settings () +{ + // Set terminal font: + QSettings *settings = resource_manager::instance ()->get_settings (); + + QFont font = QFont(); + font.setFamily(settings->value("terminal/fontName").toString()); + font.setPointSize(settings->value("terminal/fontSize").toInt ()); + _terminal->setTerminalFont(font); + + QString cursorType = settings->value ("terminal/cursorType").toString (); + bool cursorBlinking = settings->value ("terminal/cursorBlinking").toBool (); + if (cursorType == "ibeam") + _terminal->setCursorType(QTerminalInterface::IBeamCursor, cursorBlinking); + else if (cursorType == "block") + _terminal->setCursorType(QTerminalInterface::BlockCursor, cursorBlinking); + else if (cursorType == "underline") + _terminal->setCursorType(QTerminalInterface::UnderlineCursor, + cursorBlinking); + + resource_manager::instance ()->update_network_settings (); +} + +void +main_window::prepare_for_quit () +{ + write_settings (); +} + +void +main_window::reset_windows () +{ + // TODO: Implement. +} + +void +main_window::current_working_directory_has_changed (QString directory) +{ + if (_current_directory_combo_box->count () > 31) + { + _current_directory_combo_box->removeItem (0); + } + _current_directory_combo_box->addItem (directory); + int index = _current_directory_combo_box->findText (directory); + _current_directory_combo_box->setCurrentIndex (index); + + _files_dock_widget->set_current_directory (directory); +} + +void +main_window::change_current_working_directory () +{ + QString selectedDirectory = + QFileDialog::getExistingDirectory(this, tr ("Set working direcotry")); + + if (!selectedDirectory.isEmpty ()) + { + octave_link::instance () + ->post_event (new octave_change_directory_event (*this, + selectedDirectory.toStdString ())); + } +} + +void +main_window::set_current_working_directory (QString directory) +{ + octave_link::instance () + ->post_event (new octave_change_directory_event (*this, + directory.toStdString ())); +} + +void +main_window::current_working_directory_up () +{ + set_current_working_directory (".."); +} + +void +main_window::focus_command_window () +{ + if (!_terminal_dock_widget->isVisible ()) + { + _terminal_dock_widget->setVisible (true); + } + + _terminal_dock_widget->setFocus (); + _terminal_dock_widget->activateWindow (); + _terminal_dock_widget->raise (); + + _terminal->setFocus (); + _terminal->activateWindow (); + _terminal->raise (); +} + +void +main_window::focus_command_history () +{ + if (!_history_dock_widget->isVisible ()) + { + _history_dock_widget->setVisible (true); + } + + _history_dock_widget->setFocus (); + _history_dock_widget->activateWindow (); + _history_dock_widget->raise (); +} + +void +main_window::focus_current_directory () +{ + if (!_files_dock_widget->isVisible ()) + { + _files_dock_widget->setVisible (true); + } + + _files_dock_widget->setFocus (); + _files_dock_widget->activateWindow (); + _files_dock_widget->raise (); +} + +void +main_window::focus_workspace () +{ + if (!_workspace_view->isVisible ()) + { + _workspace_view->setVisible (true); + } + + _workspace_view->setFocus (); + _workspace_view->activateWindow (); + _workspace_view->raise (); +} + +void +main_window::focus_editor () +{ + if (!_file_editor->isVisible ()) + { + _file_editor->setVisible (true); + } + + _file_editor->setFocus (); + _file_editor->activateWindow (); + _file_editor->raise (); +} + +void +main_window::focus_documentation () +{ + if (!_documentation_dock_widget->isVisible ()) + { + _documentation_dock_widget->setVisible (true); + } + + _documentation_dock_widget->setFocus (); + _documentation_dock_widget->activateWindow (); + _documentation_dock_widget->raise (); +} + +void +main_window::handle_entered_debug_mode () +{ + setWindowTitle ("Octave (Debugging)"); + _debug_continue->setEnabled (true); + _debug_step_into->setEnabled (true); + _debug_step_over->setEnabled (true); + _debug_step_out->setEnabled (true); + _debug_quit->setEnabled (true); + _file_editor->handle_entered_debug_mode (); +} + +void +main_window::handle_quit_debug_mode () +{ + setWindowTitle ("Octave"); + _debug_continue->setEnabled (false); + _debug_step_into->setEnabled (false); + _debug_step_over->setEnabled (false); + _debug_step_out->setEnabled (false); + _debug_quit->setEnabled (false); + _file_editor->handle_quit_debug_mode (); +} + +void +main_window::debug_continue () +{ + octave_link::instance () + ->post_event (new octave_debug_continue_event (*this)); +} + +void +main_window::debug_step_into () +{ + octave_link::instance () + ->post_event (new octave_debug_step_into_event (*this)); +} + +void +main_window::debug_step_over () +{ + octave_link::instance () + ->post_event (new octave_debug_step_over_event (*this)); +} + +void +main_window::debug_step_out () +{ + octave_link::instance () + ->post_event (new octave_debug_step_out_event (*this)); +} + +void +main_window::debug_quit () +{ + octave_link::instance () + ->post_event (new octave_debug_quit_event (*this)); +} + +void +main_window::show_about_octave () +{ + QString message = + "GNU Octave\n" + "Copyright (C) 2009 John W. Eaton and others.\n" + "This is free software; see the source code for copying conditions." + "There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or" + "FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.\n" + "\n" + "Additional information about Octave is available at http://www.octave.org.\n" + "\n" + "Please contribute if you find this software useful." + "For more information, visit http://www.octave.org/help-wanted.html\n" + "\n" + "Report bugs to (but first, please read" + "http://www.octave.org/bugs.html to learn how to write a helpful report).\n" + "\n" + "For information about changes from previous versions, type `news'.\n"; + + QMessageBox::about (this, tr ("About Octave"), message); +} + +void +main_window::closeEvent (QCloseEvent * closeEvent) +{ + closeEvent->ignore (); + octave_link::instance ()->post_event (new octave_exit_event (*this)); + } + +void +main_window::read_settings () +{ + QSettings *settings = resource_manager::instance ()->get_settings (); + restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ()); + restoreState (settings->value ("MainWindow/windowState").toByteArray ()); + emit settings_changed (); +} + +void +main_window::write_settings () +{ + QSettings *settings = resource_manager::instance ()->get_settings (); + settings->setValue ("MainWindow/geometry", saveGeometry ()); + settings->setValue ("MainWindow/windowState", saveState ()); + settings->sync (); +} + +void +main_window::construct () +{ + _closing = false; // flag for editor files when closed + setWindowIcon (QIcon(":/actions/icons/logo.png")); + + // Setup dockable widgets and the status bar. + _workspace_view = new workspace_view (this); + _workspace_view->setStatusTip (tr ("View the variables in the active workspace.")); + _history_dock_widget = new history_dock_widget (this); + _history_dock_widget->setStatusTip (tr ("Browse and search the command history.")); + _files_dock_widget = new files_dock_widget (this); + _files_dock_widget->setStatusTip (tr ("Browse your files.")); + _documentation_dock_widget= new documentation_dock_widget (this); + _documentation_dock_widget->setStatusTip (tr ("See the documentation for help.")); + _status_bar = new QStatusBar (this); + + _current_directory_combo_box = new QComboBox (this); + _current_directory_combo_box->setFixedWidth (300); + _current_directory_combo_box->setEditable (true); + _current_directory_combo_box->setInsertPolicy (QComboBox::InsertAtTop); + _current_directory_combo_box->setMaxVisibleItems (14); + + _current_directory_tool_button = new QToolButton (this); + _current_directory_tool_button->setIcon (QIcon(":/actions/icons/search.png")); + + _current_directory_up_tool_button = new QToolButton (this); + _current_directory_up_tool_button->setIcon (QIcon(":/actions/icons/up.png")); + + // Octave Terminal subwindow. + _terminal = new QTerminal (this); + _terminal->setObjectName ("OctaveTerminal"); + _terminal->setFocusPolicy (Qt::StrongFocus); + _terminal_dock_widget = new terminal_dock_widget (_terminal, this); + _terminal_dock_widget->setWindowIcon (QIcon(":/actions/icons/terminal.png")); + + QWidget *dummyWidget = new QWidget (); + dummyWidget->setObjectName ("CentralDummyWidget"); + dummyWidget->resize (10, 10); + dummyWidget->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum); + dummyWidget->hide (); + setCentralWidget (dummyWidget); + + _file_editor = new file_editor (_terminal, this); + + QMenu *file_menu = menuBar ()->addMenu (tr ("&File")); + + QMenu *new_menu = file_menu->addMenu(tr ("New")); + + QAction *new_script_action + = new_menu->addAction (QIcon(":/actions/icons/filenew.png"), tr ("Script")); + new_script_action->setShortcut (Qt::ControlModifier + Qt::Key_N); + + QAction *new_function_action = new_menu->addAction (tr ("Function")); + new_function_action->setEnabled (false); // TODO: Make this work. + QAction *new_class_action = new_menu->addAction (tr ("Class")); + new_class_action->setEnabled (false); // TODO: Make this work. + QAction *new_enumeration_action = new_menu->addAction (tr ("Enumeration")); + new_enumeration_action->setEnabled (false); // TODO: Make this work. + QAction *new_figure_action = new_menu->addAction (tr ("Figure")); + new_figure_action->setEnabled (false); // TODO: Make this work. + QAction *new_variable_action = new_menu->addAction (tr ("Variable")); + new_variable_action->setEnabled (false); // TODO: Make this work. + QAction *new_model_action = new_menu->addAction (tr ("Model")); + new_model_action->setEnabled (false); // TODO: Make this work. + QAction *new_gui_action = new_menu->addAction (tr ("GUI")); + new_gui_action->setEnabled (false); // TODO: Make this work. + + QAction *open_action + = file_menu->addAction (QIcon(":/actions/icons/fileopen.png"), tr ("Open...")); + open_action->setShortcut (Qt::ControlModifier + Qt::Key_O); + + QAction *close_command_window_action + = file_menu->addAction (tr ("Close Command Window")); + close_command_window_action->setShortcut (Qt::ControlModifier + Qt::Key_W); + close_command_window_action->setEnabled (false); // TODO: Make this work. + + file_menu->addSeparator (); + QAction *import_data_action + = file_menu->addAction (tr ("Import Data...")); + import_data_action->setEnabled (false); // TODO: Make this work. + + QAction *save_workspace_action + = file_menu->addAction (tr ("Save Workspace...")); + save_workspace_action->setShortcut (Qt::ControlModifier + Qt::Key_S); + file_menu->addSeparator (); + + QAction *preferences_action + = file_menu->addAction (QIcon(":/actions/icons/configure.png"), + tr ("Preferences...")); + file_menu->addSeparator (); + QAction *page_setup_action + = file_menu->addAction (tr ("Page Setup...")); + page_setup_action->setEnabled (false); // TODO: Make this work. + QAction *print_action + = file_menu->addAction (tr ("Print")); + print_action->setShortcut (Qt::ControlModifier + Qt::Key_P); + print_action->setEnabled (false); // TODO: Make this work. + QAction *print_selection_action + = file_menu->addAction (tr ("Print Selection...")); + print_selection_action->setEnabled (false); // TODO: Make this work. + + file_menu->addSeparator (); + QAction *exit_action = file_menu->addAction (tr ("Exit")); + exit_action->setShortcut (Qt::ControlModifier + Qt::Key_Q); + + + QMenu *edit_menu = menuBar ()->addMenu (tr ("&Edit")); + QAction *undo_action + = edit_menu->addAction (QIcon(":/actions/icons/undo.png"), tr ("Undo")); + undo_action->setShortcut (QKeySequence::Undo); + + QAction *redo_action + = edit_menu->addAction (QIcon(":/actions/icons/redo.png"), tr ("Redo")); + redo_action->setShortcut (QKeySequence::Redo); + edit_menu->addSeparator (); + + QAction *cut_action + = edit_menu->addAction (QIcon(":/actions/icons/editcut.png"), tr ("Cut")); + cut_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_X); + + QAction *copy_action + = edit_menu->addAction (QIcon(":/actions/icons/editcopy.png"), tr ("Copy")); + copy_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_C); + + QAction *paste_action + = edit_menu->addAction (QIcon(":/actions/icons/editpaste.png"), tr ("Paste")); + paste_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_V); + + QAction *paste_to_workspace_action + = edit_menu->addAction (tr ("Paste To Workspace...")); + paste_to_workspace_action->setEnabled (false); // TODO: Make this work. + edit_menu->addSeparator (); + + QAction *select_all_action + = edit_menu->addAction (tr ("Select All")); + select_all_action->setEnabled (false); // TODO: Make this work. + QAction *delete_action + = edit_menu->addAction (tr ("Delete")); + delete_action->setShortcut (Qt::Key_Delete); + delete_action->setEnabled (false); // TODO: Make this work. + edit_menu->addSeparator (); + + QAction *find_action + = edit_menu->addAction (tr ("Find...")); + find_action->setEnabled (false); // TODO: Make this work. + QAction *find_files_action + = edit_menu->addAction (tr ("Find Files...")); + find_files_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + + Qt::Key_F); + find_files_action->setEnabled (false); // TODO: Make this work. + edit_menu->addSeparator (); + + QAction *clear_command_window_action + = edit_menu->addAction (tr ("Clear Command Window")); + clear_command_window_action->setEnabled (false); // TODO: Make this work. + QAction *clear_command_history + = edit_menu->addAction(tr ("Clear Command History")); + QAction * clear_workspace_action + = edit_menu->addAction (tr ("Clear Workspace")); + + _debug_menu = menuBar ()->addMenu (tr ("De&bug")); + + _debug_step_over = _debug_menu->addAction (QIcon (":/actions/icons/db_step.png"), tr ("Step")); + _debug_step_over->setEnabled (false); + _file_editor->debug_menu ()->addAction (_debug_step_over); + _file_editor->toolbar ()->addAction (_debug_step_over); + _debug_step_over->setShortcut (Qt::Key_F10); + + _debug_step_into = _debug_menu->addAction (QIcon (":/actions/icons/db_step_in.png"), tr ("Step in")); + _debug_step_into->setEnabled (false); + _file_editor->debug_menu ()->addAction (_debug_step_into); + _file_editor->toolbar ()->addAction (_debug_step_into); + _debug_step_into->setShortcut (Qt::Key_F11); + + _debug_step_out = _debug_menu->addAction (QIcon (":/actions/icons/db_step_out.png"), tr ("Step out")); + _debug_step_out->setEnabled (false); + _file_editor->debug_menu ()->addAction (_debug_step_out); + _file_editor->toolbar ()->addAction (_debug_step_out); + _debug_step_out->setShortcut (Qt::ShiftModifier + Qt::Key_F11); + + _debug_continue = _debug_menu->addAction (QIcon (":/actions/icons/db_cont.png"), tr ("Continue")); + _debug_continue->setEnabled (false); + _file_editor->debug_menu ()->addAction (_debug_continue); + _file_editor->toolbar ()->addAction (_debug_continue); + _debug_continue->setShortcut (Qt::Key_F5); + + _debug_menu->addSeparator (); + _file_editor->debug_menu ()->addSeparator (); + + _debug_quit = _debug_menu->addAction (QIcon (":/actions/icons/db_stop.png"), tr ("Exit Debug Mode")); + _debug_quit->setEnabled (false); + _file_editor->debug_menu ()->addAction (_debug_quit); + _file_editor->toolbar ()->addAction (_debug_quit); + _debug_quit->setShortcut (Qt::ShiftModifier + Qt::Key_F5); + + //QMenu *parallelMenu = menuBar ()->addMenu (tr ("&Parallel")); + + QMenu * desktop_menu = menuBar ()->addMenu (tr ("&Desktop")); + QAction * load_workspace_action = desktop_menu->addAction (tr ("Load workspace")); + + + // Window menu + QMenu * window_menu = menuBar ()->addMenu (tr ("&Window")); + QAction * show_command_window_action + = window_menu->addAction (tr ("Show Command Window")); + show_command_window_action->setCheckable (true); + show_command_window_action->setShortcut (Qt::ControlModifier + + Qt::ShiftModifier + Qt::Key_0); + + QAction * show_history_action + = window_menu->addAction (tr ("Show Command History")); + show_history_action->setCheckable (true); + show_history_action->setShortcut (Qt::ControlModifier + + Qt::ShiftModifier + Qt::Key_1); + QAction * show_file_browser_action + = window_menu->addAction (tr ("Show Current Directory")); + show_file_browser_action->setCheckable (true); + show_file_browser_action->setShortcut (Qt::ControlModifier + + Qt::ShiftModifier + Qt::Key_2); + + QAction * show_workspace_action + = window_menu->addAction (tr ("Show Workspace")); + show_workspace_action->setCheckable (true); + show_workspace_action->setShortcut (Qt::ControlModifier + + Qt::ShiftModifier + Qt::Key_3); + + QAction * show_editor_action = window_menu->addAction (tr ("Show Editor")); + show_editor_action->setCheckable (true); + show_editor_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + + Qt::Key_4); + + QAction * show_documentation_action = window_menu->addAction (tr ("Show Documentation")); + show_documentation_action->setCheckable (true); + show_documentation_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + + Qt::Key_5); + window_menu->addSeparator (); + + QAction * command_window_action + = window_menu->addAction (tr ("Command Window")); + command_window_action->setShortcut (Qt::ControlModifier + Qt::Key_0); + + QAction * history_action + = window_menu->addAction (tr ("Command History")); + history_action->setShortcut (Qt::ControlModifier + Qt::Key_1); + + QAction * file_browser_action + = window_menu->addAction (tr ("Current Directory")); + file_browser_action->setShortcut (Qt::ControlModifier + Qt::Key_2); + + QAction * workspace_action + = window_menu->addAction (tr ("Workspace")); + workspace_action->setShortcut (Qt::ControlModifier + Qt::Key_3); + + QAction * editor_action + = window_menu->addAction (tr ("Editor")); + editor_action->setShortcut (Qt::ControlModifier + Qt::Key_4); + + QAction * documentation_action + = window_menu->addAction (tr ("Documentation")); + documentation_action->setShortcut (Qt::ControlModifier + Qt::Key_5); + + window_menu->addSeparator (); + QAction * reset_windows_action + = window_menu->addAction (tr ("Reset Windows")); + reset_windows_action->setEnabled (false); // TODO: Make this work. + + // Help menu + QMenu * help_menu = menuBar ()->addMenu (tr ("&Help")); + QAction * report_bug_action + = help_menu->addAction (tr ("Report Bug")); + QAction * agora_action + = help_menu->addAction (tr ("Visit Agora")); + QAction * octave_forge_action + = help_menu->addAction (tr ("Visit Octave Forge")); + help_menu->addSeparator (); + + QAction * about_octave_action + = help_menu->addAction (tr ("About Octave")); + + // Toolbars + QToolBar *main_tool_bar = addToolBar ("Main"); + main_tool_bar->addAction (new_script_action); + main_tool_bar->addAction (open_action); + main_tool_bar->addSeparator (); + main_tool_bar->addAction (cut_action); + main_tool_bar->addAction (copy_action); + main_tool_bar->addAction (paste_action); + main_tool_bar->addAction (undo_action); + main_tool_bar->addAction (redo_action); + main_tool_bar->addSeparator (); + main_tool_bar->addWidget (new QLabel (tr ("Current Directory:"))); + main_tool_bar->addWidget (_current_directory_combo_box); + main_tool_bar->addWidget (_current_directory_tool_button); + main_tool_bar->addWidget (_current_directory_up_tool_button); + + connect (qApp, SIGNAL (aboutToQuit ()), + this, SLOT (prepare_for_quit ())); + connect (preferences_action, SIGNAL (triggered ()), + this, SLOT (process_settings_dialog_request ())); + connect (exit_action, SIGNAL (triggered ()), + this, SLOT (close ())); + connect (new_script_action, SIGNAL (triggered ()), + this, SLOT (new_file ())); + connect (open_action, SIGNAL (triggered ()), + this, SLOT (open_file ())); + connect (report_bug_action, SIGNAL (triggered ()), + this, SLOT (open_bug_tracker_page ())); + connect (agora_action, SIGNAL (triggered ()), + this, SLOT (open_agora_page ())); + connect (octave_forge_action, SIGNAL (triggered ()), + this, SLOT (open_octave_forge_page ())); + connect (about_octave_action, SIGNAL (triggered ()), + this, SLOT (show_about_octave ())); + connect (show_command_window_action, SIGNAL (toggled (bool)), + _terminal_dock_widget, SLOT (setVisible (bool))); + connect (_terminal_dock_widget, SIGNAL (active_changed (bool)), + show_command_window_action, SLOT (setChecked (bool))); + connect (show_workspace_action, SIGNAL (toggled (bool)), + _workspace_view, SLOT (setVisible (bool))); + connect (_workspace_view, SIGNAL (active_changed (bool)), + show_workspace_action, SLOT (setChecked (bool))); + connect (show_history_action, SIGNAL (toggled (bool)), + _history_dock_widget, SLOT (setVisible (bool))); + connect (_history_dock_widget, SIGNAL (active_changed (bool)), + show_history_action, SLOT (setChecked (bool))); + connect (show_file_browser_action, SIGNAL (toggled (bool)), + _files_dock_widget, SLOT (setVisible (bool))); + connect (_files_dock_widget, SIGNAL (active_changed (bool)), + show_file_browser_action, SLOT (setChecked (bool))); + connect (show_editor_action, SIGNAL (toggled (bool)), + _file_editor, SLOT (setVisible (bool))); + connect (_file_editor, SIGNAL (active_changed (bool)), + show_editor_action, SLOT (setChecked (bool))); + connect (show_documentation_action, SIGNAL (toggled (bool)), + _documentation_dock_widget, SLOT (setVisible (bool))); + connect (_documentation_dock_widget, SIGNAL (active_changed (bool)), + show_documentation_action, SLOT (setChecked (bool))); + + connect (command_window_action, SIGNAL (triggered ()), + this, SLOT (focus_command_window ())); + connect (workspace_action, SIGNAL (triggered ()), + this, SLOT (focus_workspace ())); + connect (history_action, SIGNAL (triggered ()), + this, SLOT (focus_command_history ())); + connect (file_browser_action, SIGNAL (triggered ()), + this, SLOT (focus_current_directory ())); + connect (editor_action, SIGNAL (triggered ()), + this, SLOT (focus_editor ())); + connect (documentation_action, SIGNAL (triggered ()), + this, SLOT (focus_documentation ())); + + connect (reset_windows_action, SIGNAL (triggered ()), + this, SLOT (reset_windows ())); + connect (this, SIGNAL (settings_changed ()), + _files_dock_widget, SLOT (notice_settings ())); + connect (this, SIGNAL (settings_changed ()), + this, SLOT (notice_settings ())); + connect (_files_dock_widget, SIGNAL (open_file (QString)), + this, SLOT (open_file (QString))); + connect (_files_dock_widget, SIGNAL (displayed_directory_changed(QString)), + this, SLOT (set_current_working_directory(QString))); + connect (_history_dock_widget, SIGNAL (information (QString)), + this, SLOT (report_status_message (QString))); + connect (_history_dock_widget, SIGNAL (command_double_clicked (QString)), + this, SLOT (handle_command_double_clicked (QString))); + connect (save_workspace_action, SIGNAL (triggered ()), + this, SLOT (handle_save_workspace_request ())); + connect (load_workspace_action, SIGNAL (triggered ()), + this, SLOT (handle_load_workspace_request ())); + connect (clear_workspace_action, SIGNAL (triggered ()), + this, SLOT (handle_clear_workspace_request ())); + connect (_current_directory_tool_button, SIGNAL (clicked ()), + this, SLOT (change_current_working_directory ())); + connect (_current_directory_up_tool_button, SIGNAL (clicked ()), + this, SLOT (current_working_directory_up())); + connect (copy_action, SIGNAL (triggered()), + _terminal, SLOT (copyClipboard ())); + connect (paste_action, SIGNAL (triggered()), + _terminal, SLOT (pasteClipboard ())); + connect (_current_directory_combo_box, SIGNAL (activated (QString)), + this, SLOT (set_current_working_directory (QString))); + connect (_debug_continue, SIGNAL (triggered ()), + this, SLOT (debug_continue ())); + connect (_debug_step_into, SIGNAL (triggered ()), + this, SLOT (debug_step_into ())); + connect (_debug_step_over, SIGNAL (triggered ()), + this, SLOT (debug_step_over ())); + connect (_debug_step_out, SIGNAL (triggered ()), + this, SLOT (debug_step_out ())); + connect (_debug_quit, SIGNAL (triggered ()), + this, SLOT (debug_quit ())); + + connect (clear_command_history, SIGNAL (triggered ()), + this, SLOT (handle_clear_history_request ())); + + setWindowTitle ("Octave"); + setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks); + addDockWidget (Qt::LeftDockWidgetArea, _workspace_view); + addDockWidget (Qt::LeftDockWidgetArea, _history_dock_widget); + addDockWidget (Qt::RightDockWidgetArea, _files_dock_widget); + addDockWidget (Qt::RightDockWidgetArea, _file_editor); + addDockWidget (Qt::BottomDockWidgetArea, _terminal_dock_widget); + addDockWidget (Qt::RightDockWidgetArea, _documentation_dock_widget); + setStatusBar (_status_bar); + read_settings (); + + _octave_qt_event_listener = new octave_qt_event_listener (); + octave_link::instance ()->register_event_listener (_octave_qt_event_listener); + + connect (_octave_qt_event_listener, + SIGNAL (current_directory_has_changed_signal (QString)), + this, + SLOT (current_working_directory_has_changed (QString))); + + connect (_octave_qt_event_listener, + SIGNAL (entered_debug_mode_signal ()), + this, + SLOT(handle_entered_debug_mode ())); + + connect (_octave_qt_event_listener, + SIGNAL (quit_debug_mode_signal ()), + this, + SLOT (handle_quit_debug_mode ())); +} + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/main-window.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/main-window.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,156 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Editor includes +#include "file-editor-interface.h" + +// QTerminal includes +#include "QTerminal.h" + +// Own includes +#include "resource-manager.h" +#include "octave-link.h" +#include "workspace-view.h" +#include "history-dockwidget.h" +#include "files-dockwidget.h" +#include "terminal-dockwidget.h" +#include "documentation-dockwidget.h" +#include "octave-qt-event-listener.h" +#include "octave-event-observer.h" + +/** + * \class MainWindow + * + * Represents the main window. + */ +class main_window + : public QMainWindow, public octave_event_observer +{ +Q_OBJECT public: + main_window (QWidget * parent = 0); + ~main_window (); + + void event_accepted (octave_event *e); + void event_reject (octave_event *e); + + QTerminal *get_terminal_view () { return _terminal; } + history_dock_widget *get_history_dock_widget () + { + return _history_dock_widget; + } + files_dock_widget *get_files_dock_widget () + { + return _files_dock_widget; + } + bool is_closing () { return _closing; } + +signals: + void settings_changed (); + +public slots: + void report_status_message (QString statusMessage); + void handle_save_workspace_request (); + void handle_load_workspace_request (); + void handle_clear_workspace_request (); + void handle_clear_history_request (); + void handle_command_double_clicked (QString command); + void new_file (); + void open_file (); + void open_file (QString file_name); + void open_bug_tracker_page (); + void open_agora_page (); + void open_octave_forge_page (); + void process_settings_dialog_request (); + void show_about_octave (); + void notice_settings (); + void prepare_for_quit (); + void reset_windows (); + void current_working_directory_has_changed (QString directory); + void change_current_working_directory (); + void set_current_working_directory (QString directory); + void current_working_directory_up (); + + void focus_command_window (); + void focus_command_history (); + void focus_current_directory (); + void focus_workspace (); + void focus_editor (); + void focus_documentation (); + + void handle_entered_debug_mode (); + void handle_quit_debug_mode (); + void debug_continue (); + void debug_step_into (); + void debug_step_over (); + void debug_step_out (); + void debug_quit (); + +protected: + void closeEvent (QCloseEvent * closeEvent); + void read_settings (); + void write_settings (); + +private: + void construct (); + void establish_octave_link (); + + QTerminal * _terminal; + file_editor_interface * _file_editor; + QMenu * _debug_menu; + + QAction * _debug_continue; + QAction * _debug_step_into; + QAction * _debug_step_over; + QAction * _debug_step_out; + QAction * _debug_quit; + + // Dock widgets. + workspace_view * _workspace_view; + history_dock_widget * _history_dock_widget; + files_dock_widget * _files_dock_widget; + terminal_dock_widget * _terminal_dock_widget; + documentation_dock_widget*_documentation_dock_widget; + + // Toolbars. + QStatusBar * _status_bar; + QComboBox * _current_directory_combo_box; + QToolButton * _current_directory_tool_button; + QToolButton * _current_directory_up_tool_button; + + octave_qt_event_listener *_octave_qt_event_listener; + + // Flag for closing whole application + bool _closing; +}; + +#endif // MAINWINDOW_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/msvc-debug.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/msvc-debug.pri Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,24 @@ +# OctaveGUI - A graphical user interface for Octave +# Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) +# +# 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 . + +win32-msvc* { + CONFIG += release warn_off + QMAKE_CXXFLAGS += -MP + QMAKE_CXXFLAGS_RELEASE += -Zi + QMAKE_CXXFLAGS_RELEASE -= -O2 + QMAKE_LFLAGS_RELEASE += -debug + QMAKE_CLEAN += $(DESTDIR)$(QMAKE_TARGET).pdb +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/msvc.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/msvc.pri Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,11 @@ +CONFIG += release + +QMAKE_CXXFLAGS += -MP +LIBDIR_SUFFIX = release + +msvc-debug { + QMAKE_CXXFLAGS_RELEASE += -Zi + QMAKE_CXXFLAGS_RELEASE -= -O2 + QMAKE_LFLAGS_RELEASE += -debug + QMAKE_CLEAN += $(DESTDIR)$(QMAKE_TARGET).pdb +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-adapter/octave-event-listener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-adapter/octave-event-listener.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,36 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef OCTAVEEVENTLISTENER_H +#define OCTAVEEVENTLISTENER_H + +#include + +class octave_event_listener +{ + public: + octave_event_listener () { } + virtual ~octave_event_listener () { } + + virtual void current_directory_has_changed (std::string directory) = 0; + virtual void about_to_exit () = 0; + + virtual void entered_debug_mode () = 0; + virtual void quit_debug_mode () = 0; +}; + +#endif // OCTAVEEVENTLISTENER_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-adapter/octave-event-observer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-adapter/octave-event-observer.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,48 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef OCTAVEEVENTOBSERVER_H +#define OCTAVEEVENTOBSERVER_H + +class octave_event; + +/** + * \class octave_event_observer + * \brief Implements the observer part for the observer pattern. + */ +class octave_event_observer +{ + public: + octave_event_observer () { } + virtual ~octave_event_observer () { } + + /** + * This will be called when an event has been accepted. Operations + * in this routine will be processed in the octave thread. + */ + virtual void event_accepted (octave_event *e) = 0; + + /** + * This will be called when an event has been rejected. Operations + * in this routine will be processed in the octave thread. + */ + virtual void event_reject (octave_event *e) = 0; +}; + +#include "octave-event.h" + +#endif // OCTAVEEVENTOBSERVER_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-adapter/octave-event.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-adapter/octave-event.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,170 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 John P. Swensen, Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "cmd-hist.h" +#include "oct-env.h" + +#include "debug.h" +#include "oct-obj.h" +#include "parse.h" +#include "symtab.h" +#include "toplev.h" + +#include "octave-event.h" + +#include + +void +octave_event::call_octave_function (std::string name) +{ + call_octave_function (name, octave_value_list ()); +} + +void +octave_event::call_octave_function (std::string name, + const octave_value_list& args, + int nargout) +{ + try + { + feval (name, args, nargout); + } catch (...) { } // Ignore exceptions. Crashes without that. +} + +void +octave_event::finish_readline_event () const +{ + rl_line_buffer[0] = '\0'; + rl_point = rl_end = 0; + rl_done = 1; + //rl_forced_update_display (); +} + +bool +octave_clear_history_event::perform () +{ + int i; + while ((i = command_history::length ()) > 0) { + command_history::remove (i - 1); + } + return true; +} + +bool +octave_debug_step_into_event::perform () +{ + octave_value_list args; + args.append (octave_value ("in")); + call_octave_function ("dbstep", args); + finish_readline_event (); + return true; +} + +bool +octave_debug_step_out_event::perform () +{ + octave_value_list args; + args.append (octave_value ("out")); + call_octave_function ("dbstep", args); + finish_readline_event (); + return true; +} + + +bool +octave_exit_event::perform () +{ + clean_up_and_exit (0); + return true; +} + +bool +octave_run_file_event::perform () +{ + octave_value_list args; + args.append (octave_value (_file)); + call_octave_function ("run", args); + finish_readline_event (); + return true; +} + +bool +octave_change_directory_event::perform () +{ + return octave_env::chdir (_directory); +} + +bool +octave_load_workspace_event::perform () +{ + octave_value_list args; + args.append (octave_value (_file)); + call_octave_function ("load", args); + return true; +} + +bool +octave_save_workspace_event::perform () +{ + octave_value_list args; + args.append (octave_value (_file)); + call_octave_function ("save", args); + return true; +} + +bool +octave_add_breakpoint_event::perform () +{ + bp_table::intmap intmap; + intmap[0] = _line + 1; + + std::string previous_directory = octave_env::get_current_directory (); + octave_env::chdir (_path); + intmap = bp_table::add_breakpoint (_function_name, intmap); + octave_env::chdir (previous_directory); + return intmap.size () > 0; +} + +bool +octave_remove_breakpoint_event::perform () +{ + bp_table::intmap intmap; + intmap[0] = _line; + + std::string previous_directory = octave_env::get_current_directory (); + octave_env::chdir (_path); + bp_table::remove_breakpoint (_function_name, intmap); + octave_env::chdir (previous_directory); + return true; // TODO: Check result. +} + +bool +octave_remove_all_breakpoints_event::perform () +{ + bp_table::intmap intmap; + std::string previous_directory = octave_env::get_current_directory (); + octave_env::chdir (_path); + intmap = bp_table::remove_all_breakpoints_in_file (_function_name, true); + octave_env::chdir (previous_directory); + return intmap.size() > 0; +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-adapter/octave-event.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-adapter/octave-event.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,377 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef OCTAVEEVENT_H +#define OCTAVEEVENT_H + +#include + +class octave_value_list; + +#include "octave-event-observer.h" + +/** + * \class octave_event + * \brief Base class for an octave event. + * In order to make communication with octave threadsafe, comunication is + * implemented via events. An application may create events and post them, + * however there is no guarantee events will be processed in a given time. + * + * In order to create an event, there must be an event observer. The event + * observer will be given the opportunity to react on the event as soon as + * it has been processed in the octave thread. Accepting and ignoring takes + * places in the octave thread. + */ +class octave_event +{ + public: + octave_event (octave_event_observer& o) + : _octave_event_observer (o) + { } + + virtual ~octave_event () + { } + + /** Performs what is necessary to make this event happen. This + * code is thread-safe since it will be executed in the octave + * thread. However, you should take care to keep this code as + * short as possible. */ + virtual bool perform () = 0; + + /** + * Accepts this event. This allows the event observer to react properly + * onto the event. + */ + void accept () + { _octave_event_observer.event_accepted (this); } + + /** + * Rejects this event. This allows the event observer to react properly + * onto the event. + */ + void reject () + { _octave_event_observer.event_reject (this); } + + protected: + void call_octave_function (std::string name); + + void call_octave_function (std::string name, + const octave_value_list& args, + int nargout = 0); + + void finish_readline_event () const; + + private: + octave_event_observer& _octave_event_observer; +}; + +class octave_update_history_event : public octave_event +{ + public: + /** Creates a new octave_exit_event. */ + octave_update_history_event (octave_event_observer& o) + : octave_event (o) + { } + + bool perform () + { return true; /* Always grant. */ } +}; + +class octave_update_workspace_event : public octave_event +{ + public: + /** Creates a new octave_exit_event. */ + octave_update_workspace_event (octave_event_observer& o) + : octave_event (o) + { } + + bool perform () + { return true; /* Always grant. */ } +}; + +/** Implements an octave exit event. */ +class octave_exit_event : public octave_event +{ + public: + /** Creates a new octave_exit_event. */ + octave_exit_event (octave_event_observer& o) + : octave_event (o) + { } + + bool perform (); +}; + +/** Implements an octave run file event. */ +class octave_run_file_event : public octave_event +{ + public: + /** Creates a new octave_run_file_event. */ + octave_run_file_event (octave_event_observer& o, + std::string file) + : octave_event (o) + { _file = file; } + + bool perform (); + + private: + std::string _file; +}; + +/** Implements a change directory event. */ +class octave_change_directory_event : public octave_event +{ + public: + /** Creates a new octave_change_directory_event. */ + octave_change_directory_event (octave_event_observer& o, + std::string directory) + : octave_event (o) + { _directory = directory; } + + bool perform (); + + private: + std::string _directory; +}; + +/** Implements a clear workspace event. */ +class octave_clear_workspace_event : public octave_event +{ + public: + /** Creates a new octave_run_file_event. */ + octave_clear_workspace_event (octave_event_observer& o) + : octave_event (o) + { } + + bool perform () + { + call_octave_function ("clear"); + return true; + } +}; + +/** Implements a load workspace event. */ +class octave_load_workspace_event : public octave_event +{ + public: + /** Creates a new octave_change_directory_event. */ + octave_load_workspace_event (octave_event_observer& o, + std::string file) + : octave_event (o) + { _file = file; } + + bool perform (); + + private: + std::string _file; +}; + +/** Implements a save workspace event. */ +class octave_save_workspace_event : public octave_event +{ + public: + /** Creates a new octave_change_directory_event. */ + octave_save_workspace_event (octave_event_observer& o, + std::string file) + : octave_event (o) + { _file = file; } + + bool perform (); + + private: + std::string _file; +}; + +class octave_clear_history_event : public octave_event +{ + public: + /** Creates a new octave_clear_history_event. */ + octave_clear_history_event (octave_event_observer& o) + : octave_event (o) + { } + + bool perform (); +}; + +class octave_add_breakpoint_event : public octave_event +{ + public: + octave_add_breakpoint_event (octave_event_observer& o, + std::string path, + std::string function_name, + int line) + : octave_event (o) + { + _path = path; + _function_name = function_name; + _line = line; + } + + bool perform (); + + std::string get_path () + { + return _path; + } + + std::string get_function_name () + { + return _function_name; + } + + int get_line () + { + return _line; + } + + private: + std::string _path; + std::string _function_name; + int _line; +}; + +class octave_remove_breakpoint_event : public octave_event +{ + public: + octave_remove_breakpoint_event (octave_event_observer& o, + std::string path, + std::string function_name, + int line) + : octave_event (o) + { + _path = path; + _function_name = function_name; + _line = line; + } + + bool perform (); + + std::string get_path () + { + return _path; + } + + std::string get_function_name () + { + return _function_name; + } + + int get_line () + { + return _line; + } + + private: + std::string _path; + std::string _function_name; + int _line; +}; + +class octave_remove_all_breakpoints_event : public octave_event +{ + public: + octave_remove_all_breakpoints_event (octave_event_observer& o, + std::string path, + std::string function_name) + : octave_event (o) + { + _path = path; + _function_name = function_name; + } + + bool perform (); + + std::string get_path () + { + return _path; + } + + std::string get_function_name () + { + return _function_name; + } + + private: + std::string _path; + std::string _function_name; +}; + +class octave_debug_step_into_event : public octave_event +{ + public: + /** Creates a new octave_debug_step_into_event. */ + octave_debug_step_into_event (octave_event_observer& o) + : octave_event (o) { } + + bool perform (); +}; + +class octave_debug_step_over_event : public octave_event +{ + public: + /** Creates a new octave_debug_step_over_event. */ + octave_debug_step_over_event (octave_event_observer& o) + : octave_event (o) { } + + bool perform () + { + call_octave_function ("dbnext"); + finish_readline_event (); + return true; + } +}; + +class octave_debug_step_out_event : public octave_event +{ + public: + /** Creates a new octave_debug_step_out_event. */ + octave_debug_step_out_event (octave_event_observer& o) + : octave_event (o) { } + + bool perform (); +}; + +class octave_debug_continue_event : public octave_event +{ + public: + /** Creates a new octave_debug_step_out_event. */ + octave_debug_continue_event (octave_event_observer& o) + : octave_event (o) { } + + bool perform () + { + call_octave_function ("dbcont"); + finish_readline_event (); + return true; + } +}; + +class octave_debug_quit_event : public octave_event +{ + public: + /** Creates a new octave_debug_step_out_event. */ + octave_debug_quit_event (octave_event_observer& o) + : octave_event (o) { } + + bool perform () + { + call_octave_function ("dbquit"); + finish_readline_event (); + return true; + } +}; + +#endif // OCTAVEEVENT_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-adapter/octave-link.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-adapter/octave-link.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,161 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 John P. Swensen, Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "cmd-edit.h" +#include "oct-env.h" +#include "oct-mutex.h" +#include "symtab.h" +#include "toplev.h" + +#include "octave-link.h" + +int octave_readline_hook () +{ + octave_link::instance ()->entered_readline_hook (); + octave_link::instance ()->generate_events (); + octave_link::instance ()->process_events (); + octave_link::instance ()->finished_readline_hook (); + return 0; +} + +void octave_exit_hook (int status) +{ + (void) status; + octave_link::instance ()->about_to_exit (); +} + +octave_link octave_link::_singleton; + +octave_link::octave_link () +{ + _event_queue_mutex = new octave_mutex (); + _last_working_directory = ""; + _debugging_mode_active = false; +} + +octave_link::~octave_link () +{ +} + +void +octave_link::launch_octave () +{ + // Create both threads. + _octave_main_thread = new octave_main_thread (); + command_editor::add_event_hook (octave_readline_hook); + octave_exit = octave_exit_hook; + + // Start the first one. + _octave_main_thread->start (); +} + +void +octave_link::register_event_listener (octave_event_listener *oel) +{ _octave_event_listener = oel; } + +void +octave_link::generate_events () +{ + std::string current_working_directory = octave_env::get_current_directory (); + if (current_working_directory != _last_working_directory) + { + _last_working_directory = current_working_directory; + if (_octave_event_listener) + _octave_event_listener + ->current_directory_has_changed (_last_working_directory); + } + + if (_debugging_mode_active != Vdebugging) + { + _debugging_mode_active = Vdebugging; + if (_octave_event_listener) + { + if (_debugging_mode_active) + _octave_event_listener->entered_debug_mode (); + else + _octave_event_listener->quit_debug_mode (); + } + } +} + +void +octave_link::process_events () +{ + _event_queue_mutex->lock (); + + while (_event_queue.size () > 0) + { + octave_event * e = _event_queue.front (); + _event_queue.pop (); + if (e->perform ()) + e->accept (); + else + e->reject (); + } + _event_queue_mutex->unlock (); +} + +void +octave_link::post_event (octave_event *e) +{ + if (e) + { + _event_queue_mutex->lock (); + _event_queue.push (e); + _event_queue_mutex->unlock (); + } +} + +void +octave_link::event_accepted (octave_event *e) +{ delete e; } + +void +octave_link::event_reject (octave_event *e) +{ delete e; } + +void +octave_link::about_to_exit () +{ + _event_queue_mutex->lock (); + while (!_event_queue.empty ()) + _event_queue.pop (); + + _event_queue_mutex->unlock (); + + if (_octave_event_listener) + _octave_event_listener->about_to_exit (); +} + +void +octave_link::entered_readline_hook () +{ } + +void +octave_link::finished_readline_hook () +{ +} + +std::string +octave_link::get_last_working_directory () +{ + return _last_working_directory; +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-adapter/octave-link.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-adapter/octave-link.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,88 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 John P. Swensen, Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef OCTAVELINK_H +#define OCTAVELINK_H + +#include +#include + +class octave_mutex; + +#include "octave-main-thread.h" +#include "octave-event.h" +#include "octave-event-observer.h" +#include "octave-event-listener.h" + +/** + * \class OctaveLink + * \brief Provides threadsafe access to octave. + * \author Jacob Dawid + * This class is a wrapper around octave and provides threadsafety by + * buffering access operations to octave and executing them in the readline + * event hook, which lives in the octave thread. + */ +class octave_link : public octave_event_observer +{ +public: + /** Provides a way to access the unique octave_link object. */ + static octave_link * instance () { return &_singleton; } + + /** Starts octave. */ + void launch_octave (); + void register_event_listener (octave_event_listener *oel); + + void generate_events (); + void process_events (); + void post_event (octave_event *e); + void event_accepted (octave_event *e); + void event_reject (octave_event *e); + + void about_to_exit (); + + void entered_readline_hook (); + void finished_readline_hook (); + + std::string get_last_working_directory (); + +private: + /** Singleton. */ + octave_link (); + ~octave_link (); + + octave_event_listener *_octave_event_listener; + + /** Thread running octave_main. */ + octave_main_thread *_octave_main_thread; + + /** Semaphore to lock access to the event queue. */ + octave_mutex *_event_queue_mutex; + + /** Buffer for queueing events until they will be processed. */ + std::queue _event_queue; + + /** Stores the last known current working directory of octave. */ + std::string _last_working_directory; + bool _debugging_mode_active; + + /** Semaphore to lock access to the performance information. */ + octave_mutex *_performance_information_mutex; + + /** Unique instance. Singelton! */ + static octave_link _singleton; +}; +#endif // OCTAVELINK_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-adapter/octave-main-thread.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-adapter/octave-main-thread.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,39 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "octave.h" + +#include "octave-main-thread.h" +#include "octave-link.h" + +octave_main_thread::octave_main_thread () : QThread () +{ +} + +void +octave_main_thread::run () +{ + setlocale (LC_ALL, "en_US.UTF-8"); + emit ready (); + octave_execute_interpreter (); +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-adapter/octave-main-thread.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-adapter/octave-main-thread.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,45 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef OCTAVEMAINTHREAD_H +#define OCTAVEMAINTHREAD_H + +#include + +/** + * \class octave_main + * \brief This class represents a thread just running octave_main. + * \author Jacob Dawid + */ +class octave_main_thread : public QThread +{ + Q_OBJECT +public: + /** Creates a new thread running octave_main. */ + octave_main_thread (); + +signals: + /** This signal will be emitted when the thread is about to actually + * run octave_main. */ + void ready(); + +protected: + /** Runs octave_main. */ + void run (); +}; + +#endif // OCTAVEMAINTHREAD_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-gui.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-gui.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,105 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include + +#include "welcome-wizard.h" +#include "resource-manager.h" +#include "main-window.h" +#include "octave-gui.h" + +// Dissociate from the controlling terminal, if any. + +static void +dissociate_terminal (void) +{ +#if ! defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN) + + pid_t pid = fork (); + + if (pid < 0) + { + std::cerr << "fork failed!" << std::endl;; + exit (1); + } + else if (pid == 0) + { + // Child. + + if (setsid () < 0) + { + std::cerr << "setsid error" << std::endl; + exit (1); + } + } + else + { + // Parent + + int status; + + waitpid (pid, &status, 0); + + exit (WIFEXITED (status) ? WEXITSTATUS (status) : 127); + } + +#endif +} + +int +octave_start_gui (int argc, char *argv[]) +{ + dissociate_terminal (); + + QApplication application (argc, argv); + + while (true) + { + if (resource_manager::instance ()->is_first_run ()) + { + welcome_wizard welcomeWizard; + welcomeWizard.exec (); + resource_manager::instance ()->reload_settings (); + } + else + { + QSettings *settings = resource_manager::instance ()->get_settings (); + QString language = settings->value ("language").toString (); + + QString translatorFile = resource_manager::instance ()->find_translator_file (language); + QTranslator translator; + translator.load (translatorFile); + application.installTranslator (&translator); + + resource_manager::instance ()->update_network_settings (); + + main_window w; + w.show (); + return application.exec (); + } + } +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-gui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-gui.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,28 @@ +/* + +Copyright (C) 2012 John W. Eaton + +This file is part of Octave. + +Octave 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. + +Octave 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 Octave; see the file COPYING. If not, see +. + +*/ + +#if !defined (octave_octave_gui_h) +#define octave_octave_gui_h 1 + +extern int octave_start_gui (int argc, char **argv); + +#endif diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-qt-event-listener.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-qt-event-listener.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,46 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2012 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "octave-qt-event-listener.h" +#include + +octave_qt_event_listener::octave_qt_event_listener (QObject *parent) + : QObject (parent), octave_event_listener () +{ +} + +void +octave_qt_event_listener::current_directory_has_changed (std::string directory) +{ + emit current_directory_has_changed_signal + (QString::fromStdString (directory)); +} + +void +octave_qt_event_listener::about_to_exit () +{ + qApp->quit (); +} + +void +octave_qt_event_listener::entered_debug_mode () +{ emit entered_debug_mode_signal (); } + +void +octave_qt_event_listener::quit_debug_mode () +{ emit quit_debug_mode_signal (); } + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/octave-qt-event-listener.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/octave-qt-event-listener.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,44 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2012 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef OCTAVEQTEVENTLISTENER_H +#define OCTAVEQTEVENTLISTENER_H + +#include +#include +#include "octave-event-listener.h" + +class octave_qt_event_listener + : public QObject, public octave_event_listener +{ + Q_OBJECT + public: + octave_qt_event_listener (QObject *parent = 0); + + void current_directory_has_changed (std::string directory); + void about_to_exit (); + + void entered_debug_mode (); + void quit_debug_mode (); + + signals: + void current_directory_has_changed_signal (QString directory); + void entered_debug_mode_signal (); + void quit_debug_mode_signal (); +}; + +#endif // OCTAVEQTEVENTLISTENER_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/qtinfo/parser.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/qtinfo/parser.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,578 @@ +/* Copyright (C) 2009 P.L. Lucas + * Copyright (C) 2012 Jacob Dawid + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "parser.h" +#include +#include +#include +#include +#include +#include +#include + +parser::parser(QObject *parent) + : QObject(parent) +{ + _compressors_map.insert ("bz2", "bzip2 -dc \"%1\""); + _compressors_map.insert ("gz", "gzip -dc \"%1\""); + _compressors_map.insert ("lzma", "lzma -dc \"%1\""); + _compressors_map.insert ("xz", "xz -dc \"%1\""); + _compressors_map.insert ("Z", "gunzip -c \"%1\""); +} + +void +parser::set_info_path (QString infoPath) +{ + this->_info_path = infoPath; + + _info_files.clear (); + + QFileInfo info (infoPath); + + QString path = info.absolutePath (); + QString fileName = info.fileName (); + + QDir infoDir (path); + QStringList filter; + filter.append (fileName + "*"); + + _info_files = infoDir.entryInfoList (filter, QDir::Files); + parse_info_map (); +} + +QString +parser::get_info_path () +{ + return _info_path; +} + +QIODevice * +parser::open_file (QFileInfo & file_info) +{ + QIODevice *iodevice=NULL; + if ( _compressors_map.contains(file_info.suffix ())) + { + QProcess gzip; + gzip.start (_compressors_map.value (file_info.suffix ()).arg (file_info.absoluteFilePath ())); + + if (!gzip.waitForFinished ()) + return NULL; + + QByteArray result = gzip.readAll (); + + QBuffer *io = new QBuffer (this); + io->setData (result); + + if (!io->open (QIODevice::ReadOnly | QIODevice::Text)) + return NULL; + + iodevice = io; + } + else + { + QFile *io = new QFile (file_info.absoluteFilePath ()); + if (!io->open (QIODevice::ReadOnly | QIODevice::Text)) + return NULL; + iodevice = io; + } + + return iodevice; +} + +int +parser::is_ref (QString node) +{ + if (_ref_map.contains (node)) + { + node_position ref = _ref_map [node]; + + return ref.pos-_node_map [ref._node_name].pos; + } + return -1; +} + +QString +parser::search_node (QString node) +{ + QFileInfo file_info; + QString ref; + + if (_ref_map.contains (node)) + { + ref = node; + node = _ref_map [ref]._node_name; + } + + if (_node_map.contains (node)) + { + int pos = _node_map [node].pos; + int realPos; + + real_position (pos, file_info, realPos); + + QIODevice *io = open_file (file_info); + if (io == NULL) + { + return QString (); + } + + seek (io, realPos); + + QString text = get_next_node (io); + if (!text.isEmpty()) + { + return text; + } + + io->close (); + delete io; + } + + return QString (); +} + +QString +parser::search_node (QString node, QIODevice *io) +{ + while (!io->atEnd ()) + { + QString text = get_next_node (io); + if(node == get_node_name (text)) + { + return text; + } + } + + return QString (); +} + +QString +parser::get_next_node (QIODevice *io) +{ + QString text; + while (!io->atEnd ()) + { + QByteArray line = io->readLine (); + if (line.at(0) == 31) + { + break; + } + else + { + text.append (line); + } + } + return text; +} + +static QString +get_first_line (QString text) +{ + int n = text.indexOf ("\n"); + + if (n < 0) + { + return QString (); + } + + QString first_line = text.left (n); + return first_line; +} + +static QString +parser_node (QString text, QString node_name) +{ + QString firstLine = get_first_line (text); + QStringList nodes = firstLine.split (","); + for (int i = 0;i < nodes.size (); i++) + { + QString node = nodes.at (i).trimmed (); + + if (node.startsWith (node_name)) + { + return node.remove (0, node_name.size ()).trimmed (); + } + } + return QString (); +} + +QString +parser::get_node_name (QString text) +{ + return parser_node (text, "Node:"); +} + +QString +parser::get_node_up (QString text) +{ + return parser_node (text, "Up:"); +} + +QString +parser::get_node_next (QString text) +{ + return parser_node (text, "Next:"); +} + +QString +parser::get_node_prev (QString text) +{ + return parser_node (text, "Prev:"); +} + +static void +replace_links (QString &text) +{ + QRegExp re ("(\\*[N|n]ote|\n\\*)([ |\n]+)([^:]+):([^:\\.,]*)([:,\\.])"); + int i = 0, f; + + while ( (i = re.indexIn (text,i)) != -1) + { + QString type = re.cap (1); + QString note = re.cap (3); + QString url_link = re.cap (4); + QString link = re.cap (4); + + if (url_link.isEmpty ()) + { + url_link = note; + } + + url_link = url_link.trimmed (); + url_link.replace ("\n"," "); + url_link.replace (QRegExp (" +")," "); + url_link.replace ("",""); + url_link.replace ("",""); + url_link = QUrl::toPercentEncoding (url_link, "", "'"); + + QString href; + if (type=="\n*") + { + href="\n"; + } + else + { + href=""; + } + href += re.cap (2) + "" + note + ":" + link + re.cap (5) + ""; + f = re.matchedLength (); + text.replace (i,f,href); + i += href.size (); + } +} + +static void +replace_colons (QString &text) +{ + QRegExp re ("`([^']+)'"); + int i = 0, f; + while ( (i = re.indexIn (text, i)) != -1) + { + QString t = re.cap (1); + QString bold = "`" + t + "'"; + + f = re.matchedLength (); + text.replace (i,f,bold); + i += bold.size (); + } +} + +static void +info_to_html (QString &text) +{ + text.replace ("&", "&"); + text.replace ("<", "<"); + text.replace (">", ">"); + + text.replace ("\n* Menu:", "\nMenu:"); + text.replace ("*See also:*", "See also:"); + replace_colons (text); + replace_links (text); +} + +QString +parser::node_text_to_html (QString text, int anchorPos, QString anchor) +{ + QString nodeName = get_node_name (text); + QString nodeUp = get_node_up (text); + QString nodeNext = get_node_next (text); + QString nodePrev = get_node_prev (text); + + if (anchorPos > -1) + { + QString text1 = text.left (anchorPos); + QString text2 = text.mid (anchorPos); + + int n = text1.indexOf ("\n"); + text1.remove (0, n); + + info_to_html (text1); + info_to_html (text2); + + text = text1 + "" + text2; + } + else + { + int n = text.indexOf ("\n"); + text.remove (0, n); + info_to_html (text); + } + + QString navigationLinks = QString ( + " Section: %1
" + "Previous Section:
%3
" + "Next Section: %5
" + "Up: %7
\n" + ) + .arg (nodeName) + .arg (QString (QUrl::toPercentEncoding (nodePrev, "", "'"))) + .arg (nodePrev) + .arg (QString (QUrl::toPercentEncoding (nodeNext, "", "'"))) + .arg (nodeNext) + .arg (QString (QUrl::toPercentEncoding (nodeUp, "", "'"))) + .arg (nodeUp); + + + text.prepend ("
\n
");
+  text.append ("
\n

\n"); + text.prepend (navigationLinks); + text.append (navigationLinks); + text.prepend ("\n"); + text.append ("\n"); + return text; +} + +void +parser::parse_info_map () +{ + QRegExp re ("(Node|Ref): ([^\\0177]+)\\0177(\\d+)\n"); + QRegExp re_files ("([^:]+): (\\d+)\n"); + int foundCount = 0; + + for(int i = 0; i < _info_files.size (); i++) + { + QFileInfo fileInfo = _info_files.at (i); + + QIODevice *io = open_file (fileInfo); + if (io == NULL) + { + continue; + } + + QString nodeText; + while (! (nodeText=get_next_node (io)).isEmpty () && foundCount < 2) + { + QString first_line = get_first_line (nodeText); + if (first_line.startsWith ("Tag") ) + { + foundCount++; + int pos = 0; + QString last_node; + + while ((pos = re.indexIn (nodeText, pos)) != -1) { + QString type = re.cap (1); + QString node = re.cap (2); + int index = re.cap (3).toInt (); + + if (type == "Node") + { + node_map_item item; + item.pos = index; + _node_map [node] = item; + last_node = node; + } + else if (type == "Ref") + { + node_position item; + item._node_name = last_node; + item.pos = index; + _ref_map [node] = item; + } + pos += re.matchedLength (); + } + break; + } + else if (first_line.startsWith ("Indirect:")) + { + foundCount++; + int pos = 0; + + while ( (pos = re_files.indexIn (nodeText, pos)) != -1) { + QString fileCap = re_files.cap (1).trimmed (); + int index = re_files.cap (2).toInt (); + + info_file_item item; + for (int j = 0;j < _info_files.size (); j++) + { + QFileInfo info = _info_files.at (j); + if (info.fileName ().startsWith (fileCap)) + { + item.file_info = info; + break; + } + } + item.real_size = index; + _info_file_real_size_list.append (item); + pos += re_files.matchedLength (); + } + + } + } + io->close (); + delete io; + } +} + +void +parser::real_position (int pos, QFileInfo & file_info, int & real_pos) +{ + int header = -1, sum = 0; + for (int i = 0; i < _info_file_real_size_list.size (); i++) + { + info_file_item item = _info_file_real_size_list.at (i); + if (header == -1) + { + file_info = item.file_info; + header = item.real_size; + } + + if (pos < item.real_size) + { + break; + } + + file_info = item.file_info; + sum = item.real_size; + } + real_pos = pos - sum + header + 2; +} + +void +parser::seek (QIODevice *io, int pos) +{ + char ch; + while (!io->atEnd () && pos > 0) + { + io->getChar (&ch); + pos--; + } +} + +static void +replace (QString &text, QRegExp re, QString after) +{ + int pos = 0; + + while ( (pos = re.indexIn (text, pos)) != -1) + { + QString cap = text.mid (pos,re.matchedLength ()); + QString a (after); + a = a.arg (cap); + text.remove (pos, re.matchedLength ()); + text.insert (pos, a); + pos += a.size (); + } +} + +QString +parser::global_search (QString text, int max_founds) +{ + QString results; + QStringList words = text.split (" ",QString::SkipEmptyParts); + + QString re_program ("(" + words.at (0)); + for (int i = 1; i < words.size (); i++) + { + re_program += "|" + words.at (i); + } + re_program += ")"; + + QRegExp re (re_program, Qt::CaseInsensitive); + + results.append ("\n

Search results

\nResults for: "); + results.append (text); + results.append ("
\n"); + + for (int i = 0; i < _info_files.size (); i++) + { + QFileInfo file_info = _info_files.at (i); + QIODevice *io = open_file (file_info); + if (io == NULL) + { + continue; + } + + QString node_text; + while ( !(node_text = get_next_node (io)).isEmpty ()) + { + QString firstLine = get_first_line (node_text); + QString node = get_node_name (node_text); + if (node.isEmpty ()) + { + continue; + } + + int n = node_text.indexOf ("\n"); + node_text.remove (0, n); + + int pos = 0; + int founds = 0; + + for (; founds < words.size () && node_text.indexOf (words.at (founds)) >= 0; founds++) + { } + + if (founds\n "); + results.append (node); + results.append ("
\n"); + } + + replace (line, re, "%1"); + results.append (line); + results.append ("
\n"); + + founds++; + + pos += re.matchedLength (); + } + } + io->close (); + delete io; + } + + results.append (""); + return results; +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/qtinfo/parser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/qtinfo/parser.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,111 @@ +/* Copyright (C) 2009 P.L. Lucas + * Copyright (C) 2012 Jacob Dawid + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include + +/** + * \class parser + * This class gets nodes and searchs inside of `info files'. + *

Each info file has nodes. Every node has the documentation. + * Info files contains a map with position of each node.

+ *

What is position? + * There is a simple answer: + * If you make a queue with info files, position will be the number of bytes + * from begining to node position.

+ *

+ * But is not so easy. There is headers, and qtinfo must not take these headers into account. + *

+ *

+ * This class also translates info files to html. + *

+ */ +class parser + : public QObject +{ + Q_OBJECT + +public: + parser (QObject *parent = 0); + void set_info_path (QString _info_path); + QString get_info_path (); + QString search_node (QString node); + QString global_search (QString text, int maxFounds); + + /** Checks if this node is reference. If node is reference, it will be returned its position + * in text, else it will be returned -1. + */ + int is_ref (QString node); + + /**Translates text of node to Html. If anchorPos is not -1, then anchor is inserted in that + * position. + */ + QString node_text_to_html (QString text, int anchorPos=-1, QString anchor=QString()); + +private: + struct node_position + { + QString _node_name; + int pos; + }; + + struct node_map_item + { + int pos; + }; + + struct info_file_item + { + QFileInfo file_info; + int real_size; + }; + + QString search_node (QString node, QIODevice * io); + QString get_next_node (QIODevice * io); + QString get_node_name (QString text); + QString get_node_up (QString text); + QString get_node_next (QString text); + QString get_node_prev (QString text); + + /** Parses info files and gets map of node positions.*/ + void parse_info_map(); + + /** Open info files and uncompress them. */ + QIODevice *open_file(QFileInfo & fileInfo); + + /** Calculates real position of nodes. + * \param pos position from info file. + * \param fileInfo returns file what contains that position. + * \param realPos returns real position inside of fileInfo. + */ + void real_position (int pos, QFileInfo & file_info, int & real_pos); + + /** Seeks to position pos. */ + void seek (QIODevice *io, int pos); + + + QString _info_path; + QFileInfoList _info_files; + QHash _node_map; + QHash _ref_map; + QList _info_file_real_size_list; + QHash _compressors_map; +}; diff -r a87fa9132b72 -r dbc43bd95477 gui/src/qtinfo/webinfo.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/qtinfo/webinfo.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,211 @@ +/* Copyright (C) 2009 P.L. Lucas + * Copyright (C) 2012 Jacob Dawid + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "webinfo.h" +#include +#include + + +webinfo::webinfo (QWidget *parent) + :QWidget (parent) +{ + _font_web = font (); + + QVBoxLayout *layout = new QVBoxLayout (); + layout->setMargin (0); + setLayout (layout); + + QHBoxLayout *hboxLayout = new QHBoxLayout (); + hboxLayout->setMargin (2); + layout->addLayout (hboxLayout); + + _close_tab_button = new QPushButton (this); + _close_tab_button->setSizePolicy (QSizePolicy::Fixed,QSizePolicy::Preferred); + _close_tab_button->setIcon (QIcon (":/actions/icons/stop.png")); + hboxLayout->addWidget (_close_tab_button); + + _tab_bar = new QTabBar (this); + _tab_bar->setSizePolicy (QSizePolicy::Preferred,QSizePolicy::Preferred); + _tab_bar->setExpanding (false); + hboxLayout->addWidget (_tab_bar); + + _zoom_in_button = new QToolButton (this); + _zoom_in_button->setSizePolicy (QSizePolicy::Fixed,QSizePolicy::Preferred); + _zoom_in_button->setIcon (QIcon (":/actions/icons/zoom-in.png")); + hboxLayout->addWidget (_zoom_in_button); + + _zoom_out_button = new QToolButton (this); + _zoom_out_button->setSizePolicy (QSizePolicy::Fixed,QSizePolicy::Preferred); + _zoom_out_button->setIcon (QIcon (":/actions/icons/zoom-out.png")); + hboxLayout->addWidget (_zoom_out_button); + + _stacked_widget = new QStackedWidget (this); + layout->addWidget (_stacked_widget); + + hboxLayout = new QHBoxLayout (); + layout->addLayout (hboxLayout); + + _search_line_edit = new QLineEdit(this); + _search_line_edit->setPlaceholderText (tr ("Type here and press \'Return\' to search")); + hboxLayout->addWidget (_search_line_edit); + + _search_check_box = new QCheckBox (tr ("Global search")); + hboxLayout->addWidget (_search_check_box); + + connect (_close_tab_button, SIGNAL (clicked ()), this, SLOT (close_tab ())); + connect (_tab_bar, SIGNAL (currentChanged (int)), this, SLOT (current_tab_changed (int))); + connect (_zoom_in_button, SIGNAL (clicked ()), this, SLOT (zoom_in ())); + connect (_zoom_out_button, SIGNAL (clicked ()), this, SLOT (zoom_out ())); + connect (_search_line_edit, SIGNAL (returnPressed ()), this, SLOT (search ())); + + resize (500, 300); + + set_info_path ("../../doc/interpreter/octave.info"); +} + +void +webinfo::set_info_path (QString info_path) +{ + _parser.set_info_path (info_path); + load_node ("Top"); +} + +void +webinfo::load_node (QString node_name) +{ + //Check if node has been already opened. + for (int i = 0;i < _tab_bar->count (); i++) + { + if (node_name == _tab_bar->tabText (i)) + { + _tab_bar->setCurrentIndex (i); + return; + } + } + + QString text = _parser.search_node (node_name); + int i = _parser.is_ref (node_name); + _text_browser = addNewTab (node_name); + _text_browser->setHtml (_parser.node_text_to_html (text, i - 1, "anchor")); + + if (i != -1) + { + _text_browser->scrollToAnchor ("anchor"); + } +} + +void +webinfo::link_clicked (const QUrl & link) +{ + QString node = link.toString (); + load_node (node); +} + +void +webinfo::current_tab_changed (int index) +{ + QVariant data = _tab_bar->tabData (index); + _text_browser = (QTextBrowser*) (data.value ()); + + _stacked_widget->setCurrentIndex (_stacked_widget->indexOf (_text_browser)); + + if (_text_browser->font () != _font_web) + { + _text_browser->setFont (_font_web); + } +} + +QTextBrowser * +webinfo::addNewTab(QString name) +{ + _text_browser = new QTextBrowser (this); + _text_browser->setOpenLinks (false); + _text_browser->show (); + + connect (_text_browser, SIGNAL (anchorClicked (const QUrl &)), this, SLOT (link_clicked (const QUrl &)) ); + disconnect(_tab_bar, SIGNAL (currentChanged(int)), this, SLOT (current_tab_changed (int))); + + int ns = _stacked_widget->addWidget (_text_browser); + _stacked_widget->setCurrentIndex (ns); + + int nt = _tab_bar->addTab (name); + _tab_bar->setCurrentIndex (nt); + QVariant data; + data.setValue ( (void*)_text_browser); + _tab_bar->setTabData (nt, data); + + connect (_tab_bar, SIGNAL (currentChanged (int)), this, SLOT (current_tab_changed (int))); + + if (_text_browser->font () != _font_web) + { + _text_browser->setFont (_font_web); + } + return _text_browser; +} + +void +webinfo::close_tab () +{ + int index = _tab_bar->currentIndex (); + if (_tab_bar->tabText (index) != "Top") + closeTab (index); +} + +void +webinfo::closeTab (int index) +{ + QVariant data = _tab_bar->tabData (index); + QWidget *w = (QWidget*) (data.value ()); + _stacked_widget->removeWidget (w); + delete w; + + _tab_bar->removeTab (index); +} + +void +webinfo::search () +{ + if (_search_check_box->isChecked ()) + { + // Global search + QString results = _parser.global_search (_search_line_edit->text (), 5); + _text_browser=addNewTab ("Results for: " + _search_line_edit->text ()); + _text_browser->setHtml (results); + } + else + { + // Local search + _text_browser->find (_search_line_edit->text ()); + } +} + +void +webinfo::zoom_in () +{ + _font_web.setPointSize (_font_web.pointSize() + 1); + _text_browser->setFont (_font_web); +} + +void +webinfo::zoom_out () +{ + _font_web.setPointSize (_font_web.pointSize() - 1); + _text_browser->setFont (_font_web); +} + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/qtinfo/webinfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/qtinfo/webinfo.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,60 @@ +/* Copyright (C) 2009 P.L. Lucas + * Copyright (C) 2012 Jacob Dawid + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include "parser.h" +#include +#include +#include +#include +#include +#include + +class webinfo : public QWidget +{ + Q_OBJECT +public: + webinfo (QWidget *parent = 0); + void set_info_path (QString info_path); + void load_node (QString node_name); + +public slots: + void link_clicked (const QUrl &link); + void current_tab_changed (int index); + void close_tab (); + void search (); + void zoom_in (); + void zoom_out (); + +private: + QTextBrowser *_text_browser; + QTabBar *_tab_bar; + QStackedWidget *_stacked_widget; + QPushButton *_close_tab_button; + QLineEdit *_search_line_edit; + QCheckBox *_search_check_box; + QToolButton *_zoom_in_button; + QToolButton *_zoom_out_button; + + parser _parser; + QFont _font_web; + + QTextBrowser *addNewTab (QString name); + void closeTab(int index); +}; diff -r a87fa9132b72 -r dbc43bd95477 gui/src/resource-manager.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/resource-manager.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,1721 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include +#include +#include + +#include "error.h" +#include "file-ops.h" +#include "oct-env.h" +#include "singleton-cleanup.h" + +#include "defaults.h" + +#include "resource-manager.h" + +resource_manager *resource_manager::_instance = 0; + +bool +resource_manager::instance_ok () +{ + bool retval = true; + + if (! _instance) + { + _instance = new resource_manager (); + + if (_instance) + singleton_cleanup_list::add (cleanup_instance); + } + + if (! _instance) + { + ::error ("unable to create resource_manager object!"); + } + + return retval; +} + +resource_manager::resource_manager () +{ + _settings = 0; + _first_run = false; + reload_settings (); +} + +resource_manager::~resource_manager () +{ + delete _settings; +} + +QSettings * +resource_manager::get_settings () +{ + return _settings; +} + +QString +resource_manager::get_home_path () +{ + return _home_path; +} + +static std::string +default_qt_settings_file (void) +{ + std::string dsf = octave_env::getenv ("OCTAVE_DEFAULT_QT_SETTINGS"); + + if (dsf.empty ()) + dsf = Voct_etc_dir + file_ops::dir_sep_str () + "default-qt-settings"; + + return dsf; +} + +void +resource_manager::reload_settings () +{ + QDesktopServices desktopServices; + _home_path = desktopServices.storageLocation (QDesktopServices::HomeLocation); + QString settings_path = _home_path + "/.config/octave/"; + QString settings_file = settings_path + "qt-settings"; + + if (!QFile::exists (settings_file)) + { + QDir("/").mkpath (settings_path); + QFile::copy (QString::fromStdString (default_qt_settings_file ()), + settings_file); + _first_run = true; + } + else + _first_run = false; + + set_settings (settings_file); +} + +void +resource_manager::set_settings (QString file) +{ + delete _settings; + _settings = new QSettings (file, QSettings::IniFormat); +} + +QString +resource_manager::find_translator_file (QString language) +{ + // TODO: Quick hack to be able to test language files. + return QString("../languages/%1.qm").arg(language); +} + + +bool +resource_manager::is_first_run () +{ + return _first_run; +} + +void +resource_manager::update_network_settings () +{ + QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy; + if (_settings->value ("useProxyServer").toBool ()) + { + QString proxyTypeString = _settings->value ("proxyType").toString (); + if (proxyTypeString == "Socks5Proxy") + { + proxyType = QNetworkProxy::Socks5Proxy; + } + else if (proxyTypeString == "HttpProxy") + { + proxyType = QNetworkProxy::HttpProxy; + } + } + + QNetworkProxy proxy; + proxy.setType (proxyType); + proxy.setHostName (_settings->value ("proxyHostName").toString ()); + proxy.setPort (_settings->value ("proxyPort").toInt ()); + proxy.setUser (_settings->value ("proxyUserName").toString ()); + proxy.setPassword (_settings->value ("proxyPassword").toString ()); + QNetworkProxy::setApplicationProxy (proxy); +} + +const char* +resource_manager::octave_keywords () +{ + return + ".nargin. " + "EDITOR " + "EXEC_PATH " + "F_DUPFD " + "F_GETFD " + "F_GETFL " + "F_SETFD " + "F_SETFL " + "I " + "IMAGE_PATH " + "Inf " + "J " + "NA " + "NaN " + "OCTAVE_HOME " + "OCTAVE_VERSION " + "O_APPEND " + "O_ASYNC " + "O_CREAT " + "O_EXCL " + "O_NONBLOCK " + "O_RDONLY " + "O_RDWR " + "O_SYNC " + "O_TRUNC " + "O_WRONLY " + "PAGER " + "PAGER_FLAGS " + "PS1 " + "PS2 " + "PS4 " + "P_tmpdir " + "SEEK_CUR " + "SEEK_END " + "SEEK_SET " + "SIG " + "S_ISBLK " + "S_ISCHR " + "S_ISDIR " + "S_ISFIFO " + "S_ISLNK " + "S_ISREG " + "S_ISSOCK " + "WCONTINUE " + "WCOREDUMP " + "WEXITSTATUS " + "WIFCONTINUED " + "WIFEXITED " + "WIFSIGNALED " + "WIFSTOPPED " + "WNOHANG " + "WSTOPSIG " + "WTERMSIG " + "WUNTRACED " + "__accumarray_max__ " + "__accumarray_min__ " + "__accumarray_sum__ " + "__accumdim_sum__ " + "__all_opts__ " + "__builtins__ " + "__calc_dimensions__ " + "__contourc__ " + "__current_scope__ " + "__delaunayn__ " + "__dispatch__ " + "__display_tokens__ " + "__dsearchn__ " + "__dump_symtab_info__ " + "__end__ " + "__error_text__ " + "__finish__ " + "__fltk_ginput__ " + "__fltk_print__ " + "__fltk_uigetfile__ " + "__ftp__ " + "__ftp_ascii__ " + "__ftp_binary__ " + "__ftp_close__ " + "__ftp_cwd__ " + "__ftp_delete__ " + "__ftp_dir__ " + "__ftp_mget__ " + "__ftp_mkdir__ " + "__ftp_mode__ " + "__ftp_mput__ " + "__ftp_pwd__ " + "__ftp_rename__ " + "__ftp_rmdir__ " + "__get__ " + "__glpk__ " + "__gnuplot_drawnow__ " + "__gnuplot_get_var__ " + "__gnuplot_ginput__ " + "__gnuplot_has_feature__ " + "__gnuplot_open_stream__ " + "__gnuplot_print__ " + "__gnuplot_version__ " + "__go_axes__ " + "__go_axes_init__ " + "__go_close_all__ " + "__go_delete__ " + "__go_draw_axes__ " + "__go_draw_figure__ " + "__go_execute_callback__ " + "__go_figure__ " + "__go_figure_handles__ " + "__go_handles__ " + "__go_hggroup__ " + "__go_image__ " + "__go_line__ " + "__go_patch__ " + "__go_surface__ " + "__go_text__ " + "__go_uimenu__ " + "__gud_mode__ " + "__image_pixel_size__ " + "__init_fltk__ " + "__isa_parent__ " + "__keywords__ " + "__lexer_debug_flag__ " + "__lin_interpn__ " + "__list_functions__ " + "__magick_finfo__ " + "__magick_format_list__ " + "__magick_read__ " + "__magick_write__ " + "__makeinfo__ " + "__marching_cube__ " + "__next_line_color__ " + "__next_line_style__ " + "__operators__ " + "__parent_classes__ " + "__parser_debug_flag__ " + "__pathorig__ " + "__pchip_deriv__ " + "__plt_get_axis_arg__ " + "__print_parse_opts__ " + "__qp__ " + "__request_drawnow__ " + "__sort_rows_idx__ " + "__strip_html_tags__ " + "__token_count__ " + "__varval__ " + "__version_info__ " + "__voronoi__ " + "__which__ " + "abs " + "accumarray " + "accumdim " + "acos " + "acosd " + "acosh " + "acot " + "acotd " + "acoth " + "acsc " + "acscd " + "acsch " + "add_input_event_hook " + "addlistener " + "addpath " + "addproperty " + "addtodate " + "airy " + "all " + "allchild " + "allow_noninteger_range_as_index " + "amd " + "ancestor " + "and " + "angle " + "anova " + "ans " + "any " + "arch_fit " + "arch_rnd " + "arch_test " + "area " + "arg " + "argnames " + "argv " + "arma_rnd " + "arrayfun " + "asctime " + "asec " + "asecd " + "asech " + "asin " + "asind " + "asinh " + "assert " + "assignin " + "atan " + "atan2 " + "atand " + "atanh " + "atexit " + "autocor " + "autocov " + "autoload " + "autoreg_matrix " + "autumn " + "available_graphics_toolkits " + "axes " + "axis " + "balance " + "bar " + "barh " + "bartlett " + "bartlett_test " + "base2dec " + "beep " + "beep_on_error " + "bessel " + "besselh " + "besseli " + "besselj " + "besselk " + "bessely " + "beta " + "betacdf " + "betai " + "betainc " + "betainv " + "betaln " + "betapdf " + "betarnd " + "bicgstab " + "bicubic " + "bin2dec " + "bincoeff " + "binocdf " + "binoinv " + "binopdf " + "binornd " + "bitand " + "bitcmp " + "bitget " + "bitmax " + "bitor " + "bitpack " + "bitset " + "bitshift " + "bitunpack " + "bitxor " + "blackman " + "blanks " + "blkdiag " + "blkmm " + "bone " + "box " + "break " + "brighten " + "bsxfun " + "bug_report " + "builtin " + "bunzip2 " + "bzip2 " + "calendar " + "canonicalize_file_name " + "cart2pol " + "cart2sph " + "case " + "cast " + "cat " + "catch " + "cauchy_cdf " + "cauchy_inv " + "cauchy_pdf " + "cauchy_rnd " + "caxis " + "cbrt " + "ccolamd " + "cd " + "ceil " + "cell " + "cell2mat " + "cell2struct " + "celldisp " + "cellfun " + "cellidx " + "cellindexmat " + "cellslices " + "cellstr " + "center " + "cgs " + "char " + "chdir " + "chi2cdf " + "chi2inv " + "chi2pdf " + "chi2rnd " + "chisquare_test_homogeneity " + "chisquare_test_independence " + "chol " + "chol2inv " + "choldelete " + "cholinsert " + "cholinv " + "cholshift " + "cholupdate " + "chop " + "circshift " + "cla " + "clabel " + "class " + "clc " + "clear " + "clf " + "clg " + "clock " + "cloglog " + "close " + "closereq " + "colamd " + "colloc " + "colon " + "colorbar " + "colormap " + "colperm " + "colstyle " + "columns " + "comet " + "comet3 " + "comma " + "command_line_path " + "common_size " + "commutation_matrix " + "compan " + "compare_versions " + "compass " + "complement " + "completion_append_char " + "completion_matches " + "complex " + "computer " + "cond " + "condest " + "confirm_recursive_rmdir " + "conj " + "continue " + "contour " + "contour3 " + "contourc " + "contourf " + "contrast " + "conv " + "conv2 " + "convhull " + "convhulln " + "convn " + "cool " + "copper " + "copyfile " + "cor " + "cor_test " + "corrcoef " + "cos " + "cosd " + "cosh " + "cot " + "cotd " + "coth " + "cov " + "cplxpair " + "cputime " + "cquad " + "crash_dumps_octave_core " + "create_set " + "cross " + "csc " + "cscd " + "csch " + "cstrcat " + "csvread " + "csvwrite " + "csymamd " + "ctime " + "ctranspose " + "cummax " + "cummin " + "cumprod " + "cumsum " + "cumtrapz " + "curl " + "cut " + "cylinder " + "daspect " + "daspk " + "daspk_options " + "dasrt " + "dasrt_options " + "dassl " + "dassl_options " + "date " + "datenum " + "datestr " + "datetick " + "datevec " + "dbclear " + "dbcont " + "dbdown " + "dblquad " + "dbnext " + "dbquit " + "dbstack " + "dbstatus " + "dbstep " + "dbstop " + "dbtype " + "dbup " + "dbwhere " + "deal " + "deblank " + "debug " + "debug_on_error " + "debug_on_interrupt " + "debug_on_warning " + "dec2base " + "dec2bin " + "dec2hex " + "deconv " + "default_save_options " + "del2 " + "delaunay " + "delaunay3 " + "delaunayn " + "delete " + "dellistener " + "demo " + "det " + "detrend " + "diag " + "diary " + "diff " + "diffpara " + "diffuse " + "dir " + "discrete_cdf " + "discrete_inv " + "discrete_pdf " + "discrete_rnd " + "disp " + "dispatch " + "display " + "divergence " + "dlmread " + "dlmwrite " + "dmperm " + "dmult " + "do " + "do_braindead_shortcircuit_evaluation " + "do_string_escapes " + "doc " + "doc_cache_file " + "dos " + "dot " + "double " + "drawnow " + "dsearch " + "dsearchn " + "dump_prefs " + "dup2 " + "duplication_matrix " + "durbinlevinson " + "e " + "echo " + "echo_executing_commands " + "edit " + "edit_history " + "eig " + "eigs " + "ellipsoid " + "else " + "elseif " + "empirical_cdf " + "empirical_inv " + "empirical_pdf " + "empirical_rnd " + "end " + "end_try_catch " + "end_unwind_protect " + "endfor " + "endfunction " + "endgrent " + "endif " + "endpwent " + "endswitch " + "endwhile " + "eomday " + "eps " + "eq " + "erf " + "erfc " + "erfcx " + "erfinv " + "errno " + "errno_list " + "error " + "error_text " + "errorbar " + "etime " + "etree " + "etreeplot " + "eval " + "evalin " + "example " + "exec " + "exist " + "exit " + "exp " + "expcdf " + "expinv " + "expm " + "expm1 " + "exppdf " + "exprnd " + "eye " + "ezcontour " + "ezcontourf " + "ezmesh " + "ezmeshc " + "ezplot " + "ezplot3 " + "ezpolar " + "ezsurf " + "ezsurfc " + "f_test_regression " + "factor " + "factorial " + "fail " + "false " + "fcdf " + "fclear " + "fclose " + "fcntl " + "fdisp " + "feather " + "feof " + "ferror " + "feval " + "fflush " + "fft " + "fft2 " + "fftconv " + "fftfilt " + "fftn " + "fftshift " + "fftw " + "fgetl " + "fgets " + "fieldnames " + "figure " + "file_in_loadpath " + "file_in_path " + "fileattrib " + "filemarker " + "fileparts " + "fileread " + "filesep " + "fill " + "filter " + "filter2 " + "find " + "find_dir_in_path " + "findall " + "findobj " + "findstr " + "finite " + "finv " + "fix " + "fixed_point_format " + "flag " + "flipdim " + "fliplr " + "flipud " + "floor " + "fminbnd " + "fminunc " + "fmod " + "fnmatch " + "fopen " + "for " + "fork " + "format " + "formula " + "fpdf " + "fplot " + "fprintf " + "fputs " + "fractdiff " + "fread " + "freport " + "freqz " + "freqz_plot " + "frewind " + "frnd " + "fscanf " + "fseek " + "fskipl " + "fsolve " + "fstat " + "ftell " + "full " + "fullfile " + "func2str " + "function " + "functions " + "fwrite " + "fzero " + "gamcdf " + "gaminv " + "gamma " + "gammai " + "gammainc " + "gammaln " + "gampdf " + "gamrnd " + "gca " + "gcbf " + "gcbo " + "gcd " + "gcf " + "ge " + "gen_doc_cache " + "genpath " + "genvarname " + "geocdf " + "geoinv " + "geopdf " + "geornd " + "get " + "get_first_help_sentence " + "get_help_text " + "get_help_text_from_file " + "getappdata " + "getegid " + "getenv " + "geteuid " + "getfield " + "getgid " + "getgrent " + "getgrgid " + "getgrnam " + "gethostname " + "getpgrp " + "getpid " + "getppid " + "getpwent " + "getpwnam " + "getpwuid " + "getrusage " + "getuid " + "ginput " + "givens " + "glob " + "global " + "glpk " + "glpkmex " + "gls " + "gmap40 " + "gmres " + "gmtime " + "gnuplot_binary " + "gplot " + "gradient " + "graphics_toolkit " + "gray " + "gray2ind " + "grid " + "griddata " + "griddata3 " + "griddatan " + "gt " + "gtext " + "gunzip " + "gzip " + "hadamard " + "hamming " + "hankel " + "hanning " + "help " + "hess " + "hex2dec " + "hex2num " + "hggroup " + "hidden " + "hilb " + "hist " + "histc " + "history " + "history_control " + "history_file " + "history_size " + "history_timestamp_format_string " + "hold " + "home " + "horzcat " + "hot " + "hotelling_test " + "hotelling_test_2 " + "housh " + "hsv " + "hsv2rgb " + "hurst " + "hygecdf " + "hygeinv " + "hygepdf " + "hygernd " + "hypot " + "i " + "idivide " + "if " + "ifelse " + "ifft " + "ifft2 " + "ifftn " + "ifftshift " + "ignore_function_time_stamp " + "imag " + "image " + "imagesc " + "imfinfo " + "imread " + "imshow " + "imwrite " + "ind2gray " + "ind2rgb " + "ind2sub " + "index " + "inf " + "inferiorto " + "info " + "info_file " + "info_program " + "inline " + "inpolygon " + "input " + "inputname " + "int16 " + "int2str " + "int32 " + "int64 " + "int8 " + "interp1 " + "interp1q " + "interp2 " + "interp3 " + "interpft " + "interpn " + "intersect " + "intmax " + "intmin " + "intwarning " + "inv " + "inverse " + "invhilb " + "ipermute " + "iqr " + "is_absolute_filename " + "is_duplicate_entry " + "is_global " + "is_leap_year " + "is_rooted_relative_filename " + "is_valid_file_id " + "isa " + "isalnum " + "isalpha " + "isappdata " + "isargout " + "isascii " + "isbool " + "iscell " + "iscellstr " + "ischar " + "iscntrl " + "iscolumn " + "iscommand " + "iscomplex " + "isdebugmode " + "isdefinite " + "isdeployed " + "isdigit " + "isdir " + "isempty " + "isequal " + "isequalwithequalnans " + "isfield " + "isfigure " + "isfinite " + "isfloat " + "isglobal " + "isgraph " + "ishandle " + "ishermitian " + "ishghandle " + "ishold " + "isieee " + "isindex " + "isinf " + "isinteger " + "iskeyword " + "isletter " + "islogical " + "islower " + "ismac " + "ismatrix " + "ismember " + "ismethod " + "isna " + "isnan " + "isnull " + "isnumeric " + "isobject " + "isocolors " + "isonormals " + "isosurface " + "ispc " + "isprime " + "isprint " + "isprop " + "ispunct " + "israwcommand " + "isreal " + "isrow " + "isscalar " + "issorted " + "isspace " + "issparse " + "issquare " + "isstr " + "isstrprop " + "isstruct " + "issymmetric " + "isunix " + "isupper " + "isvarname " + "isvector " + "isxdigit " + "j " + "jet " + "kbhit " + "kendall " + "keyboard " + "kill " + "kolmogorov_smirnov_cdf " + "kolmogorov_smirnov_test " + "kolmogorov_smirnov_test_2 " + "kron " + "kruskal_wallis_test " + "krylov " + "krylovb " + "kurtosis " + "laplace_cdf " + "laplace_inv " + "laplace_pdf " + "laplace_rnd " + "lasterr " + "lasterror " + "lastwarn " + "lchol " + "lcm " + "ldivide " + "le " + "legend " + "legendre " + "length " + "lgamma " + "license " + "lin2mu " + "line " + "link " + "linkprop " + "linspace " + "list " + "list_in_columns " + "list_primes " + "load " + "loadaudio " + "loadimage " + "loadobj " + "localtime " + "log " + "log10 " + "log1p " + "log2 " + "logical " + "logistic_cdf " + "logistic_inv " + "logistic_pdf " + "logistic_regression " + "logistic_rnd " + "logit " + "loglog " + "loglogerr " + "logm " + "logncdf " + "logninv " + "lognpdf " + "lognrnd " + "logspace " + "lookfor " + "lookup " + "lower " + "ls " + "ls_command " + "lsode " + "lsode_options " + "lsqnonneg " + "lstat " + "lt " + "lu " + "luinc " + "luupdate " + "magic " + "mahalanobis " + "make_absolute_filename " + "makeinfo_program " + "manova " + "mark_as_command " + "mark_as_rawcommand " + "mat2cell " + "mat2str " + "matlabroot " + "matrix_type " + "max " + "max_recursion_depth " + "mcnemar_test " + "md5sum " + "mean " + "meansq " + "median " + "menu " + "merge " + "mesh " + "meshc " + "meshgrid " + "meshz " + "methods " + "mex " + "mexext " + "mfilename " + "mgorth " + "min " + "minus " + "mislocked " + "missing_function_hook " + "mist " + "mkdir " + "mkfifo " + "mkoctfile " + "mkpp " + "mkstemp " + "mktime " + "mldivide " + "mlock " + "mod " + "mode " + "moment " + "more " + "most " + "movefile " + "mpoles " + "mpower " + "mrdivide " + "mtimes " + "mu2lin " + "munlock " + "namelengthmax " + "nan " + "nargchk " + "nargin " + "nargout " + "nargoutchk " + "native_float_format " + "nbincdf " + "nbininv " + "nbinpdf " + "nbinrnd " + "nchoosek " + "ndgrid " + "ndims " + "ne " + "newplot " + "news " + "nextpow2 " + "nfields " + "nnz " + "nonzeros " + "norm " + "normcdf " + "normest " + "norminv " + "normpdf " + "normrnd " + "not " + "now " + "nproc " + "nth_element " + "nthroot " + "ntsc2rgb " + "null " + "num2cell " + "num2hex " + "num2str " + "numel " + "nzmax " + "ocean " + "octave_config_info " + "octave_core_file_limit " + "octave_core_file_name " + "octave_core_file_options " + "octave_tmp_file_name " + "ols " + "onCleanup " + "onenormest " + "ones " + "optimget " + "optimize_subsasgn_calls " + "optimset " + "or " + "orderfields " + "orient " + "orth " + "otherwise " + "output_max_field_width " + "output_precision " + "pack " + "page_output_immediately " + "page_screen_output " + "paren " + "pareto " + "parseparams " + "pascal " + "patch " + "path " + "pathdef " + "pathsep " + "pause " + "pbaspect " + "pcg " + "pchip " + "pclose " + "pcolor " + "pcr " + "peaks " + "periodogram " + "perl " + "perms " + "permute " + "perror " + "persistent " + "pi " + "pie " + "pie3 " + "pink " + "pinv " + "pipe " + "pkg " + "planerot " + "playaudio " + "plot " + "plot3 " + "plotmatrix " + "plotyy " + "plus " + "poisscdf " + "poissinv " + "poisspdf " + "poissrnd " + "pol2cart " + "polar " + "poly " + "polyaffine " + "polyarea " + "polyder " + "polyderiv " + "polyfit " + "polygcd " + "polyint " + "polyout " + "polyreduce " + "polyval " + "polyvalm " + "popen " + "popen2 " + "postpad " + "pow2 " + "power " + "powerset " + "ppder " + "ppint " + "ppjumps " + "ppplot " + "ppval " + "pqpnonneg " + "prctile " + "prepad " + "primes " + "print " + "print_empty_dimensions " + "print_struct_array_contents " + "print_usage " + "printf " + "prism " + "probit " + "prod " + "program_invocation_name " + "program_name " + "prop_test_2 " + "putenv " + "puts " + "pwd " + "qp " + "qqplot " + "qr " + "qrdelete " + "qrinsert " + "qrshift " + "qrupdate " + "quad " + "quad_options " + "quadcc " + "quadgk " + "quadl " + "quadv " + "quantile " + "quit " + "quiver " + "quiver3 " + "qz " + "qzhess " + "rainbow " + "rand " + "rande " + "randg " + "randi " + "randn " + "randp " + "randperm " + "range " + "rank " + "ranks " + "rat " + "rats " + "rcond " + "rdivide " + "re_read_readline_init_file " + "read_readline_init_file " + "readdir " + "readlink " + "real " + "reallog " + "realmax " + "realmin " + "realpow " + "realsqrt " + "record " + "rectangle " + "rectint " + "refresh " + "refreshdata " + "regexp " + "regexpi " + "regexprep " + "regexptranslate " + "rehash " + "rem " + "remove_input_event_hook " + "rename " + "repelems " + "replot " + "repmat " + "reset " + "reshape " + "residue " + "resize " + "restoredefaultpath " + "rethrow " + "return " + "rgb2hsv " + "rgb2ind " + "rgb2ntsc " + "ribbon " + "rindex " + "rmappdata " + "rmdir " + "rmfield " + "rmpath " + "roots " + "rose " + "rosser " + "rot90 " + "rotdim " + "round " + "roundb " + "rows " + "rref " + "rsf2csf " + "run " + "run_count " + "run_history " + "run_test " + "rundemos " + "runlength " + "runtests " + "save " + "save_header_format_string " + "save_precision " + "saveas " + "saveaudio " + "saveimage " + "saveobj " + "savepath " + "saving_history " + "scanf " + "scatter " + "scatter3 " + "schur " + "sec " + "secd " + "sech " + "semicolon " + "semilogx " + "semilogxerr " + "semilogy " + "semilogyerr " + "set " + "setappdata " + "setaudio " + "setdiff " + "setenv " + "setfield " + "setgrent " + "setpwent " + "setstr " + "setxor " + "shading " + "shell_cmd " + "shg " + "shift " + "shiftdim " + "sighup_dumps_octave_core " + "sign " + "sign_test " + "sigterm_dumps_octave_core " + "silent_functions " + "sin " + "sinc " + "sind " + "sinetone " + "sinewave " + "single " + "sinh " + "size " + "size_equal " + "sizemax " + "sizeof " + "skewness " + "sleep " + "slice " + "sombrero " + "sort " + "sortrows " + "source " + "spalloc " + "sparse " + "sparse_auto_mutate " + "spatan2 " + "spaugment " + "spchol " + "spchol2inv " + "spcholinv " + "spconvert " + "spcumprod " + "spcumsum " + "spdet " + "spdiag " + "spdiags " + "spearman " + "spectral_adf " + "spectral_xdf " + "specular " + "speed " + "spencer " + "speye " + "spfind " + "spfun " + "sph2cart " + "sphcat " + "sphere " + "spinmap " + "spinv " + "spkron " + "splchol " + "spline " + "split " + "split_long_rows " + "splu " + "spmax " + "spmin " + "spones " + "spparms " + "spprod " + "spqr " + "sprand " + "sprandn " + "sprandsym " + "sprank " + "spring " + "sprintf " + "spstats " + "spsum " + "spsumsq " + "spvcat " + "spy " + "sqp " + "sqrt " + "sqrtm " + "squeeze " + "sscanf " + "stairs " + "stat " + "static " + "statistics " + "std " + "stderr " + "stdin " + "stdnormal_cdf " + "stdnormal_inv " + "stdnormal_pdf " + "stdnormal_rnd " + "stdout " + "stem " + "stem3 " + "stft " + "str2double " + "str2func " + "str2mat " + "str2num " + "strcat " + "strchr " + "strcmp " + "strcmpi " + "strerror " + "strfind " + "strftime " + "string_fill_char " + "strjust " + "strmatch " + "strncmp " + "strncmpi " + "strptime " + "strread " + "strrep " + "strsplit " + "strtok " + "strtrim " + "strtrunc " + "struct " + "struct2cell " + "struct_levels_to_print " + "structfun " + "strvcat " + "studentize " + "sub2ind " + "subplot " + "subsasgn " + "subsindex " + "subspace " + "subsref " + "substr " + "substruct " + "sum " + "summer " + "sumsq " + "superiorto " + "suppress_verbose_help_message " + "surf " + "surface " + "surfc " + "surfl " + "surfnorm " + "svd " + "svd_driver " + "svds " + "swapbytes " + "switch " + "syl " + "sylvester_matrix " + "symamd " + "symbfact " + "symlink " + "symrcm " + "symvar " + "synthesis " + "system " + "t_test " + "t_test_2 " + "t_test_regression " + "table " + "tan " + "tand " + "tanh " + "tar " + "tcdf " + "tempdir " + "tempname " + "terminal_size " + "test " + "test2 " + "test3 " + "text " + "textread " + "textscan " + "tic " + "tilde_expand " + "time " + "times " + "tinv " + "title " + "tmpfile " + "tmpnam " + "toascii " + "toc " + "toeplitz " + "tolower " + "toupper " + "tpdf " + "trace " + "transpose " + "trapz " + "treelayout " + "treeplot " + "tril " + "trimesh " + "triplequad " + "triplot " + "trisurf " + "triu " + "trnd " + "true " + "try " + "tsearch " + "tsearchn " + "type " + "typecast " + "typeinfo " + "u_test " + "uigetdir " + "uigetfile " + "uimenu " + "uint16 " + "uint32 " + "uint64 " + "uint8 " + "uiputfile " + "umask " + "uminus " + "uname " + "undo_string_escapes " + "unidcdf " + "unidinv " + "unidpdf " + "unidrnd " + "unifcdf " + "unifinv " + "unifpdf " + "unifrnd " + "unimplemented " + "union " + "unique " + "unix " + "unlink " + "unmark_command " + "unmark_rawcommand " + "unmkpp " + "unpack " + "untabify " + "untar " + "until " + "unwind_protect " + "unwind_protect_cleanup " + "unwrap " + "unzip " + "uplus " + "upper " + "urlread " + "urlwrite " + "usage " + "usleep " + "validatestring " + "values " + "vander " + "var " + "var_test " + "varargin " + "varargout " + "vec " + "vech " + "vectorize " + "ver " + "version " + "vertcat " + "view " + "voronoi " + "voronoin " + "waitforbuttonpress " + "waitpid " + "warning " + "warning_ids " + "warranty " + "wavread " + "wavwrite " + "wblcdf " + "wblinv " + "wblpdf " + "wblrnd " + "weekday " + "weibcdf " + "weibinv " + "weibpdf " + "weibrnd " + "welch_test " + "what " + "which " + "while " + "white " + "whitebg " + "who " + "whos " + "whos_line_format " + "wienrnd " + "wilcoxon_test " + "wilkinson " + "winter " + "xlabel " + "xlim " + "xor " + "yes_or_no " + "ylabel " + "ylim " + "yulewalker " + "z_test " + "z_test_2 " + "zeros " + "zip " + "zlabel " + "zlim "; + /* "break case catch continue do else elseif end end_unwind_protect " + "endfor endfunction endif endswitch endwhile for function " + "global if otherwise persistent return switch try until " + "unwind_protect unwind_protect_cleanup while"; + */ +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/resource-manager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/resource-manager.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,61 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef RESOURCEMANAGER_H +#define RESOURCEMANAGER_H + +#include +#include +#include +#include + +class resource_manager +{ +public: + + ~resource_manager (); + + static resource_manager * + instance () + { + return (instance_ok ()) ? _instance : 0; + } + + QSettings *get_settings (); + QString get_home_path (); + void reload_settings (); + void set_settings (QString file); + QString find_translator_file (QString language); + void update_network_settings (); + + bool is_first_run (); + const char *octave_keywords (); + +private: + resource_manager (); + + static bool instance_ok (); + + static void cleanup_instance () { delete _instance; _instance = 0; } + + QSettings *_settings; + QString _home_path; + static resource_manager *_instance; + bool _first_run; +}; + +#endif // RESOURCEMANAGER_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/resource.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/resource.qrc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,40 @@ + + + icons/artsbuilderexecute.png + icons/editcopy.png + icons/editcut.png + icons/editpaste.png + icons/filenew.png + icons/fileopen.png + icons/filesave.png + icons/redo.png + icons/search.png + icons/undo.png + icons/up.png + icons/configure.png + icons/filesaveas.png + icons/redled.png + icons/arrow_right.png + icons/bookmark.png + icons/question.png + icons/star.png + icons/stop.png + icons/zoom-in.png + icons/zoom-out.png + icons/find.png + icons/chat.png + icons/help_index.png + icons/jabber_protocol.png + icons/logo.png + icons/terminal.png + icons/bp_toggle.png + icons/bp_rm_all.png + icons/bp_prev.png + icons/bp_next.png + icons/db_cont.png + icons/db_step.png + icons/db_step_in.png + icons/db_step_out.png + icons/db_stop.png + + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/settings-dialog.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/settings-dialog.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,115 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "resource-manager.h" +#include "settings-dialog.h" +#include "ui-settings-dialog.h" +#include + +settings_dialog::settings_dialog (QWidget * parent): +QDialog (parent), ui (new Ui::settings_dialog) +{ + ui->setupUi (this); + + QSettings *settings = resource_manager::instance ()->get_settings (); + ui->useCustomFileEditor->setChecked (settings->value ("useCustomFileEditor").toBool ()); + ui->customFileEditor->setText (settings->value ("customFileEditor").toString ()); + ui->editor_showLineNumbers->setChecked (settings->value ("editor/showLineNumbers",true).toBool () ); + ui->editor_highlightCurrentLine->setChecked (settings->value ("editor/highlightCurrentLine",true).toBool () ); + ui->editor_codeCompletion->setChecked (settings->value ("editor/codeCompletion",true).toBool () ); + ui->editor_fontName->setCurrentFont (QFont (settings->value ("editor/fontName","Courier").toString()) ); + ui->editor_fontSize->setValue (settings->value ("editor/fontSize",10).toInt ()); + ui->editor_longWindowTitle->setChecked (settings->value ("editor/longWindowTitle",true).toBool ()); + ui->terminal_fontName->setCurrentFont (QFont (settings->value ("terminal/fontName","Courier").toString()) ); + ui->terminal_fontSize->setValue (settings->value ("terminal/fontSize",10).toInt ()); + ui->showFilenames->setChecked (settings->value ("showFilenames").toBool()); + ui->showFileSize->setChecked (settings->value ("showFileSize").toBool()); + ui->showFileType->setChecked (settings->value ("showFileType").toBool()); + ui->showLastModified->setChecked (settings->value ("showLastModified").toBool()); + ui->showHiddenFiles->setChecked (settings->value ("showHiddenFiles").toBool()); + ui->useAlternatingRowColors->setChecked (settings->value ("useAlternatingRowColors").toBool()); + ui->useProxyServer->setChecked (settings->value ("useProxyServer").toBool ()); + ui->proxyHostName->setText (settings->value ("proxyHostName").toString ()); + ui->terminal_cursorBlinking->setChecked (settings->value ("terminal/cursorBlinking").toBool ()); + + QString cursorType = settings->value ("terminal/cursorType").toString (); + + QStringList items; + items << QString("0") << QString("1") << QString("2"); + ui->terminal_cursorType->addItems(items); + ui->terminal_cursorType->setItemText (0, "IBeam Cursor"); + ui->terminal_cursorType->setItemText (1, "Block Cursor"); + ui->terminal_cursorType->setItemText (2, "Underline Cursor"); + + if (cursorType == "ibeam") + ui->terminal_cursorType->setCurrentIndex (0); + else if (cursorType == "block") + ui->terminal_cursorType->setCurrentIndex (1); + else if (cursorType == "underline") + ui->terminal_cursorType->setCurrentIndex (2); + + int currentIndex = 0; + QString proxyTypeString = settings->value ("proxyType").toString (); + while ( (currentIndex < ui->proxyType->count ()) && (ui->proxyType->currentText () != proxyTypeString)) + { + currentIndex++; + ui->proxyType->setCurrentIndex (currentIndex); + } + + ui->proxyPort->setText (settings->value ("proxyPort").toString ()); + ui->proxyUserName->setText (settings->value ("proxyUserName").toString ()); + ui->proxyPassword->setText (settings->value ("proxyPassword").toString ()); +} + +settings_dialog::~settings_dialog () +{ + QSettings *settings = resource_manager::instance ()->get_settings (); + settings->setValue ("useCustomFileEditor", ui->useCustomFileEditor->isChecked ()); + settings->setValue ("customFileEditor", ui->customFileEditor->text ()); + settings->setValue ("editor/showLineNumbers", ui->editor_showLineNumbers->isChecked ()); + settings->setValue ("editor/highlightCurrentLine", ui->editor_highlightCurrentLine->isChecked ()); + settings->setValue ("editor/codeCompletion", ui->editor_codeCompletion->isChecked ()); + settings->setValue ("editor/fontName", ui->editor_fontName->currentFont().family()); + settings->setValue ("editor/fontSize", ui->editor_fontSize->value()); + settings->setValue ("editor/longWindowTitle", ui->editor_longWindowTitle->isChecked()); + settings->setValue ("terminal/fontSize", ui->terminal_fontSize->value()); + settings->setValue ("terminal/fontName", ui->terminal_fontName->currentFont().family()); + settings->setValue ("showFilenames", ui->showFilenames->isChecked ()); + settings->setValue ("showFileSize", ui->showFileSize->isChecked ()); + settings->setValue ("showFileType", ui->showFileType->isChecked ()); + settings->setValue ("showLastModified", ui->showLastModified->isChecked ()); + settings->setValue ("showHiddenFiles", ui->showHiddenFiles->isChecked ()); + settings->setValue ("useAlternatingRowColors", ui->useAlternatingRowColors->isChecked ()); + settings->setValue ("useProxyServer", ui->useProxyServer->isChecked ()); + settings->setValue ("proxyType", ui->proxyType->currentText ()); + settings->setValue ("proxyHostName", ui->proxyHostName->text ()); + settings->setValue ("proxyPort", ui->proxyPort->text ()); + settings->setValue ("proxyUserName", ui->proxyUserName->text ()); + settings->setValue ("proxyPassword", ui->proxyPassword->text ()); + settings->setValue ("terminal/cursorBlinking", ui->terminal_cursorBlinking->isChecked ()); + + QString cursorType; + switch (ui->terminal_cursorType->currentIndex ()) + { + case 0: cursorType = "ibeam"; break; + case 1: cursorType = "block"; break; + case 2: cursorType = "underline"; break; + } + settings->setValue ("terminal/cursorType", cursorType); + settings->sync (); + delete ui; +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/settings-dialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/settings-dialog.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,39 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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. + *md5 + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include + +namespace Ui +{ + class settings_dialog; +} + +class settings_dialog:public QDialog +{ +Q_OBJECT public: + explicit settings_dialog (QWidget * parent); + ~settings_dialog (); + +private: + Ui::settings_dialog * ui; +}; + +#endif // SETTINGSDIALOG_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/settings-dialog.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/settings-dialog.ui Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,719 @@ + + + settings_dialog + + + Qt::ApplicationModal + + + + 0 + 0 + 600 + 400 + + + + + 600 + 400 + + + + + 600 + 400 + + + + Settings + + + + + + 0 + + + + Editor + + + + + + + + + + Font + + + + + + + false + + + QFontComboBox::MonospacedFonts + + + + + + + Font Size + + + + + + + 2 + + + 96 + + + 10 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + true + + + Show line numbers + + + false + + + + + + + true + + + Highlight current line + + + false + + + + + + + true + + + Code completion + + + false + + + + + + + Show complete path in window title + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + true + + + Use custom file editor: + + + + + + + false + + + emacs + + + + + + + + + + Terminal + + + + + + + + Font + + + + + + + false + + + QFontComboBox::MonospacedFonts + + + + + + + Font Size + + + + + + + 2 + + + 96 + + + 10 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Cursor type: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Cursor blinking + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 321 + + + + + + + + + File Browser + + + + + + Show filenames + + + + + + + Show file size + + + + + + + Show file type + + + + + + + Show date of last modification + + + + + + + Show hidden files + + + + + + + Alternating row colors + + + + + + + Qt::Vertical + + + + 20 + 360 + + + + + + + + + Network + + + + + + Use proxy server + + + + + + + + + false + + + Proxy Type: + + + + + + + false + + + + HttpProxy + + + + + Socks5Proxy + + + + + + + + false + + + Hostname: + + + + + + + false + + + + + + + false + + + Port: + + + + + + + false + + + + + + + false + + + Username: + + + + + + + false + + + + + + + false + + + Password: + + + + + + + false + + + QLineEdit::Password + + + + + + + + + + + + + + + useProxyServer + toggled(bool) + label_4 + setEnabled(bool) + + + 249 + 59 + + + 69 + 122 + + + + + useProxyServer + toggled(bool) + label_3 + setEnabled(bool) + + + 249 + 59 + + + 59 + 91 + + + + + useProxyServer + toggled(bool) + label_5 + setEnabled(bool) + + + 249 + 59 + + + 44 + 152 + + + + + useProxyServer + toggled(bool) + proxyType + setEnabled(bool) + + + 249 + 59 + + + 291 + 91 + + + + + useProxyServer + toggled(bool) + proxyHostName + setEnabled(bool) + + + 249 + 59 + + + 291 + 124 + + + + + useProxyServer + toggled(bool) + proxyPort + setEnabled(bool) + + + 249 + 59 + + + 364 + 154 + + + + + useCustomFileEditor + toggled(bool) + customFileEditor + setEnabled(bool) + + + 111 + 62 + + + 343 + 63 + + + + + useProxyServer + toggled(bool) + label_7 + setEnabled(bool) + + + 249 + 59 + + + 67 + 212 + + + + + editor_showLineNumbers + toggled(bool) + editor_showLineNumbers + setEnabled(bool) + + + 249 + 87 + + + 249 + 87 + + + + + editor_highlightCurrentLine + toggled(bool) + editor_highlightCurrentLine + setEnabled(bool) + + + 249 + 112 + + + 249 + 112 + + + + + useProxyServer + toggled(bool) + proxyUserName + setEnabled(bool) + + + 249 + 59 + + + 364 + 184 + + + + + useProxyServer + toggled(bool) + proxyPassword + setEnabled(bool) + + + 249 + 59 + + + 364 + 214 + + + + + useProxyServer + toggled(bool) + label_6 + setEnabled(bool) + + + 249 + 59 + + + 68 + 182 + + + + + editor_codeCompletion + toggled(bool) + editor_codeCompletion + setEnabled(bool) + + + 249 + 137 + + + 249 + 137 + + + + + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/src.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/src.pro Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,139 @@ +# OctaveGUI - A graphical user interface for Octave +# Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) +# +# 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 . + +# Basic settings: +QT += core gui webkit network # Qt modules +TEMPLATE = app # Build as application +TARGET = octave-gui # Name of the target binary + +DESTDIR = ../bin # Destination of the output + +TRANSLATIONS += languages/generic.ts \ + languages/de-de.ts \ + languages/pt-br.ts \ + languages/es-es.ts \ + languages/ru-ru.ts \ + languages/uk-ua.ts # Available translations + +win32-msvc*: include(msvc.pri) + +LIBS += -lreadline -lqscintilla2 \ + -L../qterminal/libqterminal/$$LIBDIR_SUFFIX -lqterminal -lm \ + -L../../libcruft/.libs -lcruft \ + -L../../liboctave/.libs -loctave \ + -L../../src/.libs -loctinterp + +mac { + CONFIG -= app_bundle +} + +# Includepaths and libraries to link against: +INCLUDEPATH += . \ + octave-adapter \ + m-editor \ + qtinfo \ + ../qterminal/libqterminal \ + /usr/include/qt4 \ + ../.. \ + ../../src \ + ../../src/interpfcn \ + ../../src/interp-core \ + ../../src/octave-value \ + ../../src/parse-tree \ + ../../src/operators \ + ../../liboctave \ + ../../libcruft/misc + +#QMAKE_LIBDIR += $$system(octave-config -p OCTLIBDIR) +#unix { +# QMAKE_RPATHDIR += $$system(octave-config -p OCTLIBDIR) +#} + +mac { + LFLAGS += -L/opt/local/lib +} + +unix { + LIBS += -lutil +} + +win32-g++ { + QMAKE_LFLAGS += --enable-auto-import +} + +win32-msvc* { + DEFINES += QSCINTILLA_DLL + QMAKE_CXXFLAGS += -wd4244 +} + +QMAKE_LFLAGS += $$LFLAGS +QMAKE_CXXFLAGS += $$INCFLAGS + +# Files associated with the project: +SOURCES +=\ + octave-adapter/octave-link.cc \ + octave-adapter/octave-main-thread.cc \ + m-editor/lexer-octave-gui.cc \ + m-editor/file-editor.cc \ + m-editor/file-editor-tab.cc \ + m-editor/find-dialog.cc \ + qtinfo/parser.cc \ + qtinfo/webinfo.cc \ + main-window.cc \ + workspace-view.cc \ + history-dockwidget.cc \ + files-dockwidget.cc \ + settings-dialog.cc \ + octave-gui.cc \ + resource-manager.cc \ + welcome-wizard.cc \ + workspace-model.cc \ + terminal-dockwidget.cc \ + octave-qt-event-listener.cc \ + documentation-dockwidget.cc + +HEADERS += \ + octave-adapter/octave-link.h \ + octave-adapter/octave-main-thread.h \ + octave-adapter/octave-event.h \ + octave-adapter/octave-event-observer.h \ + octave-adapter/octave-event-listener.h \ + m-editor/lexer-octave-gui.h \ + m-editor/file-editor.h \ + m-editor/file-editor-interface.h \ + m-editor/file-editor-tab.h \ + m-editor/find-dialog.h \ + qtinfo/parser.h \ + qtinfo/webinfo.h \ + symbol-information.h \ + main-window.h \ + workspace-view.h \ + history-dockwidget.h \ + files-dockwidget.h \ + settings-dialog.h \ + resource-manager.h \ + welcome-wizard.h \ + workspace-model.h \ + terminal-dockwidget.h \ + octave-qt-event-listener.h \ + documentation-dockwidget.h + +FORMS += \ + settings-dialog.ui \ + welcome-wizard.ui + +RESOURCES += \ + resource.qrc diff -r a87fa9132b72 -r dbc43bd95477 gui/src/symbol-information.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/symbol-information.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,100 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "ov.h" +#include "symtab.h" + +#include "symbol-information.h" + +bool +symbol_information::from_symbol_record + (const symbol_table::symbol_record& symbol_record) +{ + if (symbol_record.is_local () && !symbol_record.is_global () && !symbol_record.is_hidden ()) + _scope = local; + else if (symbol_record.is_global ()) + _scope = global; + else if (symbol_record.is_persistent ()) + _scope = persistent; + else if (symbol_record.is_hidden ()) + _scope = hidden; + + _symbol = QString (symbol_record.name ().c_str ()); + _type = QString (symbol_record.varval ().type_name ().c_str ()); + octave_value ov = symbol_record.varval (); + + // In case we have really large matrices or strings, cut them down + // for performance reasons. + QString short_value_string; + bool use_short_value_string = false; + if (ov.is_matrix_type () || ov.is_cell ()) + { + if (ov.rows () * ov.columns () > 10) + { + use_short_value_string = true; + short_value_string + = QString ("%1x%2 items").arg (ov.rows ()).arg (ov.columns ()); + } + } + else if (ov.is_string ()) + { + if (ov.string_value ().length () > 40) + { + use_short_value_string = true; + short_value_string + = QString::fromStdString (ov.string_value ().substr (0, 40)); + } + } + + if (use_short_value_string) + { + _value = short_value_string; + } + else + { + std::stringstream buffer; + ov.print (buffer, true); + _value = QString::fromStdString (buffer.str ()); + } + _value.replace("\n", " "); + + if (ov.is_string ()) + _dimension = QString ("%1").arg (ov.string_value ().length ()); + else if (ov.is_range ()) + _dimension = QString ("%1 : %2 : %3").arg (ov.range_value ().base ()) + .arg (ov.range_value ().inc ()) + .arg (ov.range_value ().limit ()); + else if (ov.is_matrix_type () || ov.is_cell ()) + _dimension = QString ("%1x%2").arg (ov.rows ()) + .arg (ov.columns ()); + else if (ov.is_function_handle ()) + // See code for func2str for a possible solution + _dimension = QString ("func handle"); + else if (ov.is_inline_function ()) + // See code for formula for a possible solution + _dimension = QString ("inline func"); + else + _dimension = "1"; + + return true; +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/symbol-information.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/symbol-information.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,86 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef SYMBOLINFORMATION_H +#define SYMBOLINFORMATION_H + +// FIXME -- we should not be including config.h in header files. + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include + +#include "symtab.h" + +/** + * \struct symbol_information + * \brief Meta-information over a symbol-table entry. + * \author Jacob Dawid + * This struct is used to store meta information over a symbol entry. + * It reduces memory consumption, since it only stores relevant data + * about a symbol-table entry that will be used in the model for the + * graphical user interface. + */ +struct symbol_information +{ + enum Scope + { + local = 0, + global = 1, + persistent = 2, + hidden = 3 + }; + + QString _symbol; + QString _type; + QString _value; + QString _dimension; + Scope _scope; + + /** Hashes the symbol information for quickly comparing it. */ + int + hash () const + { + return qHash (_symbol) + qHash (_type) + qHash (_value) + + qHash (_dimension) + (int)_scope; + } + + /** Compares two symbol information objects. */ + bool + equals (const symbol_information& other) const + { + if (hash () == other.hash ()) + { + return _symbol == other._symbol + && _type == other._type + && _value == other._value + && _scope == other._scope + && _dimension == other._dimension; + } + } + + /** Extracts meta information from a given symbol record. */ + bool + from_symbol_record (const symbol_table::symbol_record& symbol_record); +}; + +#endif // SYMBOLINFORMATION_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/terminal-dockwidget.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/terminal-dockwidget.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,28 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "terminal-dockwidget.h" + +terminal_dock_widget::terminal_dock_widget (QTerminal *terminal, QWidget *parent) + : QDockWidget (parent) +{ + setObjectName ("TerminalDockWidget"); + setWindowTitle (tr ("Command Window")); + setWidget (terminal); + + connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT (handle_visibility_changed (bool))); +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/terminal-dockwidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/terminal-dockwidget.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,41 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef TERMINALDOCKWIDGET_H +#define TERMINALDOCKWIDGET_H + +#include +#include "QTerminal.h" + +class terminal_dock_widget : public QDockWidget +{ + Q_OBJECT +public: + terminal_dock_widget (QTerminal *terminal, QWidget *parent = 0); + +signals: + void active_changed (bool active); + +public slots: + void handle_visibility_changed (bool visible) + { + if (visible) + emit active_changed (true); + } +}; + +#endif // TERMINALDOCKWIDGET_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/welcome-wizard.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/welcome-wizard.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,53 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "welcome-wizard.h" +#include "ui-welcome-wizard.h" + +welcome_wizard::welcome_wizard (QWidget *parent) : + QDialog (parent), + _ui (new Ui::welcome_wizard) +{ + _ui->setupUi (this); + connect (_ui->nextButton1, SIGNAL (clicked ()), this, SLOT (next ())); + connect (_ui->nextButton2, SIGNAL (clicked ()), this, SLOT (next ())); + connect (_ui->nextButton3, SIGNAL (clicked ()), this, SLOT (next ())); + connect (_ui->nextButton4, SIGNAL (clicked ()), this, SLOT (next ())); + + connect (_ui->previousButton2, SIGNAL (clicked ()), this, SLOT (previous ())); + connect (_ui->previousButton3, SIGNAL (clicked ()), this, SLOT (previous ())); + connect (_ui->previousButton4, SIGNAL (clicked ()), this, SLOT (previous ())); + connect (_ui->previousButton5, SIGNAL (clicked ()), this, SLOT (previous ())); +} + +welcome_wizard::~welcome_wizard() +{ + delete _ui; +} + +void +welcome_wizard::next () +{ + _ui->stackedWidget->setCurrentIndex (_ui->stackedWidget->currentIndex () + 1); +} + +void +welcome_wizard::previous () +{ + _ui->stackedWidget->setCurrentIndex (_ui->stackedWidget->currentIndex () - 1); +} + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/welcome-wizard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/welcome-wizard.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,43 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef WELCOMEWIZARD_H +#define WELCOMEWIZARD_H + +#include + +namespace Ui { + class welcome_wizard; +} + +class welcome_wizard : public QDialog +{ + Q_OBJECT + +public: + explicit welcome_wizard (QWidget *parent = 0); + ~welcome_wizard (); + +public slots: + void next (); + void previous (); + +private: + Ui::welcome_wizard *_ui; +}; + +#endif // WELCOMEWIZARD_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/welcome-wizard.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/welcome-wizard.ui Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,354 @@ + + + welcome_wizard + + + + 0 + 0 + 647 + 400 + + + + + 647 + 400 + + + + + 647 + 400 + + + + Welcome to GNU Octave + + + + + + 4 + + + + + + + It appears that you have launched Octave GUI for the first time on this computer, since no configuration file could be found at '~/.octave-gui'. This wizard will guide you through the essential settings you should make before you can start using Octave GUI. If you want to transfer your settings you have previously made just close this dialog and copy over the settings file to your home folder. The presence of that file will automatically be detected and will skip this wizard. IMPORTANT: This wizard is not fully functional yet. Just click your way to the end and it will create a standard settings file. + + + Qt::AlignJustify|Qt::AlignVCenter + + + true + + + + + + + Qt::Vertical + + + + 20 + 218 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Next + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Previous + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Next + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Previous + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Next + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Previous + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Next + + + + + + + + + + + + + + + + + + 20 + + + + Welcome to Octave! + + + + + + + This is the development version of Octave with the first official GUI. + + + true + + + + + + + You seem to run Octave GUI for the first time on this computer. This assistant will help you to configure this software installation. Click 'Finish' to write a configuration file and launch Octave GUI. + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + false + + + Previous + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Finish + + + + + + + + + + + + + + + + + finishButton + clicked() + welcome_wizard + accept() + + + 577 + 372 + + + 323 + 199 + + + + + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/workspace-model.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/workspace-model.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,224 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include + +#include + +#include "workspace-model.h" +#include "octave-link.h" + +workspace_model::workspace_model(QObject *parent) + : QAbstractItemModel(parent), octave_event_observer () +{ + QList rootData; + rootData << tr ("Name") << tr ("Type") << tr("Dimension") << tr ("Value"); + _rootItem = new tree_item(rootData); + + insert_top_level_item(0, new tree_item ("Local")); + insert_top_level_item(1, new tree_item ("Global")); + insert_top_level_item(2, new tree_item ("Persistent")); + insert_top_level_item(3, new tree_item ("Hidden")); + + connect(&_update_workspace_model_timer, + SIGNAL (timeout ()), + this, + SLOT (request_update_workspace())); + + _update_workspace_model_timer.setInterval (500); + _update_workspace_model_timer.setSingleShot (true); + _update_workspace_model_timer.start (); +} + +workspace_model::~workspace_model() +{ + delete _rootItem; +} + +void +workspace_model::request_update_workspace () +{ + octave_link::instance () + ->post_event (new octave_update_workspace_event (*this)); +} + +void +workspace_model::event_accepted (octave_event *e) +{ + if (dynamic_cast (e)) + { + std::list < symbol_table::symbol_record > symbolTable = symbol_table::all_variables (); + + _symbol_information.clear (); + for (std::list < symbol_table::symbol_record > ::iterator iterator = symbolTable.begin (); + iterator != symbolTable.end (); iterator++) + { + symbol_information symbolInformation; + symbolInformation.from_symbol_record (*iterator); + _symbol_information.push_back (symbolInformation); + } + + beginResetModel(); + top_level_item (0)->delete_child_items (); + top_level_item (1)->delete_child_items (); + top_level_item (2)->delete_child_items (); + top_level_item (3)->delete_child_items (); + + foreach (const symbol_information& s, _symbol_information) + { + tree_item *child = new tree_item (); + + child->set_data (0, s._symbol); + child->set_data (1, s._type); + child->set_data (2, s._dimension); + child->set_data (3, s._value); + + switch (s._scope) + { + case symbol_information::local: top_level_item (0)->add_child (child); break; + case symbol_information::global: top_level_item (1)->add_child (child); break; + case symbol_information::persistent: top_level_item (2)->add_child (child); break; + case symbol_information::hidden: top_level_item (3)->add_child (child); break; + } + } + + endResetModel(); + emit model_changed(); + } + + // Post a new event in a given time. + // This prevents flooding the event queue when no events are being processed. + _update_workspace_model_timer.start (); + delete e; +} + +void +workspace_model::event_reject (octave_event *e) +{ + delete e; +} + +QModelIndex +workspace_model::index(int row, int column, const QModelIndex &parent) const +{ + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + tree_item *parentItem; + + if (!parent.isValid()) + parentItem = _rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + tree_item *childItem = parentItem->child(row); + if (childItem) + return createIndex(row, column, childItem); + else + return QModelIndex(); +} + +QModelIndex +workspace_model::parent(const QModelIndex &index) const +{ + if (!index.isValid()) + return QModelIndex(); + + tree_item *childItem = static_cast(index.internalPointer()); + tree_item *parentItem = childItem->parent(); + + if (parentItem == _rootItem) + return QModelIndex(); + + return createIndex(parentItem->row(), 0, parentItem); +} + +int +workspace_model::rowCount(const QModelIndex &parent) const +{ + tree_item *parentItem; + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) + parentItem = _rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + return parentItem->child_count(); +} + +int +workspace_model::columnCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return static_cast(parent.internalPointer())->column_count(); + else + return _rootItem->column_count(); +} + +void +workspace_model::insert_top_level_item(int at, tree_item *treeItem) +{ + _rootItem->insert_child_item(at, treeItem); +} + +tree_item * +workspace_model::top_level_item (int at) +{ + return _rootItem->child(at); +} + +Qt::ItemFlags +workspace_model::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return 0; + + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +QVariant +workspace_model::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + return _rootItem->data(section); + + return QVariant(); +} + +QVariant +workspace_model::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (role != Qt::DisplayRole) + return QVariant(); + + tree_item *item = static_cast(index.internalPointer()); + + return item->data(index.column()); +} + diff -r a87fa9132b72 -r dbc43bd95477 gui/src/workspace-model.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/workspace-model.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,150 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef WORKSPACEMODEL_H +#define WORKSPACEMODEL_H + +// Qt includes +#include +#include +#include +#include + +#include "symbol-information.h" +#include "octave-event-observer.h" + +class tree_item +{ +public: + tree_item (const QList &data, tree_item *parent = 0) { + _parent_item = parent; + _item_data = data; + } + + tree_item (QVariant data = QVariant(), tree_item *parent = 0) { + QList variantList; + variantList << data << QVariant () << QVariant () << QVariant (); + _parent_item = parent; + _item_data = variantList; + } + + ~tree_item () { + qDeleteAll (_child_items); + } + + void insert_child_item (int at, tree_item *item) { + item->_parent_item = this; + _child_items.insert (at, item); + } + + void add_child (tree_item *item) { + item->_parent_item = this; + _child_items.append (item); + } + + void delete_child_items () { + qDeleteAll (_child_items); + _child_items.clear (); + } + + void remove_child (tree_item *item) { + _child_items.removeAll (item); + } + + QVariant data (int column) const + { + return _item_data[column]; + } + + void set_data (int column, QVariant data) + { + _item_data[column] = data; + } + + tree_item *child (int row) { + return _child_items[row]; + } + + int child_count () const { + return _child_items.count(); + } + + int column_count () const + { + return _item_data.count(); + } + + int row () const { + if (_parent_item) + return _parent_item->_child_items.indexOf (const_cast(this)); + + return 0; + } + + tree_item *parent () + { + return _parent_item; + } + +private: + QList _child_items; + QList _item_data; + tree_item *_parent_item; +}; + +class workspace_model + : public QAbstractItemModel, public octave_event_observer +{ + Q_OBJECT + +public: + workspace_model (QObject *parent = 0); + ~workspace_model (); + + void event_accepted (octave_event *e); + void event_reject (octave_event *e); + + QVariant data (const QModelIndex &index, int role) const; + Qt::ItemFlags flags (const QModelIndex &index) const; + QVariant headerData (int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QModelIndex index (int row, int column, + const QModelIndex &parent = QModelIndex ()) const; + QModelIndex parent (const QModelIndex &index) const; + int rowCount (const QModelIndex &parent = QModelIndex ()) const; + int columnCount (const QModelIndex &parent = QModelIndex ()) const; + + void insert_top_level_item (int at, tree_item *treeItem); + tree_item *top_level_item (int at); + +public slots: + void request_update_workspace (); + +signals: + void model_changed (); + +private: + /** Timer for periodically updating the workspace model from the current + * symbol information. */ + QTimer _update_workspace_model_timer; + + /** Stores the current symbol information. */ + QList _symbol_information; + tree_item *_rootItem; +}; + +#endif // WORKSPACEMODEL_H diff -r a87fa9132b72 -r dbc43bd95477 gui/src/workspace-view.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/workspace-view.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,207 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#include "workspace-view.h" +#include "resource-manager.h" +#include +#include +#include + +workspace_view::workspace_view (QWidget * parent) : QDockWidget + (parent) +{ + setObjectName ("WorkspaceView"); + setWindowTitle (tr ("Workspace")); + + // Create a new workspace model. + _workspace_model = new workspace_model (); + + _workspace_tree_view = new QTreeView (this); // Create a new tree view. + _workspace_tree_view->setHeaderHidden (false); // Do not show header columns. + _workspace_tree_view->setAlternatingRowColors (true); // Activate alternating row colors. + _workspace_tree_view->setAnimated (false); // Deactivate animations because of strange glitches. + _workspace_tree_view->setTextElideMode (Qt::ElideRight);// Elide text to the right side of the cells. + _workspace_tree_view->setWordWrap (false); // No wordwrapping in cells. + _workspace_tree_view->setModel (_workspace_model); // Assign model. + + // Set an empty widget, so we can assign a layout to it. + setWidget (new QWidget (this)); + + // Create a new layout and add widgets to it. + QVBoxLayout *layout = new QVBoxLayout (); + layout->addWidget (_workspace_tree_view); + layout->setMargin (2); + + // Set the empty widget to have our layout. + widget ()->setLayout (layout); + + // Initialize collapse/expand state of the workspace subcategories. + _explicit_collapse.local = resource_manager::instance ()->get_settings ()->value ("workspaceview/local_collapsed", false).toBool (); + _explicit_collapse.global = resource_manager::instance ()->get_settings ()->value ("workspaceview/global_collapsed", false).toBool ();; + _explicit_collapse.persistent = resource_manager::instance ()->get_settings ()->value ("workspaceview/persistent_collapsed", false).toBool ();; + _explicit_collapse.hidden = resource_manager::instance ()->get_settings ()->value ("workspaceview/hidden_collapsed", false).toBool ();; + + // Connect signals and slots. + connect (this, SIGNAL (visibilityChanged (bool)), + this, SLOT(handle_visibility_changed (bool))); + + connect (_workspace_model, SIGNAL (model_changed ()), + this, SLOT (model_changed ())); + + connect (_workspace_tree_view, SIGNAL (collapsed (QModelIndex)), + this, SLOT (collapse_requested (QModelIndex))); + connect (_workspace_tree_view, SIGNAL (expanded (QModelIndex)), + this, SLOT (expand_requested (QModelIndex))); + + connect (_workspace_tree_view, SIGNAL (doubleClicked (QModelIndex)), + this, SLOT (item_double_clicked (QModelIndex))); + +} + +workspace_view::~workspace_view () +{ + resource_manager::instance ()->get_settings ()->setValue("workspaceview/local_collapsed", _explicit_collapse.local); + resource_manager::instance ()->get_settings ()->setValue("workspaceview/global_collapsed", _explicit_collapse.global); + resource_manager::instance ()->get_settings ()->setValue("workspaceview/persistent_collapsed", _explicit_collapse.persistent); + resource_manager::instance ()->get_settings ()->setValue("workspaceview/hidden_collapsed", _explicit_collapse.hidden); +} + +void +workspace_view::handle_visibility_changed (bool visible) +{ + if (visible) + emit active_changed (true); +} + +void +workspace_view::model_changed () +{ + // This code is very quirky and requires some explanation. + // Usually, we should not deal with collapsing or expanding ourselves, + // because the view itself determines (based on the model) whether it + // is appropriate to collapse or expand items. + // + // Now, the logic requires that we update our model item by item, which + // would make it work correctly, but this is extremely slow and scales + // very bad (O(n^2)). That's why we throw away our model and rebuild it + // completely from scratch (O(n)), which is why the view renders all + // displayed data as invalid. + // + // In order to make collapsing/expanding work again, we need to set + // flags ourselves here. + + QModelIndex local_model_index = _workspace_model->index (0, 0); + QModelIndex global_model_index = _workspace_model->index (1, 0); + QModelIndex persistent_model_index = _workspace_model->index (2, 0); + QModelIndex hidden_model_index = _workspace_model->index (3, 0); + + if (_explicit_collapse.local) { + _workspace_tree_view->collapse (local_model_index); + } else { + _workspace_tree_view->expand (local_model_index); + } + + if (_explicit_collapse.global) { + _workspace_tree_view->collapse (global_model_index); + } else { + _workspace_tree_view->expand (global_model_index); + } + + if (_explicit_collapse.persistent) { + _workspace_tree_view->collapse (persistent_model_index); + } else { + _workspace_tree_view->expand (persistent_model_index); + } + + if (_explicit_collapse.hidden) { + _workspace_tree_view->collapse (hidden_model_index); + } else { + _workspace_tree_view->expand (hidden_model_index); + } +} + +void +workspace_view::collapse_requested (QModelIndex index) +{ + // This code is very quirky and requires some explanation. + // Usually, we should not deal with collapsing or expanding ourselves, + // because the view itself determines (based on the model) whether it + // is appropriate to collapse or expand items. + // + // Now, the logic requires that we update our model item by item, which + // would make it work correctly, but this is extremely slow and scales + // very bad (O(n^2)). That's why we throw away our model and rebuild it + // completely from scratch (O(n)), which is why the view renders all + // displayed data as invalid. + // + // In order to make collapsing/expanding work again, we need to set + // flags ourselves here. + QMap item_data + = _workspace_model->itemData (index); + + if (item_data[0] == "Local") + _explicit_collapse.local = true; + if (item_data[0] == "Global") + _explicit_collapse.global = true; + if (item_data[0] == "Persistent") + _explicit_collapse.persistent = true; + if (item_data[0] == "Hidden") + _explicit_collapse.hidden = true; +} + +void +workspace_view::expand_requested (QModelIndex index) +{ + // This code is very quirky and requires some explanation. + // Usually, we should not deal with collapsing or expanding ourselves, + // because the view itself determines (based on the model) whether it + // is appropriate to collapse or expand items. + // + // Now, the logic requires that we update our model item by item, which + // would make it work correctly, but this is extremely slow and scales + // very bad (O(n^2)). That's why we throw away our model and rebuild it + // completely from scratch (O(n)), which is why the view renders all + // displayed data as invalid. + // + // In order to make collapsing/expanding work again, we need to do set + // flags ourselves here. + QMap item_data + = _workspace_model->itemData (index); + + if (item_data[0] == "Local") + _explicit_collapse.local = false; + if (item_data[0] == "Global") + _explicit_collapse.global = false; + if (item_data[0] == "Persistent") + _explicit_collapse.persistent = false; + if (item_data[0] == "Hidden") + _explicit_collapse.hidden = false; +} + +void +workspace_view::item_double_clicked (QModelIndex index) +{ + Q_UNUSED (index); + // TODO: Implement opening a dialog that allows the user to change a variable in the workspace. +} + +void +workspace_view::closeEvent (QCloseEvent *event) +{ + emit active_changed (false); + QDockWidget::closeEvent (event); +} diff -r a87fa9132b72 -r dbc43bd95477 gui/src/workspace-view.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/src/workspace-view.h Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,65 @@ +/* OctaveGUI - A graphical user interface for Octave + * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com) + * + * 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 . + */ + +#ifndef WORKSPACEVIEW_H +#define WORKSPACEVIEW_H + +#include +#include +#include +#include "octave-link.h" +#include "workspace-model.h" + +class workspace_view : public QDockWidget +{ + Q_OBJECT +public: + workspace_view (QWidget * parent = 0); + ~workspace_view (); + +public slots: + void handle_visibility_changed (bool visible); + void model_changed (); + +signals: + /** Custom signal that tells if a user has clicke away that dock widget. */ + void active_changed (bool active); + +protected: + void closeEvent (QCloseEvent *event); + +protected slots: + void collapse_requested (QModelIndex index); + void expand_requested (QModelIndex index); + void item_double_clicked (QModelIndex index); + +private: + QTreeView *_workspace_tree_view; + + /** Stores the current workspace model. */ + workspace_model *_workspace_model; + + struct + { + bool local; + bool global; + bool persistent; + bool hidden; + } _explicit_collapse; +}; + +#endif // WORKSPACEVIEW_H diff -r a87fa9132b72 -r dbc43bd95477 gui/translators --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/translators Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,8 @@ +# Below Octave GUI translators are listed with their e-mails +# to be able inform them about generic translation file changes +en-en Jacob Dawid +es-es Valentin Ortega-Clavero +de-de Jacob Dawid +pt-br Júlio Hoffimann Mendes +ru-ru Andriy Shinkarchuck +uk-ua Andriy Shinkarchuck diff -r a87fa9132b72 -r dbc43bd95477 run-octave.in --- a/run-octave.in Sat Aug 11 17:32:42 2012 -0400 +++ b/run-octave.in Mon Aug 13 10:32:19 2012 -0400 @@ -42,6 +42,8 @@ d2_path=`echo "$d2_list" | $AWK '{ t = (s $0); s = t; } END { sub (/:$/, "", s); print s; }'` d3_path=`echo "$d3_list" | $AWK '{ t = (s $0); s = t; } END { sub (/:$/, "", s); print s; }'` +octave_executable="$builddir/src/octave" + LOADPATH="$d1_path:$d2_path:$d3_path" IMAGEPATH="$top_srcdir/scripts/image" DOCFILE="$builddir/doc/interpreter/doc-cache" @@ -64,11 +66,15 @@ elif [ "x$1" = "x-strace" ]; then driver="strace -o octave.trace" shift + elif [ "x$1" = "x-cli" ]; then + octave_executable="$builddir/src/octave-cli" + shift fi fi OCTAVE_SITE_INITFILE="$top_srcdir/scripts/startup/main-rcfile" \ +OCTAVE_DEFAULT_QT_SETTINGS="$top_srcdir/gui/default-qt-settings" \ exec $builddir/libtool --mode=execute $driver \ - "$builddir/src/octave" --no-init-path --path="$LOADPATH" \ + "$octave_executable" --no-init-path --path="$LOADPATH" \ --image-path="$IMAGEPATH" --doc-cache-file="$DOCFILE" \ --texi-macros-file="$TEXIMACROSFILE" --info-file="$INFOFILE" "$@" diff -r a87fa9132b72 -r dbc43bd95477 scripts/plot/__gnuplot_drawnow__.m diff -r a87fa9132b72 -r dbc43bd95477 src/Makefile.am --- a/src/Makefile.am Sat Aug 11 17:32:42 2012 -0400 +++ b/src/Makefile.am Mon Aug 13 10:32:19 2012 -0400 @@ -39,7 +39,7 @@ if AMCOND_BUILD_COMPILED_AUX_PROGRAMS bin_PROGRAMS = \ mkoctfile \ - octave \ + $(OCTAVE_PROGRAMS) \ octave-config mkoctfile_SOURCES = @@ -58,7 +58,8 @@ octave-config.cc else bin_PROGRAMS = \ - octave + octave \ + octave-cli bin_SCRIPTS = \ mkoctfile \ @@ -218,18 +219,40 @@ ## FIXME: Does this rule need to be uncommented? #fft.df fft.lo fft2.df fft2.lo fftn.df fftn.lo: CPPFLAGS += $(FFTW_XCPPFLAGS) -octave_SOURCES = main.c - -octave_LDADD = \ +OCTAVE_CORE_LIBS = \ liboctinterp.la \ ../liboctave/liboctave.la \ - ../libcruft/libcruft.la \ + ../libcruft/libcruft.la + +octave_cli_SOURCES = main-cli.cc + +octave_cli_LDADD = \ + $(OCTAVE_CORE_LIBS) $(OCTAVE_LINK_DEPS) -octave_LDFLAGS = \ +octave_cli_LDFLAGS = \ $(NO_UNDEFINED_LDFLAG) \ $(OCTAVE_LINK_OPTS) +if AMCOND_BUILD_GUI + octave_SOURCES = main.cc + OCTAVE_GUI_LIBS = ../gui/src/liboctgui.la + OCTAVE_GUI_CPPFLAGS = -I$(top_srcdir)/gui/src +else + octave_SOURCES = main-cli.cc + OCTAVE_GUI_LIBS = + OCTAVE_GUI_CPPFLAGS = +endif + +octave_CPPFLAGS = $(OCTAVE_GUI_CPPFLAGS) + +octave_LDADD = \ + $(OCTAVE_CORE_LIBS) \ + $(OCTAVE_GUI_LIBS) \ + $(OCTAVE_LINK_DEPS) + +octave_LDFLAGS = $(octave_cli_LDFLAGS) + ## Section for defining and creating DEF_FILES SRC_DEF_FILES := $(shell $(srcdir)/find-defun-files.sh "$(srcdir)" $(DIST_SRC)) diff -r a87fa9132b72 -r dbc43bd95477 src/interp-core/display.cc --- a/src/interp-core/display.cc Sat Aug 11 17:32:42 2012 -0400 +++ b/src/interp-core/display.cc Mon Aug 13 10:32:19 2012 -0400 @@ -79,6 +79,8 @@ rx = wd * 25.4 / wd_mm; ry = ht * 25.4 / ht_mm; + + dpy_avail = true; } else warning ("no graphical display found"); @@ -109,6 +111,8 @@ rx = wd * 25.4 / wd_mm; ry = ht * 25.4 / ht_mm; + + dpy_avail = true; } else warning ("no graphical display found"); @@ -144,6 +148,8 @@ warning ("X11 display has no default screen"); XCloseDisplay (display); + + dpy_avail = true; } else warning ("unable to open X11 DISPLAY"); diff -r a87fa9132b72 -r dbc43bd95477 src/interp-core/display.h --- a/src/interp-core/display.h Sat Aug 11 17:32:42 2012 -0400 +++ b/src/interp-core/display.h Mon Aug 13 10:32:19 2012 -0400 @@ -30,7 +30,7 @@ protected: display_info (bool query = true) - : ht (1), wd (1), dp (0), rx (72), ry (72) + : ht (1), wd (1), dp (0), rx (72), ry (72), dpy_avail (false) { init (query); } @@ -62,6 +62,11 @@ return instance_ok () ? instance->do_y_dpi () : 0; } + static bool display_available (void) + { + return instance_ok () ? instance->do_display_available () : false; + } + // To disable querying the window system for defaults, this function // must be called before any other display_info function. static void no_window_system (void) @@ -84,6 +89,8 @@ double rx; double ry; + bool dpy_avail; + int do_height (void) const { return ht; } int do_width (void) const { return wd; } int do_depth (void) const { return dp; } @@ -91,6 +98,8 @@ double do_x_dpi (void) const { return rx; } double do_y_dpi (void) const { return ry; } + bool do_display_available (void) const { return dpy_avail; } + void init (bool query = true); static bool instance_ok (bool query = true); diff -r a87fa9132b72 -r dbc43bd95477 src/interpfcn/symtab.h diff -r a87fa9132b72 -r dbc43bd95477 src/interpfcn/toplev.cc --- a/src/interpfcn/toplev.cc Sat Aug 11 17:32:42 2012 -0400 +++ b/src/interpfcn/toplev.cc Mon Aug 13 10:32:19 2012 -0400 @@ -1341,6 +1341,8 @@ { false, "QRUPDATE_CPPFLAGS", OCTAVE_CONF_QRUPDATE_CPPFLAGS }, { false, "QRUPDATE_LDFLAGS", OCTAVE_CONF_QRUPDATE_LDFLAGS }, { false, "QRUPDATE_LIBS", OCTAVE_CONF_QRUPDATE_LIBS }, + { false, "QT_INCDIR", OCTAVE_CONF_QT_INCDIR }, + { false, "QT_LIBDIR", OCTAVE_CONF_QT_LIBDIR }, { false, "RANLIB", OCTAVE_CONF_RANLIB }, { false, "RDYNAMIC_FLAG", OCTAVE_CONF_RDYNAMIC_FLAG }, { false, "READLINE_LIBS", OCTAVE_CONF_READLINE_LIBS }, diff -r a87fa9132b72 -r dbc43bd95477 src/main-cli.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main-cli.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,35 @@ +/* + +Copyright (C) 2012 John W. Eaton + +This file is part of Octave. + +Octave 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. + +Octave 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 Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +int +main (int argc, char **argv) +{ + octave_initialize_interpreter (argc, argv, 0); + + return octave_execute_interpreter (); +} diff -r a87fa9132b72 -r dbc43bd95477 src/main.c --- a/src/main.c Sat Aug 11 17:32:42 2012 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - -Copyright (C) 2002-2012 John W. Eaton - -This file is part of Octave. - -Octave 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. - -Octave 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 Octave; see the file COPYING. If not, see -. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "f77-fcn.h" -#include "lo-ieee.h" - -#include "octave.h" - -int -main (int argc, char **argv) -{ - return octave_main (argc, argv, 0); -} diff -r a87fa9132b72 -r dbc43bd95477 src/main.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main.cc Mon Aug 13 10:32:19 2012 -0400 @@ -0,0 +1,39 @@ +/* + +Copyright (C) 2012 John W. Eaton + +This file is part of Octave. + +Octave 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. + +Octave 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 Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +int +main (int argc, char **argv) +{ + octave_initialize_interpreter (argc, argv, 0); + + if (octave_starting_gui ()) + return octave_start_gui (argc, argv); + + return octave_execute_interpreter (); +} diff -r a87fa9132b72 -r dbc43bd95477 src/oct-conf.in.h --- a/src/oct-conf.in.h Sat Aug 11 17:32:42 2012 -0400 +++ b/src/oct-conf.in.h Mon Aug 13 10:32:19 2012 -0400 @@ -464,6 +464,14 @@ #define OCTAVE_CONF_QRUPDATE_LIBS %OCTAVE_CONF_QRUPDATE_LIBS% #endif +#ifndef OCTAVE_CONF_QT_INCDIR +#define OCTAVE_CONF_QT_INCDIR %OCTAVE_CONF_QT_INCDIR% +#endif + +#ifndef OCTAVE_CONF_QT_LIBDIR +#define OCTAVE_CONF_QT_LIBDIR %OCTAVE_CONF_QT_LIBDIR% +#endif + #ifndef OCTAVE_CONF_RANLIB #define OCTAVE_CONF_RANLIB %OCTAVE_CONF_RANLIB% #endif diff -r a87fa9132b72 -r dbc43bd95477 src/octave.cc --- a/src/octave.cc Sat Aug 11 17:32:42 2012 -0400 +++ b/src/octave.cc Mon Aug 13 10:32:19 2012 -0400 @@ -56,6 +56,7 @@ #include "lex.h" #include "load-path.h" #include "octave.h" +#include "oct-conf.h" #include "oct-hist.h" #include "oct-map.h" #include "oct-mutex.h" @@ -81,6 +82,10 @@ extern void install_builtins (void); +int octave_cmdline_argc; +char **octave_cmdline_argv; +int octave_embedded; + // The command-line options. static string_vector octave_argv; @@ -115,14 +120,23 @@ // (--verbose; -V) static bool verbose_flag = false; +// If TRUE, force the GUI to start. +// (--force-gui) +static bool force_gui_option = false; + +// If TRUE don't start the GUI. +// (--no-gui) +static bool no_gui_option = false; + // Usage message static const char *usage_string = "octave [-HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE]\n\ - [--exec-path path] [--help] [--image-path path] [--info-file file]\n\ - [--info-program prog] [--interactive] [--line-editing]\n\ - [--no-history] [--no-init-file] [--no-init-path] [--no-line-editing]\n\ - [--no-site-file] [--no-window-system] [-p path] [--path path]\n\ - [--silent] [--traditional] [--verbose] [--version] [file]"; + [--exec-path path] [--force-gui] [--help] [--image-path path]\n\ + [--info-file file] [--info-program prog] [--interactive]\n\ + [--line-editing] [--no-gui] [--no-history] [--no-init-file]\n\ + [--no-init-path] [--no-line-editing] [--no-site-file]\n\ + [--no-window-system] [-p path] [--path path] [--silent]\n\ + [--traditional] [--verbose] [--version] [file]"; // This is here so that it's more likely that the usage message and // the real set of options will agree. Note: the `+' must come first @@ -140,18 +154,20 @@ #define DOC_CACHE_FILE_OPTION 1 #define EVAL_OPTION 2 #define EXEC_PATH_OPTION 3 -#define IMAGE_PATH_OPTION 4 -#define INFO_FILE_OPTION 5 -#define INFO_PROG_OPTION 6 -#define LINE_EDITING_OPTION 7 -#define NO_INIT_FILE_OPTION 8 -#define NO_INIT_PATH_OPTION 9 -#define NO_LINE_EDITING_OPTION 10 -#define NO_SITE_FILE_OPTION 11 -#define NO_WINDOW_SYSTEM_OPTION 12 -#define PERSIST_OPTION 13 -#define TEXI_MACROS_FILE_OPTION 14 -#define TRADITIONAL_OPTION 15 +#define FORCE_GUI_OPTION 4 +#define IMAGE_PATH_OPTION 5 +#define INFO_FILE_OPTION 6 +#define INFO_PROG_OPTION 7 +#define LINE_EDITING_OPTION 8 +#define NO_GUI_OPTION 9 +#define NO_INIT_FILE_OPTION 10 +#define NO_INIT_PATH_OPTION 11 +#define NO_LINE_EDITING_OPTION 12 +#define NO_SITE_FILE_OPTION 13 +#define NO_WINDOW_SYSTEM_OPTION 14 +#define PERSIST_OPTION 15 +#define TEXI_MACROS_FILE_OPTION 16 +#define TRADITIONAL_OPTION 17 struct option long_opts[] = { { "braindead", no_argument, 0, TRADITIONAL_OPTION }, @@ -160,12 +176,14 @@ { "echo-commands", no_argument, 0, 'x' }, { "eval", required_argument, 0, EVAL_OPTION }, { "exec-path", required_argument, 0, EXEC_PATH_OPTION }, + { "force-gui", no_argument, 0, FORCE_GUI_OPTION }, { "help", no_argument, 0, 'h' }, { "image-path", required_argument, 0, IMAGE_PATH_OPTION }, { "info-file", required_argument, 0, INFO_FILE_OPTION }, { "info-program", required_argument, 0, INFO_PROG_OPTION }, { "interactive", no_argument, 0, 'i' }, { "line-editing", no_argument, 0, LINE_EDITING_OPTION }, + { "no-gui", no_argument, 0, NO_GUI_OPTION }, { "no-history", no_argument, 0, 'H' }, { "no-init-file", no_argument, 0, NO_INIT_FILE_OPTION }, { "no-init-path", no_argument, 0, NO_INIT_PATH_OPTION }, @@ -628,11 +646,27 @@ disable_warning ("Octave:possible-matlab-short-circuit-operator"); } -// You guessed it. +// EMBEDDED is declared int instead of bool because this function is +// declared extern "C". int octave_main (int argc, char **argv, int embedded) { + octave_initialize_interpreter (argc, argv, embedded); + + return octave_execute_interpreter (); +} + +// EMBEDDED is declared int instead of bool because this function is +// declared extern "C". + +void +octave_initialize_interpreter (int argc, char **argv, int embedded) +{ + octave_cmdline_argc = argc; + octave_cmdline_argv = argv; + octave_embedded = embedded; + octave_env::set_program_name (argv[0]); octave_program_invocation_name = octave_env::get_program_invocation_name (); @@ -771,6 +805,10 @@ set_exec_path (optarg); break; + case FORCE_GUI_OPTION: + force_gui_option = true; + break; + case IMAGE_PATH_OPTION: if (optarg) set_image_path (optarg); @@ -794,6 +832,10 @@ read_init_files = false; break; + case NO_GUI_OPTION: + no_gui_option = true; + break; + case NO_INIT_PATH_OPTION: set_initial_path = false; break; @@ -833,6 +875,12 @@ } } + if (force_gui_option && no_gui_option) + { + error ("error: only one of --force-gui and --no-gui may be used"); + usage (); + } + // Make sure we clean up when we exit. Also allow users to register // functions. If we don't have atexit or on_exit, we're going to // leave some junk files around if we exit abnormally. @@ -862,9 +910,6 @@ if (line_editing) initialize_command_input (); - if (! inhibit_startup_message) - std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; - if (traditional) maximum_braindamage (); @@ -880,6 +925,13 @@ load_path::initialize (set_initial_path); initialize_history (read_history_file); +} + +int +octave_execute_interpreter (void) +{ + if (! inhibit_startup_message) + std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; execute_startup_files (); @@ -892,7 +944,7 @@ int last_arg_idx = optind; - int remaining_args = argc - last_arg_idx; + int remaining_args = octave_cmdline_argc - last_arg_idx; if (! code_to_eval.empty ()) { @@ -907,9 +959,9 @@ // If we are running an executable script (#! /bin/octave) then // we should only see the args passed to the script. - intern_argv (remaining_args, argv+last_arg_idx); + intern_argv (remaining_args, octave_cmdline_argv+last_arg_idx); - execute_command_line_file (argv[last_arg_idx]); + execute_command_line_file (octave_cmdline_argv[last_arg_idx]); if (! persist) { @@ -924,9 +976,9 @@ command_editor::reset_current_command_number (1); // Now argv should have the full set of args. - intern_argv (argc, argv); + intern_argv (octave_cmdline_argc, octave_cmdline_argv); - if (! embedded) + if (! octave_embedded) switch_to_buffer (create_buffer (get_input_from_stdin ())); // Force input to be echoed if not really interactive, but the user @@ -941,7 +993,7 @@ bind_internal_variable ("echo_executing_commands", ECHO_CMD_LINE); } - if (embedded) + if (octave_embedded) { // FIXME -- do we need to do any cleanup here before // returning? If we don't, what will happen to Octave functions @@ -962,6 +1014,39 @@ return 0; } +// Return int instead of bool because this function is declared +// extern "C". + +int +octave_starting_gui (void) +{ + if (! display_info::display_available ()) + return false; + + if (force_gui_option) + return true; + + if (no_gui_option) + return false; + + if (persist) + return true; + + if (! (interactive || forced_interactive)) + return false; + + // If we have code to eval or execute from a file, and we are going to + // exit immediately after executing it, don't start the gui. + + int last_arg_idx = optind; + int remaining_args = octave_cmdline_argc - last_arg_idx; + + if (! code_to_eval.empty () || remaining_args > 0) + return false; + + return true; +} + DEFUN (argv, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} argv ()\n\ diff -r a87fa9132b72 -r dbc43bd95477 src/octave.h --- a/src/octave.h Sat Aug 11 17:32:42 2012 -0400 +++ b/src/octave.h Mon Aug 13 10:32:19 2012 -0400 @@ -29,6 +29,17 @@ extern OCTINTERP_API int octave_main (int argc, char **argv, int embedded); +extern OCTINTERP_API void +octave_initialize_interpreter (int argc, char **argv, int embedded); + +extern OCTINTERP_API int octave_execute_interpreter (void); + +extern OCTINTERP_API int octave_cmdline_argc; +extern OCTINTERP_API char **octave_cmdline_argv; +extern OCTINTERP_API int octave_embedded; + +extern OCTINTERP_API int octave_starting_gui (void); + #ifdef __cplusplus } #endif