/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/ /* */ /* P†l Hedne 1990 */ /* */ /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/ extern latex_help; extern MathKeys, NonMathKeys, DefMathKeys; extern TexKeys, NormKeys; extern math_key,tabbing_key,tabular_key,thebib_key; extern keyboard; /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* ; */ /* ; */ /* ; */ /* ; */ /* ; */ /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ _init (...) { assign_to_key ("", "latex"); message ("Ctrl-F1 aktiverer Latex macro Ver.PH/1.2"); } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* ; */ /* ; */ /* ; */ /* ; */ /* ; */ /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ latex (...) { int ikey, on_off, NorModus, MathModus; string command; global NorModus, on_off, MathModus; if (!on_off) { on_off = 1; /* if (!inq_macro("latex"))*/ load_macro ("latex"); /* error ("Latex loaded.");*/ /* if (!inq_macro("embrace"))*/ load_macro ("embrace"); /* error ("Embrace loaded.");*/ /* if (!inq_macro("latexmat"))*/ load_macro ("latexmat"); /* error ("Latexmat loaded.");*/ /* if (!inq_macro("gresk"))*/ load_macro ("gresk"); /* error ("Gresk loaded.");*/ autoload ("label","find_label"); /* error ("Flabel loaded.");*/ autoload ("gmatch","find_match"); /* error ("Gmatch loaded.");*/ autoload ("latexh","latex_help","gen_help"); /* error ("Latexh loaded.");*/ autoload ("norsk","nor_to_tex","tex_to_nor","NormKeys","TexKeys"); /* error ("Norsk loaded.");*/ autoload ("remmer","split_tex","join_tex"); /* error ("Remmer loaded.");*/ assign_to_key ("", "ToggleNor"); assign_to_key ("", "nor_to_tex"); assign_to_key ("", "tex_to_nor"); assign_to_key ("", "find_match"); assign_to_key ("", "disp_match"); assign_to_key ("", "ToggleMath"); assign_to_key ("", "find_label"); assign_to_key ("", "disp_label"); assign_to_key ("", "split_tex"); assign_to_key ("", "join_tex"); assign_to_key ("$", "dollar"); assign_to_key ("", "array"); assign_to_key ("", "begin_array"); assign_to_key ("", "begin_thebibliography"); assign_to_key ("", "begin_displaymath"); assign_to_key ("", "begin_figure"); assign_to_key ("", "begin_itemize"); assign_to_key ("", "begin_enumerate"); assign_to_key ("", "begin_description"); assign_to_key ("", "begin_math"); assign_to_key ("", "begin_tabbing"); assign_to_key ("

", "end_minipage"); assign_to_key ("", "end_equation"); assign_to_key ("", "end_tabular"); assign_to_key ("", "end_document"); assign_to_key ("", "end_eqnarray"); assign_to_key ("", "figure"); assign_to_key ("", "grad"); assign_to_key ("", "latex_help"); assign_to_key ("", "itemize"); assign_to_key ("", "enumerate"); assign_to_key ("", "description"); assign_to_key ("", "description"); assign_to_key ("", "footnote"); assign_to_key ("", "caption"); assign_to_key ("", "label"); assign_to_key ("", "math"); assign_to_key ("", "tabbing"); assign_to_key ("", "table"); /* ctrl-p = pop_up_error !! */ assign_to_key ("", "equation"); assign_to_key ("", "ref"); assign_to_key ("", "chapter"); assign_to_key ("", "section"); assign_to_key ("", "subsection"); assign_to_key ("", "tabular"); assign_to_key ("", "bold"); assign_to_key ("", "caps"); assign_to_key ("", "emphasize"); assign_to_key ("", "italic"); assign_to_key ("", "overline"); assign_to_key ("", "roman"); assign_to_key ("", "sansserif"); assign_to_key ("", "typewriter"); assign_to_key ("", "underline"); assign_to_key ("", "minipage"); assign_to_key ("", "document"); assign_to_key ("", "mbox"); assign_to_key ("", "eqnarray"); NorModus = 0; MathModus = 0; assign_to_key ("", "r_indent"); message ("Latex template installed.Press Ctrl-h for help."); } else { on_off = 0; if (inq_macro("latex")) {delete_macro ("latex"); /* error ("Latex removed.");*/ } if (inq_macro("embrace")) {delete_macro ("embrace"); /* error ("Embrace removed.");*/ } if (inq_macro("latexmat")) {delete_macro ("latexmat"); /* error ("Latexmat removed.");*/ } if (inq_macro("gresk")) {delete_macro ("gresk"); /* error ("Gresk removed.");*/ } if (inq_macro("label")) {delete_macro ("label"); /* error ("Label removed.");*/ } if (inq_macro("gmatch")) {delete_macro ("gmatch"); /* error ("Gmatch removed.");*/ } if (inq_macro("latexh")) {delete_macro ("latexh"); /* error ("Latexh removed.");*/ } if (inq_macro("norsk")) {delete_macro ("norsk"); /* error ("Norsk removed.");*/ } if (inq_macro("remmer")) {delete_macro ("remmer"); /* error ("Remmer removed.");*/ } message ("Latex template removed."); keyboard(); } } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* ; */ /* ; */ /* EMBRACE ; */ /* ; */ /* ; */ /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ embrace (...) { int line, col, mtype, sw; int mline1, mcol1, mlinex, mcolx; string command; get_parm (0, command); get_parm (1, sw); inq_position (line, col); command = lower (command); if (sw == -1) command = "{" + ("\\" + (command + " ")); else if (sw == 1) command = command + "{"; else command = "\\" + (command + "{"); if (command == "\\cite{") command = "~" + command; if (command == "\\ref{") command = "~" + command; mtype = inq_marked (mline1, mcol1, mlinex, mcolx); if (mtype > 0) { move_abs (mline1, mcol1); insert (command); move_abs (mline1, mcol1); swap_anchor (); move_abs (mlinex, mcolx + 1); if (mline1 == line) move_abs (mlinex, (mcolx + strlen (command)) + 1); insert ("}"); inq_position (line, col); move_abs (line, col - 1); } else { command = command + "}"; insert (command); move_rel (0, -1); } } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* */ /* PUT COMMAND */ /* */ /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ begin_command (...) { int line, col, ins; string command; if (get_parm (0, command)) { ins = insert_mode (1); inq_position (line, col); move_rel (0, 1 - col); insert ("\\begin{" + (command + "}\n")); move_abs (line + 1, col + 4); insert_mode (ins); } } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* ; */ /* PUT COMMAND ; */ /* ; */ /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ end_command (...) { int line, col, ins; string command; if (get_parm (0, command)) { ins = insert_mode (1); inq_position (line, col); move_rel (0, 1 - col); insert ("\\end{" + (command + "}\n")); move_abs (line + 1, col); insert_mode (ins); } } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ /* ; */ /* ; */ /* ; */ /* ; */ /* ; */ /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ put_commands (...) { int i, line, col, mtype; int j, ins; int mline1, mcol1, mlinex, mcolx; string text, CR, command, ins_text; get_parm (0, command); command = lower (command); ins_text = " "; if (command == "itemize") ins_text = " \\item "; if (command == "enumerate") ins_text = " \\item "; sprintf (CR, "%c", 13); inq_position (line, col); mtype = inq_marked (mline1, mcol1, mlinex, mcolx); ins = insert_mode (1); if (mtype > 0) { move_abs (mline1, mcol1); insert ("\\begin{" + (command + "}\n")); move_abs (mline1, mcol1); swap_anchor (); i = mline1; while (i < mlinex) { ++i; move_abs (i, mcol1); if (i == mline1 + 1 && mcol1 > 1) { j = 1; move_abs (i, 1); while (j < mcol1) { insert (" "); ++j; } } insert (ins_text); } move_abs (mlinex + 1, mcol1); text = read (); if (text != CR) { move_abs (mlinex + 1, mcol1); insert (ins_text); move_abs (mlinex + 2, 1); if (mcol1 > 1) { j = 1; while (j <= mcol1) { insert (" "); ++j; } } } else move_abs (mlinex + 1, mcol1); insert ("\\end{" + (command + "}\n")); move_abs (line + 2, 1); end_of_line (); } else { insert ("\\begin{" + (command + "}\n\n")); move_rel (0, col-1); insert ("\\end{" + (command + "}")); move_abs (line + 1, col + 4); } insert_mode (ins); } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ ToggleNor (...) { if (NorModus == 1) { message ("Norsk tegnsett p†"); NormKeys (); NorModus = 0; } else { message ("Norsk tegnsett av"); TexKeys (); NorModus = 1; } } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ ToggleMath (...) { int ipar; if (get_parm (0, ipar)) MathModus=ipar; else { if (MathModus == 0) MathModus=1; else MathModus=0; } if (MathModus == 0) { NonMathKeys (); message ("Math modus off"); } else { MathKeys (); message ("Math modus on"); } } /* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */ dollar (...) { insert("$"); ToggleMath(); }

", "begin_minipage"); assign_to_key ("", "begin_equation"); assign_to_key ("", "begin_tabular"); assign_to_key ("", "begin_document"); assign_to_key ("", "begin_eqnarray"); assign_to_key ("", "cite"); assign_to_key ("", "displaymath"); assign_to_key ("", "end_array"); assign_to_key ("", "end_thebibliography"); assign_to_key ("", "end_displaymath"); assign_to_key ("", "end_figure"); assign_to_key ("", "end_itemize"); assign_to_key ("", "end_enumerate"); assign_to_key ("", "end_description"); assign_to_key ("", "end_tabbing"); assign_to_key ("", "end_math"); assign_to_key ("