Mercurial > octave-dspies
view examples/mysparse.c @ 18684:86eca5d178a6 gui-release
disable some global shortcuts when editor gets focus to prevent conflicts
* file-editor-tab.cc (constructor): connect signal from the qscintilla edit
area about focus with the related new slot;
(edit_area_has_focus): new slot for the focus signal from qscintilla edit
area emitting a signal for enabling/disabling the common edit shortcuts
* file-editor-tab.h: new slot edit_area_has_focus,
new signal set_global_edit_shortcuts_signal
* file-editor.cc (add_file_editor_tab ): connect new tab signal
set_global_edit_shortcuts_signal with the related slot in main_window;
(copyClipboard, pasteClipboard, selectAll): removed these functions because
the related actions are triggered editor shortcuts
* file-editor.h: remove copyClipboard, pasteClipboard, selectAll
* octave-qscintilla.cc (focusInEvent, focusOutEvent): handlers emitting the
signal about the focus state of the edit area
* octave-qscintilla.h: new focus signal qsci_has_focus_signal, focus event
handlers
* main-window.cc (set_global_edit_shortcuts): new slot dis-/enabling the common
edit shortcuts depending on focus of edit area
* main-window.h: new slot set_global_edit_shortcuts
author | Torsten <ttl@justmail.de> |
---|---|
date | Sun, 27 Apr 2014 13:03:08 +0200 |
parents | 4d7f95eb8bfe |
children | 9ac2357f19bc |
line wrap: on
line source
#include "mex.h" void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mwSize m, n, nz; mxArray *v; mwIndex i; double *pr, *pi; double *pr2, *pi2; mwIndex *ir, *jc; mwIndex *ir2, *jc2; if (nrhs != 1 || ! mxIsSparse (prhs[0])) mexErrMsgTxt ("ARG1 must be a sparse matrix"); m = mxGetM (prhs[0]); n = mxGetN (prhs[0]); nz = mxGetNzmax (prhs[0]); if (mxIsComplex (prhs[0])) { mexPrintf ("Matrix is %d-by-%d complex sparse matrix", m, n); mexPrintf (" with %d elements\n", nz); pr = mxGetPr (prhs[0]); pi = mxGetPi (prhs[0]); ir = mxGetIr (prhs[0]); jc = mxGetJc (prhs[0]); i = n; while (jc[i] == jc[i-1] && i != 0) i--; mexPrintf ("last non-zero element (%d, %d) = (%g, %g)\n", ir[nz-1]+ 1, i, pr[nz-1], pi[nz-1]); v = mxCreateSparse (m, n, nz, mxCOMPLEX); pr2 = mxGetPr (v); pi2 = mxGetPi (v); ir2 = mxGetIr (v); jc2 = mxGetJc (v); for (i = 0; i < nz; i++) { pr2[i] = 2 * pr[i]; pi2[i] = 2 * pi[i]; ir2[i] = ir[i]; } for (i = 0; i < n + 1; i++) jc2[i] = jc[i]; if (nlhs > 0) plhs[0] = v; } else if (mxIsLogical (prhs[0])) { mxLogical *pbr, *pbr2; mexPrintf ("Matrix is %d-by-%d logical sparse matrix", m, n); mexPrintf (" with %d elements\n", nz); pbr = mxGetLogicals (prhs[0]); ir = mxGetIr (prhs[0]); jc = mxGetJc (prhs[0]); i = n; while (jc[i] == jc[i-1] && i != 0) i--; mexPrintf ("last non-zero element (%d, %d) = %d\n", ir[nz-1]+ 1, i, pbr[nz-1]); v = mxCreateSparseLogicalMatrix (m, n, nz); pbr2 = mxGetLogicals (v); ir2 = mxGetIr (v); jc2 = mxGetJc (v); for (i = 0; i < nz; i++) { pbr2[i] = pbr[i]; ir2[i] = ir[i]; } for (i = 0; i < n + 1; i++) jc2[i] = jc[i]; if (nlhs > 0) plhs[0] = v; } else { mexPrintf ("Matrix is %d-by-%d real sparse matrix", m, n); mexPrintf (" with %d elements\n", nz); pr = mxGetPr (prhs[0]); ir = mxGetIr (prhs[0]); jc = mxGetJc (prhs[0]); i = n; while (jc[i] == jc[i-1] && i != 0) i--; mexPrintf ("last non-zero element (%d, %d) = %g\n", ir[nz-1]+ 1, i, pr[nz-1]); v = mxCreateSparse (m, n, nz, mxREAL); pr2 = mxGetPr (v); ir2 = mxGetIr (v); jc2 = mxGetJc (v); for (i = 0; i < nz; i++) { pr2[i] = 2 * pr[i]; ir2[i] = ir[i]; } for (i = 0; i < n + 1; i++) jc2[i] = jc[i]; if (nlhs > 0) plhs[0] = v; } }