Wei-Ting Lin wrote:
> I have no idea where to start from.

Yeah, that will take a little time.

Attached are few patches I used some time ago
when I created quick and dirty lyx math calculator
which launches external app (maxima) when equation
is finished.

I don't think you can apply those patches right away
with nowadays master, but at least they might give
you few inspirational points what and where to touch
few things. No IO there though.

Pavel
commit 5ede0161b732f33426535c0e467b0ed43093d26c
Author: Pavel Sanda <p...@twin.jikos.cz>
Date:   Mon May 16 22:26:49 2011 +0200

    Revert my older commit in branch which allows usage of command alternatives 
inside mathull.
    We should migrate to user binding instead of enter hardcoding one non lazy 
day.

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index b28142c..fde47dd 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -1549,11 +1549,6 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest 
const & cmd,
                status.setEnabled(true);
                return true;
 
-       // we never allow this in math, and we want to bind enter
-       // to another actions in command-alternatives
-       case LFUN_BREAK_PARAGRAPH:
-               status.setEnabled(false);
-               return true;
        case LFUN_MATH_MUTATE: {
                HullType const ht = hullType(cmd.argument());
                status.setOnOff(type_ == ht);

commit c628b6cb6510a23f85d6f4840402617c39a41a5d
Author: Pavel Sanda <p...@twin.jikos.cz>
Date:   Sat Dec 11 18:33:43 2010 +0100

    More general esc

diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 8ffd80c..5a835fb 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -834,7 +834,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & 
cmd)
                else  {
                        //cmd = FuncRequest(LFUN_FINISHED_FORWARD);
                        //cur.undispatched();
-                       lyx::dispatch(FuncRequest(LFUN_COMMAND_SEQUENCE, 
"inset-select-all;char-delete-backward;math-mode on"));
+                       lyx::dispatch(FuncRequest(LFUN_COMMAND_SEQUENCE, 
"buffer-begin;buffer-end-select;char-delete-backward;math-mode on"));
                }
                break;
 

commit 058b2d6c52ab270282081d9791651873f50922ed
Author: Pavel Sanda <p...@twin.jikos.cz>
Date:   Sat Dec 11 17:22:42 2010 +0100

    Allow smaller size of window

diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index e30ad41..8bd7a34 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -491,7 +491,7 @@ GuiView::GuiView(int id)
 
        // Forbid too small unresizable window because it can happen
        // with some window manager under X11.
-       setMinimumSize(300, 200);
+       setMinimumSize(30, 20);
 
        if (lyxrc.allow_geometry_session) {
                // Now take care of session management.

commit a637afc3a9874418277a24bd4630e074031eb07e
Author: Pavel Sanda <p...@twin.jikos.cz>
Date:   Sat Dec 11 16:59:14 2010 +0100

    Escape for reseting calc

diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 21bfdfe..8ffd80c 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -832,8 +832,9 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & 
cmd)
                if (cur.selection())
                        cur.clearSelection();
                else  {
-                       cmd = FuncRequest(LFUN_FINISHED_FORWARD);
-                       cur.undispatched();
+                       //cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+                       //cur.undispatched();
+                       lyx::dispatch(FuncRequest(LFUN_COMMAND_SEQUENCE, 
"inset-select-all;char-delete-backward;math-mode on"));
                }
                break;
 

commit e23a7c369a6012322810e35065962113cc253403
Author: Pavel Sanda <p...@twin.jikos.cz>
Date:   Sat Dec 11 16:44:59 2010 +0100

    Do not ask for save at the end

diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index 04b3ce9..e30ad41 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -2474,6 +2474,7 @@ bool GuiView::closeBuffer(Buffer & buf)
        // so no need to do it here. This will ensure that the children end up
        // in the session file in the correct order. If we close the master
        // buffer, we can close or release the child buffers here too.
+       lyx::dispatch(FuncRequest(LFUN_BUFFER_WRITE));
        bool success = true;
        if (!closing_) {
                ListOfBuffers clist = buf.getChildren();

commit 8b3431e29ab5eae0a28e479507f323341a2a6039
Author: Pavel Sanda <p...@twin.jikos.cz>
Date:   Sat Dec 11 16:18:19 2010 +0100

    Setup new window and proper inset

diff --git a/src/LyX.cpp b/src/LyX.cpp
index 5ae488d..fbcb8ca 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -574,6 +574,12 @@ void LyX::execCommands()
        // create the first main window
        lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW, geometryArg));
 
+       FileName p=package().user_support();
+       lyx::dispatch(FuncRequest(LFUN_FILE_OPEN, 
p.absFileName()+"calculator.lyx"));
+       lyx::dispatch(FuncRequest(LFUN_COMMAND_SEQUENCE, "char-right;math-mode 
on"));
+       lyx::dispatch(FuncRequest(LFUN_COMMAND_SEQUENCE, "ui-toggle statusbar; 
ui-toggle scrollbar; ui-toggle menubar; ui-toggle frame"));
+
+
        if (!pimpl_->files_to_load_.empty()) {
                // if some files were specified at command-line we assume that 
the
                // user wants to edit *these* files and not to restore the 
session.

commit 051dac7b6be92bd8e233bf3027e316df766bf287
Author: Pavel Sanda <p...@twin.jikos.cz>
Date:   Sat Dec 11 15:31:53 2010 +0100

    Trigger maxima computation on enter

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index a27e00d..b28142c 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -30,6 +30,7 @@
 #include "FuncStatus.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
+#include "LyX.h"
 #include "LyXRC.h"
 #include "MacroTable.h"
 #include "output_xhtml.h"
@@ -1347,6 +1348,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest 
& cmd)
                break;
 
        case LFUN_BREAK_PARAGRAPH:
+               lyx::dispatch(FuncRequest(LFUN_MATH_EXTERN, "maxima"));
                // just swallow this
                break;
 

commit 50755df909ca04408af224fc90211f97655311ed
Author: Pavel Sanda <p...@twin.jikos.cz>
Date:   Sat Dec 11 15:31:05 2010 +0100

    Do not share session info with other lyx instances

diff --git a/src/version.cpp b/src/version.cpp
index 2ae5992..2b494dc 100644
--- a/src/version.cpp
+++ b/src/version.cpp
@@ -20,7 +20,7 @@ extern const int lyx_version_minor = LYX_MINOR_VERSION;
 extern char const * const lyx_release_date = LYX_DATE;
 
 /// Package identifier (lyx[-<version-suffix>])
-extern char const * const lyx_package = PACKAGE;
+extern char const * lyx_package = "lyxcalc";
 
 /// This is the version information shown by 'lyx --version'
 extern char const * const lyx_version_info = VERSION_INFO;

Reply via email to