[q-lang-cvs] qcalc qcalc.q,1.169,1.170
Brought to you by:
agraef
From: Albert G. <ag...@us...> - 2007-11-21 02:58:58
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21757 Modified Files: qcalc.q Log Message: code cleanup, fix checks for local event loop Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.169 retrieving revision 1.170 diff -C2 -d -r1.169 -r1.170 *** qcalc.q 20 Nov 2007 18:58:28 -0000 1.169 --- qcalc.q 21 Nov 2007 02:58:54 -0000 1.170 *************** *** 606,648 **** if qt TABW "currentPageIndex" () = 0; - /* Callbacks. */ - - about _ _ _ = aboutbox $ sprintf - "<h1>QCalc - A Q spreadsheet</h1>\n\ - \n\ - <h2>QCalc %s (Q version %s, %s)</h2>\n\ - CVS version %s\n\ - \n\ - <p><big>%s</big></p>\n\ - \n\ - <p>This program is free software; you can redistribute it and/or modify\n\ - it under the terms of the GNU General Public License as published by\n\ - the Free Software Foundation; either version 2 of the License, or\n\ - (at your option) any later version.</p>\n\ - \n\ - <p>This program is distributed in the hope that it will be useful,\n\ - but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ - GNU General Public License for more details.</p>\n\ - \n\ - <p>You should have received a copy of the GNU General Public License\n\ - along with this program; if not, write to the Free Software\n\ - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</p>" - (VERSION,version,sysinfo,CVS_VERSION,COPYRIGHT); - - /* Qt Assistant interface */ - - /* KLUDGE: At least with Qt3 under X11, it seems to be necessary to give Qt - Assistant some time to start up before we tell it the page to show, - otherwise the wrong page (i.e., whatever page was shown most recently) is - displayed. */ - - assistant PAGE = qt_assistant "" || sleep 0.5 || qt APP "processEvents" () || - fail if not qt_assistant_is_open; - = qt_assistant PAGE; - - help A _ _ _ = assistant (which "doc/qcalc.html"++A); - manual A _ _ _ = assistant (which "doc/qdoc.html"++A); - /* This flag is set iff we're processing events in the global loop. If it is unset, we're being invoked recursively through a local event loop, in which --- 606,609 ---- *************** *** 672,677 **** @1 ! /* Our last line of defence: Override qt_invoke to reject any "unsafe" ! callbacks (i.e., everything except abort) during evaluations. */ qt_invoke OBJ SLOT ARGS --- 633,640 ---- @1 ! /* Override qt_invoke to reject any "unsafe" callbacks (i.e., everything ! except abort) during evaluations. XXXFIXME: We should actually queue ! callbacks (and execute them later in the callback routine) if we're in a ! local event loop here. */ qt_invoke OBJ SLOT ARGS *************** *** 682,686 **** @0 ! /* Uncomment this for debugging purposes. (Qt/Q needs to be configured with -DDEBUG_INVOKE to make this work.) */ --- 645,649 ---- @0 ! /* Uncomment this for debugging purposes. (Qt/Q needs to be built with -DDEBUG_INVOKE to make this work.) */ *************** *** 706,711 **** = normal_cursor otherwise; - abort _ _ _ = ABORTED := true; - /* Queue GUI updates for later processing during evaluations. */ --- 669,672 ---- *************** *** 731,734 **** --- 692,737 ---- nub [X,Y|Xs] = [X|nub [Y|Xs]] otherwise; + /* Callbacks. */ + + abort _ _ _ = ABORTED := true; + + about _ _ _ if is_global: + = aboutbox $ sprintf + "<h1>QCalc - A Q spreadsheet</h1>\n\ + \n\ + <h2>QCalc %s (Q version %s, %s)</h2>\n\ + CVS version %s\n\ + \n\ + <p><big>%s</big></p>\n\ + \n\ + <p>This program is free software; you can redistribute it and/or modify\n\ + it under the terms of the GNU General Public License as published by\n\ + the Free Software Foundation; either version 2 of the License, or\n\ + (at your option) any later version.</p>\n\ + \n\ + <p>This program is distributed in the hope that it will be useful,\n\ + but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ + GNU General Public License for more details.</p>\n\ + \n\ + <p>You should have received a copy of the GNU General Public License\n\ + along with this program; if not, write to the Free Software\n\ + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</p>" + (VERSION,version,sysinfo,CVS_VERSION,COPYRIGHT); + + /* Qt Assistant interface */ + + /* KLUDGE: At least with Qt3 under X11, it seems to be necessary to give Qt + Assistant some time to start up before we tell it the page to show, + otherwise the wrong page (i.e., whatever page was shown most recently) is + displayed. */ + + assistant PAGE = qt_assistant "" || sleep 0.5 || qt APP "processEvents" () || + fail if not qt_assistant_is_open; + = qt_assistant PAGE; + + help A _ _ _ = assistant (which "doc/qcalc.html"++A) if is_global; + manual A _ _ _ = assistant (which "doc/qdoc.html"++A) if is_global; + /* Timer processing. */ *************** *** 956,960 **** // KLUDGE: Qt/Q cannot pass the QPoint parameter right now, so we read // QCursor::pos() instead. ! popup _ _ (I,J) = qt POPUP "exec" $ qt "QCursor" "pos" (); /* Manage table items. We derive our own QTableItems here, as we need to --- 959,963 ---- // KLUDGE: Qt/Q cannot pass the QPoint parameter right now, so we read // QCursor::pos() instead. ! popup _ _ (I,J) = qt POPUP "exec" $ qt "QCursor" "pos" () if is_global; /* Manage table items. We derive our own QTableItems here, as we need to *************** *** 1357,1365 **** def REPLS = ref 0; ! find _ _ _ if is_global: ! = find_dg || REPLS := 0 || find_clearmsg || show_editor; ! find_prev _ _ _ if is_global: ! = savestr FIND_TEXT S || find_statusmsg "Found previous occurrence" || set_status true FIND_REPL || qt FIND_PREV "setDefault" true --- 1360,1366 ---- def REPLS = ref 0; ! find _ _ _ = find_dg || REPLS := 0 || find_clearmsg || show_editor; ! find_prev _ _ _ = savestr FIND_TEXT S || find_statusmsg "Found previous occurrence" || set_status true FIND_REPL || qt FIND_PREV "setDefault" true *************** *** 1373,1378 **** otherwise; ! find_next _ _ _ if is_global: ! = savestr FIND_TEXT S || find_statusmsg "Found next occurrence" || set_status true FIND_REPL || qt FIND_NEXT "setDefault" true --- 1374,1378 ---- otherwise; ! find_next _ _ _ = savestr FIND_TEXT S || find_statusmsg "Found next occurrence" || set_status true FIND_REPL || qt FIND_NEXT "setDefault" true *************** *** 1391,1396 **** REPLS := 0 otherwise; ! find_repl X D A if is_global: ! = qt EDIT "insert" S || REPLS := get REPLS+1 || savestr REPL_TEXT S0 || (if qt FIND_NEXT "isDefault" () then find_next --- 1391,1395 ---- REPLS := 0 otherwise; ! find_repl X D A = qt EDIT "insert" S || REPLS := get REPLS+1 || savestr REPL_TEXT S0 || (if qt FIND_NEXT "isDefault" () then find_next *************** *** 1453,1467 **** /* Various editing operations. */ ! edit_undo _ _ _ if is_global: ! = undo || updatemsg current_cell where _ = check_editing ! if qt TABW "currentPageIndex" () = 0; = qt EDIT "undo" () if qt TABW "currentPageIndex" () = 1; ! edit_redo _ _ _ if is_global: ! = redo || updatemsg current_cell where _ = check_editing ! if qt TABW "currentPageIndex" () = 0; = qt EDIT "redo" () if qt TABW "currentPageIndex" () = 1; --- 1452,1464 ---- /* Various editing operations. */ ! edit_undo _ _ _ = undo || updatemsg current_cell where _ = check_editing ! if (qt TABW "currentPageIndex" () = 0) and then is_global; = qt EDIT "undo" () if qt TABW "currentPageIndex" () = 1; ! edit_redo _ _ _ = redo || updatemsg current_cell where _ = check_editing ! if (qt TABW "currentPageIndex" () = 0) and then is_global; = qt EDIT "redo" () if qt TABW "currentPageIndex" () = 1; *************** *** 1630,1635 **** = (I<N) and then (J<M); ! del _ _ _ if is_global: ! = EDITED := get EDITED or else not null CELLS || update_title || clear_sel CELLS || --- 1627,1631 ---- = (I<N) and then (J<M); ! del _ _ _ = EDITED := get EDITED or else not null CELLS || update_title || clear_sel CELLS || *************** *** 1638,1647 **** where SEL = check_editing || selection, CELLS = sel_cells SEL ! if qt TABW "currentPageIndex" () = 0; = qt EDIT "del" () if qt TABW "currentPageIndex" () = 1; ! cut _ _ _ if is_global: ! = EDITED := get EDITED or else not null CELLS || update_title || set_clipboard X S || clear_sel CELLS || --- 1634,1642 ---- where SEL = check_editing || selection, CELLS = sel_cells SEL ! if (qt TABW "currentPageIndex" () = 0) and then is_global; = qt EDIT "del" () if qt TABW "currentPageIndex" () = 1; ! cut _ _ _ = EDITED := get EDITED or else not null CELLS || update_title || set_clipboard X S || clear_sel CELLS || *************** *** 1651,1667 **** X = sel_cellvals SEL, S = sel_cellcvals SEL, CELLS = sel_cells SEL ! if qt TABW "currentPageIndex" () = 0; = qt EDIT "cut" () if qt TABW "currentPageIndex" () = 1; ! copy _ _ _ if is_global: ! = set_clipboard X S where SEL = check_editing || selection, X = sel_cellvals SEL, S = sel_cellcvals SEL ! if qt TABW "currentPageIndex" () = 0; = qt EDIT "copy" () if qt TABW "currentPageIndex" () = 1; ! copy_selection _ _ _ if is_global: = set_clipboard2 S where S = sel_cellcvals SEL --- 1646,1661 ---- X = sel_cellvals SEL, S = sel_cellcvals SEL, CELLS = sel_cells SEL ! if (qt TABW "currentPageIndex" () = 0) and then is_global; = qt EDIT "cut" () if qt TABW "currentPageIndex" () = 1; ! copy _ _ _ = set_clipboard X S where SEL = check_editing || selection, X = sel_cellvals SEL, S = sel_cellcvals SEL ! if (qt TABW "currentPageIndex" () = 0) and then is_global; = qt EDIT "copy" () if qt TABW "currentPageIndex" () = 1; ! copy_selection _ _ _ = set_clipboard2 S where S = sel_cellcvals SEL *************** *** 1669,1676 **** where SEL = check_editing || selection, (I0,J0;I1,J1;I2,J2) = SEL ! if qt TABW "currentPageIndex" () = 0; ! paste _ _ _ if is_global: ! = EDITED := get EDITED or else not null SEL || adjust_table (N,M) || update_title || process_sel SEL || --- 1663,1669 ---- where SEL = check_editing || selection, (I0,J0;I1,J1;I2,J2) = SEL ! if (qt TABW "currentPageIndex" () = 0) and then is_global; ! paste _ _ _ = EDITED := get EDITED or else not null SEL || adjust_table (N,M) || update_title || process_sel SEL || *************** *** 1686,1694 **** N = foldl max (MIN_ROWS-1) (map fst CELLS) + 1, M = foldl max (MIN_COLS-1) (map snd CELLS) + 1 ! if qt TABW "currentPageIndex" () = 0; = qt EDIT "paste" () if qt TABW "currentPageIndex" () = 1; ! paste_text _ _ _ if is_global: = EDITED := get EDITED or else not null SEL || update_title || process_sel SEL || --- 1679,1687 ---- N = foldl max (MIN_ROWS-1) (map fst CELLS) + 1, M = foldl max (MIN_COLS-1) (map snd CELLS) + 1 ! if (qt TABW "currentPageIndex" () = 0) and then is_global; = qt EDIT "paste" () if qt TABW "currentPageIndex" () = 1; ! paste_text _ _ _ = EDITED := get EDITED or else not null SEL || update_title || process_sel SEL || *************** *** 1702,1709 **** SEL = map (translate (DI,DJ)) SEL, CELLS = map (flip (flip sub 0) 1) SEL ! if qt TABW "currentPageIndex" () = 0; ! fill _ _ _ if is_global: ! = EDITED := true || update_title || process_sel $ tl $ cat $ fill_vals VALS || save_undo CELLS || --- 1695,1701 ---- SEL = map (translate (DI,DJ)) SEL, CELLS = map (flip (flip sub 0) 1) SEL ! if (qt TABW "currentPageIndex" () = 0) and then is_global; ! fill _ _ _ = EDITED := true || update_title || process_sel $ tl $ cat $ fill_vals VALS || save_undo CELLS || *************** *** 1715,1719 **** VALS = sel_cellvals SEL, CELLS = map (flip (flip sub 0) 1) $ cat VALS ! if qt TABW "currentPageIndex" () = 0; fill_vals SEL --- 1707,1711 ---- VALS = sel_cellvals SEL, CELLS = map (flip (flip sub 0) 1) $ cat VALS ! if (qt TABW "currentPageIndex" () = 0) and then is_global; fill_vals SEL *************** *** 1949,1953 **** (FONT,true) = font_dg FONT; ! enlarge_font _ _ _ if is_global: = statusmsg $ sprintf "New point size: %dpt" $ change_pointsize succ TABLE --- 1941,1945 ---- (FONT,true) = font_dg FONT; ! enlarge_font _ _ _ = statusmsg $ sprintf "New point size: %dpt" $ change_pointsize succ TABLE *************** *** 1958,1962 **** otherwise; ! reduce_font _ _ _ if is_global: = statusmsg $ sprintf "New point size: %dpt" $ change_pointsize pred TABLE --- 1950,1954 ---- otherwise; ! reduce_font _ _ _ = statusmsg $ sprintf "New point size: %dpt" $ change_pointsize pred TABLE *************** *** 1967,1976 **** otherwise; ! increase_prec _ _ _ if is_global: = FPREC := get FPREC+1 || FFORMAT := sprintf "%%0.%dg" (get FPREC) || do update_fformat $ list $ get CELLS; ! decrease_prec _ _ _ if is_global: = FPREC := get FPREC-1 || FFORMAT := sprintf "%%0.%dg" (get FPREC) || --- 1959,1968 ---- otherwise; ! increase_prec _ _ _ = FPREC := get FPREC+1 || FFORMAT := sprintf "%%0.%dg" (get FPREC) || do update_fformat $ list $ get CELLS; ! decrease_prec _ _ _ = FPREC := get FPREC-1 || FFORMAT := sprintf "%%0.%dg" (get FPREC) || *************** *** 2211,2215 **** OPT_CELLS = qt OPTIONS_CELLS "selectedId" (), FROM = qt PRT "fromPage" (), TO = qt PRT "toPage" () ! where ALL = selection_all, SEL = selection: = doprint PRT OPT_CONTENTS (FROM,TO) $ format_as_text OPT_CELLS (I1,J1;I2,J2) --- 2203,2208 ---- OPT_CELLS = qt OPTIONS_CELLS "selectedId" (), FROM = qt PRT "fromPage" (), TO = qt PRT "toPage" () ! where ALL = selection_all, SEL = selection ! if is_global: = doprint PRT OPT_CONTENTS (FROM,TO) $ format_as_text OPT_CELLS (I1,J1;I2,J2) *************** *** 2220,2224 **** where (_,_;I1,J1;I2,J2) = ALL; = doprint PRT OPT_CONTENTS (FROM,TO) ""; ! otherwise: = statusmsg "Print aborted"; --- 2213,2217 ---- where (_,_;I1,J1;I2,J2) = ALL; = doprint PRT OPT_CONTENTS (FROM,TO) ""; ! if is_global: = statusmsg "Print aborted"; |