view libinterp/corefcn/txt-eng.cc @ 17289:bc924baa2c4e

doc: Add new @qcode macro for code samples which are quoted. Macro handles options ("on") or properties ("position") more elegantly than @code{"text"}. * doc/interpreter/macros.texi: Add new @qcode macro. * doc/interpreter/tips.txi: Add documentation about @qcode macro. * doc/interpreter/basics.txi, doc/interpreter/container.txi, doc/interpreter/emacs.txi, doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi, doc/interpreter/external.txi, doc/interpreter/func.txi, doc/interpreter/grammar.txi, doc/interpreter/image.txi, doc/interpreter/install.txi, doc/interpreter/interp.txi, doc/interpreter/io.txi, doc/interpreter/matrix.txi, doc/interpreter/numbers.txi, doc/interpreter/oop.txi, doc/interpreter/package.txi, doc/interpreter/plot.txi, doc/interpreter/quad.txi, doc/interpreter/sparse.txi, doc/interpreter/strings.txi, doc/interpreter/system.txi, doc/interpreter/vectorize.txi, libinterp/corefcn/balance.cc, libinterp/corefcn/bitfcns.cc, libinterp/corefcn/cellfun.cc, libinterp/corefcn/conv2.cc, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc, libinterp/corefcn/dirfns.cc, libinterp/corefcn/dlmread.cc, libinterp/corefcn/error.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/help.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc, libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/pager.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc, libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc, libinterp/corefcn/str2double.cc, libinterp/corefcn/svd.cc, libinterp/corefcn/symtab.cc, libinterp/corefcn/syscalls.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/tril.cc, libinterp/corefcn/typecast.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-mat.cc, scripts/@ftp/ftp.m, scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m, scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/shell_cmd.m, scripts/general/dblquad.m, scripts/general/display.m, scripts/general/genvarname.m, scripts/general/idivide.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/interpn.m, scripts/general/isa.m, scripts/general/profexplore.m, scripts/general/profile.m, scripts/general/quadgk.m, scripts/general/randi.m, scripts/general/structfun.m, scripts/general/subsindex.m, scripts/general/triplequad.m, scripts/geometry/griddata.m, scripts/geometry/griddata3.m, scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/help/help.m, scripts/help/lookfor.m, scripts/image/cmpermute.m, scripts/image/colormap.m, scripts/image/image.m, scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m, scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m, scripts/image/ind2gray.m, scripts/image/lines.m, scripts/image/rgb2ind.m, scripts/image/spinmap.m, scripts/io/dlmwrite.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/java/javaclasspath.m, scripts/java/usejava.m, scripts/miscellaneous/bzip2.m, scripts/miscellaneous/computer.m, scripts/miscellaneous/copyfile.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/gzip.m, scripts/miscellaneous/license.m, scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/movefile.m, scripts/miscellaneous/parseparams.m, scripts/miscellaneous/unix.m, scripts/optimization/fminbnd.m, scripts/optimization/fminsearch.m, scripts/optimization/fminunc.m, scripts/optimization/fsolve.m, scripts/optimization/fzero.m, scripts/optimization/glpk.m, scripts/optimization/lsqnonneg.m, scripts/optimization/optimset.m, scripts/optimization/pqpnonneg.m, scripts/pkg/pkg.m, scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m, scripts/plot/axis.m, scripts/plot/bar.m, scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m, scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m, scripts/plot/close.m, scripts/plot/colorbar.m, scripts/plot/daspect.m, scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezsurf.m, scripts/plot/ezsurfc.m, scripts/plot/findall.m, scripts/plot/findobj.m, scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m, scripts/plot/grid.m, scripts/plot/guihandles.m, scripts/plot/hdl2struct.m, scripts/plot/hidden.m, scripts/plot/hold.m, scripts/plot/isonormals.m, scripts/plot/isosurface.m, scripts/plot/legend.m, scripts/plot/mesh.m, scripts/plot/meshc.m, scripts/plot/meshz.m, scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m, scripts/plot/patch.m, scripts/plot/pbaspect.m, scripts/plot/pcolor.m, scripts/plot/plot.m, scripts/plot/print.m, scripts/plot/private/__add_default_menu__.m, scripts/plot/quiver.m, scripts/plot/quiver3.m, scripts/plot/refreshdata.m, scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m, scripts/plot/shading.m, scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/stem.m, scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m, scripts/plot/surf.m, scripts/plot/surfc.m, scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/uigetfile.m, scripts/plot/uimenu.m, scripts/plot/uiputfile.m, scripts/plot/waterfall.m, scripts/plot/whitebg.m, scripts/plot/xlim.m, scripts/plot/ylim.m, scripts/plot/zlim.m, scripts/polynomial/conv.m, scripts/polynomial/polyout.m, scripts/polynomial/splinefit.m, scripts/set/ismember.m, scripts/set/powerset.m, scripts/set/setdiff.m, scripts/set/union.m, scripts/set/unique.m, scripts/signal/detrend.m, scripts/signal/filter2.m, scripts/signal/freqz.m, scripts/signal/periodogram.m, scripts/signal/spectral_adf.m, scripts/signal/spectral_xdf.m, scripts/sparse/eigs.m, scripts/sparse/svds.m, scripts/specfun/legendre.m, scripts/special-matrix/gallery.m, scripts/statistics/base/mean.m, scripts/statistics/base/moment.m, scripts/statistics/tests/cor_test.m, scripts/statistics/tests/kolmogorov_smirnov_test.m, scripts/statistics/tests/kolmogorov_smirnov_test_2.m, scripts/statistics/tests/kruskal_wallis_test.m, scripts/statistics/tests/prop_test_2.m, scripts/statistics/tests/sign_test.m, scripts/statistics/tests/t_test.m, scripts/statistics/tests/t_test_2.m, scripts/statistics/tests/t_test_regression.m, scripts/statistics/tests/u_test.m, scripts/statistics/tests/var_test.m, scripts/statistics/tests/welch_test.m, scripts/statistics/tests/wilcoxon_test.m, scripts/statistics/tests/z_test.m, scripts/statistics/tests/z_test_2.m, scripts/strings/base2dec.m, scripts/strings/index.m, scripts/strings/isstrprop.m, scripts/strings/mat2str.m, scripts/strings/regexptranslate.m, scripts/strings/rindex.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strjust.m, scripts/strings/strmatch.m, scripts/strings/validatestring.m, scripts/testfun/demo.m, scripts/testfun/example.m, scripts/testfun/test.m, scripts/time/addtodate.m, scripts/time/asctime.m, scripts/time/datestr.m, scripts/time/datetick.m, scripts/time/weekday.m, scripts/ui/errordlg.m, scripts/ui/helpdlg.m, scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/msgbox.m, scripts/ui/questdlg.m, scripts/ui/warndlg.m: Use new @qcode macro.
author Rik <rik@octave.org>
date Mon, 19 Aug 2013 20:46:38 -0700
parents 8ce6cdd272eb
children ea23eb07f8ed
line wrap: on
line source

/*

Copyright (C) 2013 Michael Goffioul

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
<http://www.gnu.org/licenses/>.

*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "txt-eng.h"

static const char* symbol_names[] = {
    "alpha",
    "beta",
    "gamma",
    "delta",
    "epsilon",
    "zeta",
    "eta",
    "theta",
    "vartheta",
    "iota",
    "kappa",
    "lambda",
    "mu",
    "nu",
    "xi",
    "pi",
    "rho",
    "sigma",
    "varsigma",
    "tau",
    "equiv",
    "Im",
    "otimes",
    "cap",
    "supset",
    "int",
    "rfloor",
    "lfloor",
    "perp",
    "wedge",
    "rceil",
    "vee",
    "langle",

    "upsilon",
    "phi",
    "chi",
    "psi",
    "omega",
    "Gamma",
    "Delta",
    "Theta",
    "Lambda",
    "Xi",
    "Pi",
    "Sigma",
    "Upsilon",
    "Phi",
    "Psi",
    "Omega",
    "forall",
    "exists",
    "ni",
    "cong",
    "approx",
    "Re",
    "oplus",
    "cup",
    "subseteq",
    "in",
    "lceil",
    "cdot",
    "neg",
    "times",
    "surd",
    "varpi",
    "rangle",

    "leq",
    "infty",
    "clubsuit",
    "diamondsuit",
    "heartsuit",
    "spadesuit",
    "leftrightarrow",
    "leftarrow",
    "uparrow",
    "rightarrow",
    "downarrow",
    "circ",
    "pm",
    "geq",
    "propto",
    "partial",
    "bullet",
    "div",
    "neq",
    "aleph",
    "wp",
    "oslash",
    "supseteq",
    "subset",
    "o",
    "nabla",
    "ldots",
    "prime",
    "0",
    "mid",
    "copyright",

    0
};

// Maps the symbol names (using index from symbol_names array) to
// character codes, using 2 mapping:
// - Unicode
// - MS symbol (using Private Use Area)
static uint32_t symbol_codes[][2] = {
      { 0x03B1, 0xF061 },		// alpha
      { 0x03B2, 0xF062 },		// beta
      { 0x03B3, 0xF067 },		// gamma
      { 0x03B4, 0xF064 },		// delta
      { 0x03B5, 0xF065 },		// epsilon
      { 0x03B6, 0xF07A },		// zeta
      { 0x03B7, 0xF068 },		// eta
      { 0x03B8, 0xF071 },		// theta
      { 0x03D1, 0xF04A },		// vartheta
      { 0x03B9, 0xF069 },		// iota
      { 0x03BA, 0xF06B },		// kappa
      { 0x03BB, 0xF06C },		// lambda
      { 0x03BC, 0xF06D },		// mu
      { 0x03BD, 0xF06E },		// nu
      { 0x03BE, 0xF078 },		// xi
      { 0x03C0, 0xF070 },		// pi
      { 0x03C1, 0xF072 },		// rho
      { 0x03C3, 0xF073 },		// sigma
      { 0x03C2, 0xF056 },		// varsigma
      { 0x03C4, 0xF074 },		// tau
      { 0x2261, 0xF0BA },		// equiv
      { 0x2111, 0xF0C1 },		// Im
      { 0x2297, 0xF0C4 },		// otimes
      { 0x2229, 0xF0C7 },		// cap
      { 0x2283, 0xF0C9 },		// supset
      { 0x222B, 0xF0F2 },		// int
      { 0x230B, 0xF0FB },		// rfloor
      { 0x230A, 0xF0EB },		// lfloor
      { 0x22A5, 0xF05E },		// perp
      { 0x2227, 0xF0D9 },		// wedge
      { 0x2309, 0xF0F9 },		// rceil
      { 0x2228, 0xF0DA },		// vee
      { 0x2220, 0xF0E1 },		// langle

      { 0x03C5, 0xF075 },		// upsilon
      { 0x03C6, 0xF066 },		// phi
      { 0x03C7, 0xF063 },		// chi
      { 0x03C8, 0xF079 },		// psi
      { 0x03C9, 0xF077 },		// omega
      { 0x0393, 0xF047 },		// Gamma
      { 0x0394, 0xF044 },		// Delta
      { 0x0398, 0xF051 },		// Theta
      { 0x039B, 0xF04C },		// Lambda
      { 0x039E, 0xF058 },		// Xi
      { 0x03A0, 0xF050 },		// Pi
      { 0x03A3, 0xF053 },		// Sigma
      { 0x03D2, 0xF055 },		// Upsilon
      { 0x03A6, 0xF046 },		// Phi
      { 0x03A8, 0xF059 },		// Psi
      { 0x03A9, 0xF057 },		// Omega
      { 0x2200, 0xF022 },		// forall
      { 0x2203, 0xF024 },		// exists
      { 0x220B, 0xF027 },		// ni
      { 0x2245, 0xF040 },		// cong
      { 0x2248, 0xF0BB },		// approx
      { 0x211C, 0xF0C2 },		// Re
      { 0x2295, 0xF0C5 },		// oplus
      { 0x222A, 0xF0C8 },		// cup
      { 0x2286, 0xF0CD },		// subseteq
      { 0x2208, 0xF0CE },		// in
      { 0x2308, 0xF0E9 },		// lceil
      { 0x22C5, 0xF0D7 },		// cdot
      { 0x00AC, 0xF0D8 },		// neg
      { 0x00D7, 0xF0B4 },		// times
      { 0x221A, 0xF0D6 },		// surd
      { 0x03D6, 0xF076 },		// varpi
      { 0x232A, 0xF0F1 },		// rangle

      { 0x2264, 0xF0A3 },		// leq
      { 0x221E, 0xF0A5 },		// infty
      { 0x2663, 0xF0A7 },		// clubsuit
      { 0x2666, 0xF0A8 },		// diamondsuit
      { 0x2665, 0xF0A9 },		// heartsuit
      { 0x2660, 0xF0AA },		// spadesuit
      { 0x2194, 0xF0AB },		// leftrightarrow
      { 0x2190, 0xF0AC },		// leftarrow
      { 0x2191, 0xF0AD },		// uparrow
      { 0x2192, 0xF0AE },		// rightarrow
      { 0x2193, 0xF0AF },		// downarrow
      { 0x25CB, 0xF0B0 },		// circ
      { 0x00B1, 0xF0B1 },		// pm
      { 0x2265, 0xF0B3 },		// geq
      { 0x221D, 0xF0B5 },		// propto
      { 0x2202, 0xF0B6 },		// partial
      { 0x2022, 0xF0B7 },		// bullet
      { 0x00F7, 0xF0B8 },		// div
      { 0x2260, 0xF0B9 },		// neq
      { 0x2135, 0xF0C0 },		// aleph
      { 0x2118, 0xF0C3 },		// wp
      { 0x2298, 0xF0C6 },		// oslash
      { 0x2287, 0xF0CA },		// supseteq
      { 0x2282, 0xF0CC },		// subset
      { 0x03BF, 0xF0B0 },		// o
      { 0x2207, 0xF0D1 },		// nabla
      { 0x2026, 0xF0BC },		// ldots
      { 0x2032, 0xF0A2 },		// prime
      { 0x2205, 0xF0C6 },		// 0
      { 0x2223, 0xF0BD },		// mid
      { 0x00A9, 0xF0E3 },		// copyright

      { 0, 0 }
};

uint32_t
text_element_symbol::get_symbol_code (void)
{
  if (code == invalid_code)
    {
      std::string sym = string_value ();

      for (int i = 0; symbol_names[i]; i++)
        {
          if (symbol_names[i] == sym)
            {
              code = symbol_codes[i][0];
              break;
            }
        }
    }

  return code;
}