home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-09-07 | 73.4 KB | 2,143 lines |
- /**************************************************************************/
- /* */
- /* What's it called: EPM TeX Front End (texfe.e) */
- /* */
- /* */
- /* What does it do: The E source code for the EPM TeX Front End */
- /* */
- /* Who and When: Originally written as 'EPMTeX' by John Hacker, */
- /* Rodney Korte, Thorsten Domsalla and Joachim Koenen, */
- /* 1/1993-10/1995; */
- /* this version by Walter Schmidt, 9/1998, */
- /* with contributions by Wonkoo Kim. */
- /* */
- /**************************************************************************/
-
- /*
-
- Version 2.2
-
- * Default value of LATEX_SYNTAX_INDENT is now 2
-
- * Improved syntax assist: Arguments of environments may appear on
- the same line. Arbitrary long environment names are recognized.
- Reasonable handling of the "verbatim" and "macrocode" environments.
- (See file texfek.e)
-
- * Optimized code for processing the EPMTeX accelerator keys; approx.
- 1kB smaller than the previous version. (See file texfed.e)
-
-
- Version 2.1
-
- * tex_file_in_ring() rewritten; files differing in path only
- should now be handled properly.
-
- * Call 'TeXMenuEnable' once more, because the TeX menu would be
- enabled erroneously under certain circumstances. There is, however,
- no complete solution to this problem.
-
- * Fixed the menu item "Menu always on', which would not display its
- current setting.
-
-
- Version 2.0
-
- * The TeX menu is now provided with the module, too.
-
- * The default format can be changed via the settings menu; manual
- format select is no longer provided.
-
- * Removed the menu item "Delete log file".
-
- * Bug fix: Customized <enter> key would not be honored
-
- * Bug fix: \end{...} would not be properly indented
-
- * New optional feature: Simple automatic indentation within LaTeX
- environmemts, controlled by const LATEX_SYNTAX_INDENT.
-
- * Syntax assist (expansion): \fo -> \footnote{}
-
- * "Menu always on" can be toggled via the TeX menu only.
-
- * const EXTENDED_LATEX_ASSIST = 1 will include Juan J.G.Ripoll's
- LaTeX auto-indentation package.
-
- * strip leading and trailing spaces from settings values which are
- entered interactively
-
-
- Version 1.1
-
- * Bug fix: Menu item "Master file support" was broken. (Only vith
- v1.1 as of 1998-01-07.)
-
- * Added "Cancel" buttons to options entry box and to "process
- marked region" dialog box.
-
- * TeXing a marked region is now possible with plain TeX, too. The
- end of the header is indicated by "%**end of header"
-
- * "Locate Next Error" and "View Log File" will always refer to the
- log file of the *latest* TeX run. The name of the log file is
- memorized from one EPM invocation to the next and will be displayed
- while definit.
-
- * "Locate Next Error" will again draw a circle around the location
- of the error. I have found a reliable (!) method to do so.
-
- * "Locate next error" will at least display the name of the TeX
- input file an error message refers to, if line number of error is
- not indicated in the transcript file.
-
- * "View Log File" will reset the error browsing facility when called
- from within the log file.
-
- * rewrote tex_more_errors(), the old one was too obscure ...
-
- * fixed a bug which caused the first line of the log file to be
- displayed instead of the recently found error, if the Log action was
- triggered after the last error in the file had been processed.
-
- * The TeX command connected with a certain format can now be an exe
- file, too.
-
- * Syntax highlighting is checked while defload; file types DTX and
- FDD are never highlighted.
-
- * *Each* occurence of %**N or %**F in the external commands will now
- be replaced with the filename.
-
- * Syntax assist: Fixed a bug which prevented the description
- environment from being recognized (file texfek.e).
-
- * Syntax assist (expansion):
- New : \la -> \label{}, \re -> \ref{}
- Removed: \hs -> \hspace{}, \vs -> \vspace{}
-
- * Preview, user commands etc. will no longer change into master
- file. However, they cannot be executed, if master file does not
- exist, regardless of the associated file type.
-
- * In case an external command is undefined, the corresponding menu
- item or toolbar button will display an appropriate error message.
-
- * Replaced various error messages with pop-up windows for better
- information.
-
- * Pro version: "Shell" and "Folder" added to the "Command" and
- "File" submenus, instead of creating an "OS/2" submenu. Applies
- only if STD_MENU_NAME is undefined, i.e. the standard menu is used.
-
- * Code optimization; no more unnecessary directory switching etc.
-
- * Many changes to the messages in texfeen.e
-
- * German version
-
- * rewrote the settings menu due to NLS support
-
-
- Version 1.0
-
- * TeX a marked region of the current file
-
- * Various changes to tex_extract_filename and tex_find_errors.
- Should now handle *all* TeX error messages! If location of error
- cannot be determined, the log file will be displayed.
-
- * "View LOG File" now goes to the line of the last error which has
- been located before; the parsing routines will only be initialized,
- if there are no more errors or the log file is not found in the
- ring.
-
- * The log file being viewed is read-only.
-
- * Fixed one more error affecting handling of filenames without
- extension, in the procedure tex_file_in_ring.
-
- * Removed defc tex_warning
-
- * In case a specified master file does not exist, the current action
- will be stopped without querying "Continue processing ... ?".
-
- * Fixed the TeX/PS action, which used to fail with file types other
- than '.TEX'.
-
- * The name of the dvips executable will be determined from the INI
- file. The default is 'dvips', as before.
-
- * The debug level is no longer saved in the INI file. Each EPM
- session will start with TeX_debug = 0 .
-
-
- Version 0.96
-
- * File types, highlighting etc. are configured via a menu. The
- EPM commands introduced with v0.92 have been removed.
-
- * The procedure tex_locate_error will no longer run into an endless
- loop , if the TeX error does not refer to a line number, e.g. with
- "runaway argument". Furthermore, it will move the cursor only; no
- mark will be set.
-
- * Changes to the syntax assist facility: Completion of environments
- and keywords will always be active with TeX documents/styles. The
- new command tex_keys will toggle the behaviour of the accelerator
- keys only. The command tex_syntaxassist has been abandoned.
- New expansion: "\fr " -> "\frac{}{}"
- Removed: "\it " -> "\item "
-
- * Restored the "Quick Keys":
- TeX : Ctrl F9
- TeX/PS : Ctrl F10
- locate next error : Ctlr F11
- view log file : Ctrl F12
- This was the only way to get the same sequence as in the toolbar, so
- it is necessarily different from EPMTeX's key assignments.
-
- * Restored the EPMTeX accelerator keys
-
-
- Changes from epmtex 3.1a to TeX Front End 0.92 (the first public
- version):
-
- Toolbar:
-
- * The standard version has no pull-down menus any more. Instead it
- is controlled via the toolbar. This is because the menu identifiers
- from different modules may collide. With the Pro version one has
- the source code available and can ensure unique menu identifiers.
-
- Files:
-
- * TeX documents are no longer required to have the extension .TEX
-
- * Since TeXing is no longer restricted to .TEX files, there are now
- three different lists of 'file extensions to associate with TeX':
- One for TeX documents, another one for style files, and a third one
- for auxiliary files. The syntax assist is available with the
- documents and the style files, and the auxiliary files are those
- which provide syntax highlighting and the quick keys, too. The TeX
- menu of the Pro version is enabled with file types from any list.
-
- Formats:
-
- * The default format is 'latex', unless there is a different
- specification in the configuration file.
-
- * Each format is called through its own batch file, so that the TeX
- options and the environment settings can be specified individually.
-
- Configuration, external programs:
-
- * The master file support is now toggled via the menu resp. the
- toolbar.
-
- * The program epmtex.exe has disappeared. Instead, some of the
- settings are controlled via EPM commands; others are defined in a
- text file TFE.CFG and transferred to EPM.INI by a configuration
- script named TFCONFIG.CMD, which is *not* run from within the EPM.
- The entries in the configuration file specify EPM commands, so that
- one can run external programs (start /n program), EPM REXX programs
- (rx program) or built-in EPM commands (sayerror ...).
-
- * Options may be passed interactively to external programs; see the
- documentation. Thus e.g. the printer driver can now be told to
- process a certain range of pages only.
-
- * The passing of the filename to an external command has been
- changed: Within the "executable file name" (i.e. the command
- line) the following substitutions will occur:
-
- %**N -> the filename without extension
- %**F -> the filename incl. extension
-
- This syntax is similar to the WPS, and it should cover all possible
- calling schemes of external programs. In case none of the above
- strings is present, the filename will *not* be passed to the
- program.
-
- New features:
-
- * The commands for previewimg, printing, dvips and the user commands
- will switch to the master file before running.
-
- * New menu items resp. toolbar buttons: "Folder" opens the
- directory of the current file as a WPS folder. "Command Prompt"
- creates an OS/2 shell window in the directory of the current file.
-
- * New menu items for dvips and Postscript viewing (Ghostview) have
- been added. (In case your *printer* supports Postscript, then you
- just have to specify dvips to be used as the printer driver, too.)
-
- * There is a new menu item named TeX/PS. It will run TeX and dvips
- in sequence, so that you need not call dvips explicitly. This is
- useful if you know that you will have to preview your document via
- Postscript, because it contains Type 1 fonts or other Postscript
- material.
-
- * The syntax assist facility will recognize more expansions:
- "equ " -> "equation"
- "eqn " -> "eqnarray"
- "\hs " -> "\hspace"
- "\vs " -> "\vspace"
-
- Removed features:
-
- * The 'TeX margins' have been removed due to their somewhat obscure
- interaction with the `general' margins setting: Switching the TeX
- margins ON does not immediately affect the current file, but when
- you open and close the settings notebook while the TeX margins are
- active, then they will be saved, too, and become the 'general'
- default for all file types. (I do understand what happens here,
- but what about users who are interested in writing texts and not in
- the EPM internals?)
-
- * The 'user defined formats' have disappeared. To my opinion it is
- difficult to understand why there are two different ways of defining
- the format to be used: The 'automatic format selection' and the
- 'user formats'.
-
- * The following features have also been removed:
- Orientation
- Resolving of references to environment variables (Will perhaps
- return in a later version)
- Unix style directory separators
- The menu item 'Remove DVI file'
- The option 'Auto save' (i.e. it is now always on)
- The option 'Auto log delete' (i.e. it is now always off)
- The 'Quick keys' (they may return in a later version)
- The 'Accelerator keys', except for '{', '$' and Ctrl-x,
- which are now included in the 'Syntax Assist' option.
- The TeX tabs
- The TeX margins (see above)
- The user formats (see above)
- (My policy was: Keep it small and simple!)
-
- Bug fixes:
-
- * Dependent files will be recognized when given as "\input{file}",
- too. Formerly only "\input file" and "\include{file}" were allowed.
-
- * Dependent files will no lomger be checked for modification if the
- \input or \include commands are commented out.
-
- * A user defined mouse pointer will no longer be overwritten by the
- TeX module.
-
- * 'Locate Next Error' has been made much more robust and handles
- arbitrary filenames now.
-
- * The initialization code is no longer executed multiple times.
-
- Source code:
-
- * When compiling the Pro version, the TeX module is now included
- into EPM.EX so that no separate .ex file must be loaded at startup
- time.
-
- * All messages are defined in a separate file so that support for
- different languages will be possible in the future.
-
- * Cleaned up the source code, removed unused universal variables
- etc.
-
-
- Known bugs and deficiencies:
-
- * You cannot TeX a file which has no `type'.
-
- * The LaTeX command \includeonly should be honored when master file
- support is on.
-
- * Only one simgle \include or \input command per line is recognized.
-
- * A folder opened via tex_fm cannot be closed through the window
- list.
-
- * The TeX menu is somteimes enabled erroineously, e.g., when a new
- module is losdad which adds its own submenu.
-
- * You cannot jump back to the _previous_ error.
-
- * You cannot request the window of a command to stay open after
- completion, because the `start' command has no such option. This
- would sometimes be convenient, so as to see whether a command has
- terminated normally or with an error message.
-
- * You cannot request a user command to check whether the document
- and the dependent files need to be saved before the command is
- executed.
- */
-
- /*********************************/
- /* */
- /* We need EPM 6.03b or later */
- /* */
- /*********************************/
-
- compile if EVERSION < '6.03b'
- *** Error: EPM version 6.03b required
- compile endif
-
-
-
-
- /******************************/
- /* */
- /* Standard or Pro version */
- /* */
- /******************************/
-
- compile if not defined(SMALL) -- being separately compiled
- const TEXFEPRO = 0
- compile else -- integrated "Pro(fessional)" version
- const TEXFEPRO = 1
- compile endif
-
-
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ Include the standard stuff we need when we are compiling separately │
- │ from epm.ex. │
- └────────────────────────────────────────────────────────────────────────────┘
- */
-
- compile if not defined(SMALL) -- Being compiled separately
- include 'stdconst.e'
- include 'colors.e'
- define INCLUDING_FILE = 'TEXFE.E'
- tryinclude 'MYCNF.E'
- compile if not defined(SITE_CONFIG)
- const SITE_CONFIG = 'SITECNF.E'
- compile endif
- compile if SITE_CONFIG
- tryinclude SITE_CONFIG
- compile endif
- compile if not defined(NLS_LANGUAGE)
- const NLS_LANGUAGE = 'ENGLISH'
- compile endif
- compile endif -- SMALL
-
-
-
- /*********************************************/
- /* */
- /* TeX menu and extended LaTeX syntax assist */
- /* */
- /*********************************************/
-
- compile if not defined(WANT_TEX_MENU) -- may have been defined in MYCNF.E
- define WANT_TEX_MENU = 1 -- default is to include the menu
- compile endif
-
- compile if not defined(EXTENDED_LATEX_ASSIST)
- define EXTENDED_LATEX_ASSIST = 0
- compile endif
-
-
- /*******************/
- /* */
- /* Version info */
- /* */
- /*******************/
-
- define PrimVersion = '2.2'
-
- const
- compile if TEXFEPRO
- TEXFE_VERSION = PrimVersion || ' Pro'
- compile else
- TEXFE_VERSION = PrimVersion
- compile endif /* TEXFEPRO */
- TEXFE_COPYRIGHT_STRING = '(C) Walter Schmidt 1997-1998'
-
- /* Within EPM.INI this application identifies itself as EPMTFE */
- TEX_APP = 'EPMTFE'
-
-
-
- /************************/
- /* */
- /* Include NLS support */
- /* */
- /************************/
-
- /* only German and English currently available */
- compile if NLS_LANGUAGE = 'DEUTSCH'
- include 'texfede.e'
- compile else
- include 'texfeen.e'
- compile endif
-
-
-
- /**************************************/
- /* */
- /* definit, defselect and defload */
- /* */
- /**************************************/
-
- definit -- called once at startup time
- universal app_hini,
- tex_debug,
- tex_log_file_name,
- tex_log_file_line,
- tex_log_file_curr
- compile if EXTENDED_LATEX_ASSIST
- universal TeX_Margin
- compile endif
-
- -- we initialize the information in the INI file, if necessary
-
- answer = queryprofile(app_hini, TEX_APP, 'VERSION')
- if answer <> TEXFE_VERSION then
- -- the database might have been changed,
- -- so we must check some of the settings:
- answer = queryprofile(app_hini, TEX_APP, 'DVIPS_EXEC')
- if answer = '' then
- call setprofile(app_hini, TEX_APP, 'DVIPS_EXEC', 'dvips')
- endif
- answer = queryprofile(app_hini, TEX_APP, 'FILETYPES')
- if answer = '' then
- call setprofile(app_hini, TEX_APP, 'FILETYPES', 'AUX LOG')
- endif
- answer = queryprofile(app_hini, TEX_APP, 'STYLETYPES')
- if answer = '' then
- call setprofile(app_hini, TEX_APP, 'STYLETYPES', 'STY')
- endif
- answer = queryprofile(app_hini, TEX_APP, 'DOCTYPES')
- if answer = '' then
- call setprofile(app_hini, TEX_APP, 'DOCTYPES', 'TEX')
- endif
- answer = queryprofile(app_hini, TEX_APP, 'DEFAULT_FORMAT')
- if answer = '' then
- call setprofile(app_hini, TEX_APP, 'DEFAULT_FORMAT', 'LaTeX')
- endif
- -- leave an 'ok' mark:
- call setprofile(app_hini, TEX_APP, 'VERSION', TEXFE_VERSION)
- endif -- VERSION
-
- compile if WANT_TEX_MENU
- 'PostMe BuildTexMenu' -- delay creating menu until after the definit
- compile endif
-
- -- we initialize the debug level
- tex_debug = 0
-
- -- we initialize log file processing
- tex_log_file_name = queryprofile(app_hini, TEX_APP, 'LOGFILE')
- if tex_log_file_name <> '' then
- sayerror TEX_LOGINIT_STRING||tex_log_file_name
- endif
- tex_log_file_line = 1
- tex_log_file_curr = 1
-
- -- we initialize the TeX line width
- compile if EXTENDED_LATEX_ASSIST
- TeX_Margin = queryprofile(app_hini, TEX_APP, 'MARGIN')
- if TeX_Margin = '' then
- TeX_Margin = 72
- call setprofile(app_hini, TEX_APP, 'MARGIN', 72)
- endif
- compile endif
-
- defselect -- called at startup time and when switching files
-
- compile if TEXFEPRO and WANT_TEX_MENU
- -- enable the TeX menu if TeX file loaded
- 'PostMe TexMenuEnable'
- compile endif
-
- -- load any requested keysets and enable syntax expansion
- call setTexKeySets()
-
- compile if EXTENDED_LATEX_ASSIST
- -- set margins to infinity, so as not to collide with TeX margins,
- -- when a TeX document or style file is edited
- call setTeXMargins()
- compile endif
-
- defload -- called when loading a file
- -- set hiliting if TeX file loaded
- call setTexHilite()
-
-
- /**********************************************************/
- /* */
- /* include the key set and the syntax assist functions */
- /* */
- /**********************************************************/
-
- compile if EXTENDED_LATEX_ASSIST
- include 'emacs.e'
- include 'xtexfek.e'
- compile else
- include 'texfek.e'
- compile endif
-
-
-
- /****************************/
- /* */
- /* Define TeX menu system */
- /* */
- /****************************/
-
- compile if WANT_TEX_MENU
-
- defc BuildTexMenu
- universal defaultmenu,
- app_hini
-
- -- load in required environment information to build menu system
- TEX_USER1_MENU_TEXT = queryprofile( app_hini, TEX_APP, 'USER1_MENU_TEXT')
- TEX_USER1__MSG = queryprofile( app_hini, TEX_APP, 'USER1__MSG')
- TEX_USER2_MENU_TEXT = queryprofile( app_hini, TEX_APP, 'USER2_MENU_TEXT')
- TEX_USER2__MSG = queryprofile( app_hini, TEX_APP, 'USER2__MSG')
- TEX_USER3_MENU_TEXT = queryprofile( app_hini, TEX_APP, 'USER3_MENU_TEXT')
- TEX_USER3__MSG = queryprofile( app_hini, TEX_APP, 'USER3__MSG')
- TEX_USER4_MENU_TEXT = queryprofile( app_hini, TEX_APP, 'USER4_MENU_TEXT')
- TEX_USER4__MSG = queryprofile( app_hini, TEX_APP, 'USER4__MSG')
-
- -- Temporarily delete Help menu so we can put it back later on the end
- -- of the menu bar where it belongs!
- deletemenu defaultmenu, HELP_MENU_ID, 0, 0 -- delete the existing Help menu
- -- (we want it to stay at the right)
-
- -- OS/2 menu
- compile if TEXFEPRO
- compile if defined(STD_MENU_NAME)
- -- the menu is not the standard one; we build our own OS/2 submenu
- buildsubmenu defaultmenu, 90, 'OS/~2', \1TEX_OS2__MSG, 0, 0
- buildmenuitem defaultmenu, 90, 910, TEX_OSSHELL_MENU_TEXT, 'tex_osshell'\1TEX_OSSHELL__MSG, 0, 0
- buildmenuitem defaultmenu, 90, 912, TEX_FOLDER_MENU_TEXT, 'tex_fm'\1TEX_FM__MSG, 0, 0
- compile else
- -- we add the OS/2 items to the "Command" and " File" submenus
- buildmenuitem defaultmenu, 1, 105, \0, '', 4, 0
- buildmenuitem defaultmenu, 1, 106, TEX_OSSHELL1_MENU_TEXT, 'tex_osshell'\1TEX_OSSHELL__MSG, 0, 0
- buildmenuitem defaultmenu, 2, 212, \0, '', 4, 0
- buildmenuitem defaultmenu, 2, 213, TEX_FOLDER1_MENU_TEXT, 'tex_fm'\1TEX_FM__MSG, 0, 0
- compile endif -- STD_MENU_NAME
- compile endif -- TEXFEPRO
-
- -- TeX menu
- buildsubmenu defaultmenu, 9, '~TeX', \1TEX_BAR__MSG, 0,0
- buildmenuitem defaultmenu, 9, 901, TEX_TEX_MENU_TEXT\9'Ctrl+F9', 'tex'\1TEX_TEX__MSG, 0,0
- buildmenuitem defaultmenu, 9, 908, TEX_TEXPS_MENU_TEXT\9'Ctrl+F10', 'texps'\1TEX_TEXPS__MSG, 0,0
- buildmenuitem defaultmenu, 9, 924, TEX_LOCERR_MENU_TEXT\9'Ctrl+F11', 'tex_locate_error'\1TEX_LOCATE_ERROR__MSG, 0,0
- buildmenuitem defaultmenu, 9, 905, TEX_VIEWLOG_MENU_TEXT\9'Ctrl+F12', 'tex_view_log'\1TEX_VIEW_LOG__MSG, 0,0
-
- buildmenuitem defaultmenu, 9, 902, \0, '', 4, 0
- buildmenuitem defaultmenu, 9, 903, TEX_VIEW_MENU_TEXT, 'tex_view_dvi'\1TEX_VIEW_DVI__MSG, 0,0
- buildmenuitem defaultmenu, 9, 943, TEX_VIEWPS_MENU_TEXT, 'tex_view_ps'\1TEX_VIEW_PS__MSG, 0,0
- buildmenuitem defaultmenu, 9, 904, TEX_PRINT_MENU_TEXT, 'tex_print'\1TEX_PRINT__MSG, 0,0
-
- buildmenuitem defaultmenu, 9, 941, \0, '', 4, 0
- buildmenuitem defaultmenu, 9, 944, TEX_DVIPS_MENU_TEXT, 'tex_dvips'\1TEX_DVIPS__MSG, 0,0
- if TEX_USER1_MENU_TEXT <> '' then
- buildmenuitem defaultmenu, 9, 911, TEX_USER1_MENU_TEXT,'texuser1exec' \1TEX_USER1__MSG, 0,0
- endif
- if TEX_USER2_MENU_TEXT <> '' then
- buildmenuitem defaultmenu, 9, 921, TEX_USER2_MENU_TEXT,'texuser2exec' \1TEX_USER2__MSG, 0,0
- endif
- if TEX_USER3_MENU_TEXT <> '' then
- buildmenuitem defaultmenu, 9, 930, TEX_USER3_MENU_TEXT,'texuser3exec' \1TEX_USER3__MSG, 0,0
- endif
- if TEX_USER4_MENU_TEXT <> '' then
- buildmenuitem defaultmenu, 9, 933, TEX_USER4_MENU_TEXT,'texuser4exec' \1TEX_USER4__MSG, 0,0
- endif
-
- buildmenuitem defaultmenu, 9, 927, \0, '', 4, 0
- buildmenuitem defaultmenu, 9, 931, TEX_CONF_MENU_TEXT,'texfe_settings_window' \1TEX_CONF__MSG,0,0
- compile if TEXFEPRO
- buildmenuitem defaultmenu, 9, 940, TEX_MFS_MENU_TEXT, 'tex_master_file_support' \1TEX_MASTER__MSG,0,0
- buildmenuitem defaultmenu, 9, 916, TEX_MAO_MENU_TEXT, 'tex_menu_always_on' \1TEX_MENU__MSG,0,0
- compile endif
- compile if not TEXFEPRO
- buildmenuitem defaultmenu, 9, 917, \0, '',4, 0
- buildmenuitem defaultmenu, 9, 910, TEX_OSSHELL2_MENU_TEXT, 'tex_osshell'\1TEX_OSSHELL__MSG, 0, 0
- buildmenuitem defaultmenu, 9, 912, TEX_FOLDER2_MENU_TEXT, 'tex_fm'\1TEX_FM__MSG, 0, 0
- compile endif
- buildmenuitem defaultmenu, 9, 922, \0, '', 4, 0
- buildmenuitem defaultmenu, 9, 929, TEX_ABOUT_MENU_TEXT, 'tex_ver' HELP_PROD_MENUP__MSG,0,0
-
- -- unused & not critical: 923 925 926 928
-
- call readd_help_menu(); -- Put Help menu back in
- showmenu defaultmenu
- compile if TEXFEPRO
- 'PostMe TexMenuEnable'
- compile endif
-
- compile if TEXFEPRO
- defc TexMenuEnable
- -- enable the TeX menu only if TeX file loaded
- -- or enable if TEX_MENUON is set
-
- universal app_hini
-
- if queryprofile( app_hini, TEX_APP, 'TEX_MENUON') then
- SetMenuAttribute(9, 16384, 1)
- else
- if tex_is_file() then
- SetMenuAttribute(9, 16384, 1)
- else
- SetMenuAttribute(9, 16384, 0)
- endif
- endif
- compile endif -- TEXFEPRO
-
- compile endif -- WANT_TEX_MENU
-
-
- /*****************************/
- /* */
- /* Set margins to infinity */
- /* */
- /*****************************/
-
- compile if EXTENDED_LATEX_ASSIST
- defproc setTexMargins
- universal expand_on
- if (tex_is_doc() or tex_is_style()) and expand_on then
- -- if TeX doc/style loaded and syntax expansion is on
- .margins = '1 1599 1'
- endif
- compile endif /* EXTENDED_LATEX_ASSIST */
-
-
- /**************************/
- /* */
- /* Enable highlighting */
- /* */
- /**************************/
-
- defproc setTexHilite
- universal app_hini
-
- if .visible and
- tex_is_file() and not ( (filetype()='DTX' or filetype()='FDD') ) and
- queryprofile(app_hini, TEX_APP, 'TEX_SYNTAXHILITE') then
- 'toggle_parse 1 EPMKWDS.TEX'
- endif
-
-
- /********************/
- /* */
- /* Execute TeX */
- /* */
- /********************/
-
- defc tex
- call tex_run_tex(0) -- run TeX
-
- defc texps
- call tex_run_tex(1) -- run TeX and dvips
-
- defproc tex_run_tex(ps) -- here we do the real work
-
- universal tex_log_file_line,
- tex_log_file_curr,
- tex_log_file_name,
- app_hini,
- tex_debug
-
- -- lockout if not a TeX document
- if not tex_is_doc() then
- sayerror TEX_NODOC_STRING
- RETURN
- endif
-
- -- memorize id of file being edited
- getfileid working_fid
-
- -- If a line mark exists, then ask whether only the marked region
- -- is to be processed; indicate this by process_mark = 1.
- process_mark = 0
- if (marktype() = 'LINE') then
- getmark a,b,c,d,marked_fid
- process_mark = (marked_fid = working_fid) -- mark is in the current file
- endif
- if process_mark then
- rc = WinMessageBox(TEX_MARK1_STRING,
- TEX_MARK2_STRING,
- MB_YESNOCANCEL+MB_NOICON+MB_DEFBUTTON1+MB_MOVEABLE)
- if rc = MBID_NO then
- process_mark = 0 -- proceed as usual
- elseif rc = MBID_CANCEL then
- RETURN -- cancel
- endif
- endif
-
- -- If master file system is enabled, then check for master file
-
- tex_master= queryprofile( app_hini, TEX_APP, 'TEX_MASTERFILE')
- if tex_master then /* master file system enabled */
- master = tex_master_name(TEX_TEX_TITLE)
-
- -- Need to change to master file to get Format from first line
- -- And TeX in that directory
-
- if master = '-1' then -- master file specified but not found on disk
- RETURN
- endif
-
- if master = '' then -- no master file specified
- sayerror .filename||TEX_M_ASSUME_STRING
- call tex_parse_filename(.filename,dr,dir,stem,ext)
- call tex_check_for_save()
- else -- a master file is being used
- sayerror TEX_M_NAME_STRING||master
- call tex_parse_filename(master,dr,dir,stem,ext)
- if tex_file_in_ring(master) then
- getfileid master_fid,master
- activatefile master_fid
- call tex_check_for_save()
- else
- 'edit /d' master
- getfileid master_fid
- endif
- endif
-
- -- Here we look for file dependencies in the file to be TeX'd
- -- and if dependent files are loaded in the editor
- -- they are checked for modification as well.
- -- Notes:
- -- * we search each line of the file so this can be a real
- -- performance bottleneck with large files
- -- * nested dependencies more than one level deep are ignored
- --
- -- We recognize 3 methods to specify an included file:
- -- LaTeX: \include{file} or \input{file}
- -- TeX: \input file
-
- getfileid source_fid
- for counter = 1 to .last
- getline line, counter
- if pos('%', strip(line)) <> 1 then -- line doesn't start with %
- parse value line with '\include{' dep_fname '}' .
- if dep_fname = '' then
- parse value line with '\input{' dep_fname '}' .
- if dep_fname = '' then
- parse value line with '\input ' dep_fname .
- endif
- endif
- else
- dep_fname = ''
- endif
-
- if dep_fname <> '' then
- -- Translate from unix-style to OS/2-style and add '.tex' extension if missing
- dep_fname = translate(strip(dep_fname),'\','/')
- n = lastpos('\',dep_fname)
- tmp = substr(dep_fname,n+1)
- if lastpos('.', tmp) <> length(tmp) then
- parse value tmp with tmpStem '.' tmpExt
- if tmpExt = '' then
- dep_fname = dep_fname||'.tex'
- endif
- else
- -- the given filename ends with '.', so
- -- we remove the '.' to get the real name
- dep_fname = substr(dep_fname, 1, length(dep_fname)-1)
- endif
- sayerror TEX_CHKDEP_STRING||dep_fname
- if tex_file_in_ring(dep_fname) = 1 then
- getfileid dep_fid,dep_fname
- activatefile dep_fid
- call tex_check_for_save()
- activatefile source_fid /* restore source file */
- endif
- endif
- endfor
- else /* master file system disabled */
- call tex_parse_filename(.filename,dr,dir,stem,ext)
- call tex_check_for_save()
- master = ''
- endif /* tex_master */
-
- -- update and set format to use
- format = tex_auto_format()
-
- -- determine filename to be passed to TeX program
- ; TeXfilename = translate(dr||dir||stem,'/','\')
- if translate(ext) <> 'TEX' then -- add extension
- TeXfilename = stem||'.'||ext
- else
- TeXfilename = stem
- endif
-
- -- get name of TeX program for the requested format
- texprog = queryprofile(app_hini, TEX_APP, translate(format))
- if texprog = '' then
- texprog = format||'.CMD'
- endif
-
- -- Change working directory to directory of current file since that is
- -- where the .DVI and .LOG files (and any others) should go.
- call tex_cd()
-
- -- TeX marked region only?
- if process_mark then
- getfileid current_fid -- memorize current file
- 'edit /n 'stem'.___' -- create temporary file
- -- first we locate the end of the preamble;
- bye = ''
- do counter = 1 to current_fid.last
- getline line, counter, current_fid
- insertline line
- if pos('\begin{document}', line) then
- bye = '\end{document}'
- leave
- endif
- if pos('%**end of header', line) then
- bye = '\bye'
- leave
- endif
- enddo
- if bye = '' then
- .modify = 0;
- 'quit'
- activatefile current_fid
- call WinMessageBox('TeX', TEX_MARK3_STRING,
- MB_OK+MB_WARNING+MB_MOVEABLE)
- RETURN
- -- we stay in the file the above warning refers to !
- endif
- -- now copy the marked lines from working_fid to temporary file
- do counter = a to b
- getline line, counter, marked_fid
- insertline line
- enddo
- insertline bye
- 'file' -- save and quit temporary file
- activatefile current_fid -- return to main document
- TeXfilename = stem'.___'
- endif /* process_mark */
-
- if ps=1 then
- dvips = queryprofile(app_hini, TEX_APP, 'DVIPS_EXEC')
- command = 'start /f /c "TeX/PS" TFETEXPS.CMD '||texprog||
- ' '||TeXfilename||' '||dvips||' '||stem||'.'||'dvi'
- if translate(rightstr(texprog,4))<>'.EXE' then
- command = command 'CALL'
- endif
- else
- command = 'start /f /c "TeX" '||texprog||' '||TeXfilename
- endif
-
- -- launch the TeX command
- if tex_debug=1 then sayerror 'TeX command: 'command; endif
- command
- if rc <> 0 then
- sayerror command||TEX_CMDFAIL_STRING||rc
- call tex_cmderror('TeX')
- else
- -- Memorize fully qualified name of current log file
- tex_log_file_name = dr||dir||stem||'.log'
- call setprofile(app_hini, TEX_APP, 'LOGFILE', tex_log_file_name)
- -- Remove old LOG file from the ring after successful TeX compilation
- if tex_file_in_ring(tex_log_file_name) = 1 then
- getfileid log_fid,tex_log_file_name
- activatefile log_fid
- .modify = 0 -- set this in case user modified file
- 'quit' -- close the file
- endif
- -- Can't load new log file here unless we wait for TeX to finish
- tex_log_file_line = 1
- tex_log_file_curr = 1
- -- need this in case the log file will be loaded manually
- endif /* rc <> 0 */
-
- -- Change back to file from which we called TeX if we changed it
- getfileid current_fid
- if current_fid <> working_fid then
- activatefile working_fid
- endif
- RETURN
-
-
- /********************/
- /* */
- /* DVI preview */
- /* */
- /********************/
-
- defc tex_view_dvi
- universal app_hini
-
- command = queryprofile( app_hini, TEX_APP, 'VIEW_CMD')
- call tex_run_cmd('.dvi', command, TEX_VIEW_TITLE, 'TEX_VIEW_DVI_OPT')
-
-
- /***************/
- /* */
- /* Print */
- /* */
- /***************/
-
- defc tex_print
- universal app_hini
-
- command = queryprofile( app_hini, TEX_APP, 'PRINT_CMD')
- call tex_run_cmd('.dvi', command, TEX_PRINT_TITLE, 'TEX_PRINT_OPT')
-
-
- /********************/
- /* */
- /* PS preview */
- /* */
- /********************/
-
- defc tex_view_ps
- universal app_hini
-
- command = queryprofile( app_hini, TEX_APP, 'VIEWPS_CMD')
- call tex_run_cmd('.ps', command, TEX_VIEWPS_TITLE, 'TEX_VIEWPS_OPT')
-
-
- /**************/
- /* */
- /* dvips */
- /* */
- /**************/
-
- defc tex_dvips
- universal app_hini
-
- dvips = queryprofile( app_hini, TEX_APP, 'DVIPS_EXEC')
- command = 'start /n /f 'dvips' %**N -o ["'dvips' %**N -o "]'
- call tex_run_cmd('.dvi', command, TEX_DVIPS_TITLE, 'TEX_DVIPS_OPT')
-
-
- /**********************/
- /* */
- /* View log file */
- /* */
- /**********************/
-
- defc tex_view_log
- universal tex_log_file_curr,
- tex_log_file_name,
- tex_error_fname,
- app_hini,
- tex_debug
-
- -- lockout if there is no "current" log file yet
- if not tex_current_log() then
- sayerror TEX_NOCURRLOG_STRING
- RETURN
- endif
-
- call tex_parse_filename(tex_log_file_name,dr,dir,stem,ext)
-
- -- if there are still errors to be processed,
- -- AND the log file is still in the ring:
- if tex_more_errors() and tex_file_in_ring(tex_log_file_name) then
- getfileid log_fid,tex_log_file_name
- getfileid current_fid
- activatefile log_fid
- -- if we are alreay in the log file, then start again at 1st error
- if current_fid = log_fid then
- call tex_parse_init()
- endif
- -- go to current error, if possible
- if tex_log_file_curr <= .last then
- .line = tex_log_file_curr
- endif
- -- No (more) errors or log file not in the ring?
- -- Then get rid of old copy in ring if it exists; edit new one.
- -- (Is this really necessary?)
- else
- if tex_file_in_ring(tex_log_file_name) then
- getfileid log_fid,tex_log_file_name
- activatefile log_fid
- .modify = 0 -- set this in case user modified file
- 'quit' -- close the file
- else
- tex_log_file_curr = 3 -- forget location of last error
- endif
- if not exist(tex_log_file_name) then
- call WinMessageBox(TEX_VIEWLOG_TITLE, TEX_L_LOG_STRING||
- tex_log_file_name||TEX_NOTFOUND_STRING,
- MB_OK+MB_WARNING+MB_MOVEABLE)
- -- clear the current log file name
- tex_log_file_name = ''
- call setprofile(app_hini, TEX_APP, 'LOGFILE', '')
- RETURN
- endif
- 'edit /d /r' tex_log_file_name
- -- show location of last error
- if tex_log_file_curr <= .last then
- .line = tex_log_file_curr
- endif
- -- initialize the parsing routines
- tex_error_fname = dr||dir||stem||'.tex' -- ?
- call tex_parse_init()
- endif
-
-
-
- /*************************/
- /* */
- /* The user commands */
- /* */
- /*************************/
-
- defc texuser1exec
- universal app_hini
-
- UserMenuText = queryprofile( app_hini, TEX_APP, 'USER1_MENU_TEXT')
- UserMenuTexT = translate(UserMenuText, '', '~')
- UserExt = queryprofile( app_hini, TEX_APP, 'USER1_EXT')
- command = queryprofile( app_hini, TEX_APP, 'USER1_CMD')
- key = 'USER1_OPT'
- call tex_run_cmd(UserExt, command, UserMenuText, key)
-
- defc texuser2exec
- universal app_hini
-
- UserMenuText = queryprofile( app_hini, TEX_APP, 'USER2_MENU_TEXT')
- UserMenuTexT = translate(UserMenuText, '', '~')
- UserExt = queryprofile( app_hini, TEX_APP, 'USER2_EXT')
- command = queryprofile( app_hini, TEX_APP, 'USER2_CMD')
- key = 'USER2_OPT'
- call tex_run_cmd(UserExt, command, UserMenuText, key)
-
- defc texuser3exec
- universal app_hini
-
- UserMenuText = queryprofile( app_hini, TEX_APP, 'USER3_MENU_TEXT')
- UserMenuTexT = translate(UserMenuText, '', '~')
- UserExt = queryprofile( app_hini, TEX_APP, 'USER3_EXT')
- command = queryprofile( app_hini, TEX_APP, 'USER3_CMD')
- key = 'USER3_OPT'
- call tex_run_cmd(UserExt, command, UserMenuText, key)
-
- defc texuser4exec
- universal app_hini
-
- UserMenuText = queryprofile( app_hini, TEX_APP, 'USER4_MENU_TEXT')
- UserMenuTexT = translate(UserMenuText, '', '~')
- UserExt = queryprofile( app_hini, TEX_APP, 'USER4_EXT')
- command = queryprofile( app_hini, TEX_APP, 'USER4_CMD')
- key = 'USER4_OPT'
- call tex_run_cmd(UserExt, command, UserMenuText, key)
-
-
- /***************************************/
- /* */
- /* Execute an external command */
- /* */
- /***************************************/
-
- defproc tex_run_cmd(FileExt, cmd, title, optname) =
-
- -- Arguments:
- -- FileExt check for the existence of this file type first
- -- cmd the command to be executed
- -- title use this as the title for error messages
- -- optname save extra options under this key in the INI file
-
- universal app_hini,
- tex_debug
-
- if cmd = '' then
- sayerror TEX_NOCONFIG_STRING
- RETURN
- endif
-
- -- If master file system is enabled, then check for master file
- tex_master= queryprofile( app_hini, TEX_APP, 'TEX_MASTERFILE')
- if tex_master then
- master = tex_master_name(title)
- if master = '-1' then
- RETURN
- endif
- if master = '' then
- sayerror .filename||TEX_M_ASSUME_STRING
- call tex_parse_filename(.filename,dr,dir,stem,ext)
- else
- sayerror TEX_M_NAME_STRING||master
- call tex_parse_filename(master,dr,dir,stem,ext)
- endif
- else
- call tex_parse_filename(.filename,dr,dir,stem,ext)
- endif /* masterfile support */
-
- -- lockout if file does not exist
- if FileExt <> '' then
- if not exist(dr||dir||stem||FileExt) then
- sayerror FileExt||TEX_NOEX2_STRING
- RETURN
- endif
- endif
-
- -- Substitute the filename in the command string
- command = tex_makecmd(cmd, stem, ext)
-
- -- Evaluate options to be entered interactively
- if pos('[',command) and optname <> '' then
- parse value command with lcommand '[' prompttext ']' rcommand
- curopts = queryprofile( app_hini, TEX_APP, optname)
- sbuf = entrybox(title,
- TEX_XOPT_BUTTONS,
- curopts,60,62,
- atoi(1) || -- default button #
- atoi(0) || -- help panel ID (0 for no help)
- gethwnd(APP_HANDLE) ||
- TEX_ADDOPT_STRING||prompttext||\0)
- -- prompt
- button = asc(leftstr(sbuf,1))
- if button=3 or button=0 then RETURN; endif -- Cancel or closed otherwise
- if button=2 then -- Use std. options
- options = ''
- else -- Use extra options
- EOS = pos(\0,sbuf,2) -- CHR(0) signifies End Of String
- options = substr(sbuf,2,EOS-2)
- call setprofile( app_hini, TEX_APP, optname, options)
- endif
- command = lcommand||options||rcommand
- endif
-
- -- tell the user that the command is going to be launched:
- sayerror title
-
- -- Change working directory to directory of current/master file since that is
- -- where the .DVI and .LOG files (and any others) should go.
-
- savedir = directory() -- save directory **
- tstr = dr || leftstr(dir,length(dir)-1)
- if not (savedir = tstr) then
- if tex_debug then sayerror 'Changing to directory 'tstr; endif
- call directory(tstr) -- change directory **
- endif
-
- -- launch the command
- if tex_debug=1 then sayerror 'Run command: 'command; endif
- command
- if rc <> 0 then
- sayerror command||TEX_CMDFAIL_STRING||rc
- call tex_cmderror(title)
- endif
-
- -- change back to directory from where we called the command
- ;if not (savedir = tstr) then
- ; if tex_debug then sayerror 'Back to directory 'savedir; endif
- ; call directory(savedir) -- restore directory **
- ;endif
-
-
-
- /******************************************************/
- /* */
- /* Read LOG file and find errors in source code */
- /* */
- /******************************************************/
-
- defc tex_locate_error
- universal tex_log_file_name
-
- -- lockout if there is no "current" log file yet
- if not tex_current_log() then
- sayerror TEX_NOCURRLOG_STRING
- RETURN
- endif
-
- if tex_more_errors() then -- more errors to be shown?
- call tex_find_errors()
- else
- sayerror TEX_NOERRORS_STRING
- endif
-
-
-
- /***************************/
- /* */
- /* Product information */
- /* */
- /***************************/
- defc tex_ver
- call WinMessageBox(TEX_ABOUT_TITLE,
- 'TeX Front End'||TEXFE_VERSION_STRING||TEXFE_VERSION\13||
- TEXFE_COPYRIGHT_STRING\13\13||
- TEXFE_THANKS_STRING,
- MB_OK+MB_INFORMATION+MB_DEFBUTTON1+MB_MOVEABLE)
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ Procedure definitions │
- └────────────────────────────────────────────────────────────────────────────┘
- */
- -----------------------------------------------------------------------------
- -- Determine format to use with this file from first line of the file.
- -- Same specification as Eberhard Mattes' TEXIT.CMD distributed with emTeX.
- -- The default format is DEFAULT_FORMAT.
-
- defproc tex_auto_format =
- universal app_hini
-
- format = ''
- getline line, 1
- line = translate(line)
- parse value line with '%' 'FORMAT' ':' format .
- if format = '' then
- parse value line with '%' 'FORMAT' format .
- endif
-
- if format = '' then
- format = queryprofile (app_hini, TEX_APP, 'DEFAULT_FORMAT')
- sayerror TEX_NO_FORMAT_STRING||format||TEX_USE_FORMAT_STRING
- else
- sayerror TEX_FORMAT_STRING||format||TEX_USE_FORMAT_STRING
- endif
- return format
-
-
- -----------------------------------------------------------------------------
- compile if TEXFEPRO
- -- Called from mymniuni.e to determine if file of given type exists for the
- -- associated master file, or for current file.
- -- Returns: 1 if file does not exist or if the master file does not exist
- -- 0 if the file exists
-
- defproc tex_check_exist(FileExt) =
- universal app_hini
-
- -- If master file system is enabled, then check for master file
- if queryprofile( app_hini, TEX_APP, 'TEX_MASTERFILE') then
- master = tex_master_name()
- if master = '' then
- fname = .filename
- else
- fname = master
- endif
- else
- fname = .filename
- endif -- master file support
- if fname = '-1' then
- ret = 1
- else
- if FileExt = '' then
- ret= 0
- else
- call tex_parse_filename(fname,dr,dir,stem,ext)
- ret = not exist(dr||dir||stem||FileExt)
- endif
- endif
- return ret
- compile endif /* TEXFEPRO */
-
- -----------------------------------------------------------------------------
- compile if TEXFEPRO
- -- get the value of TEX_USER?_EXT
-
- defproc get_tex_user_ext =
- universal app_hini
-
- if arg(1) = 1 then
- return queryprofile(app_hini, TEX_APP, 'USER1_EXT')
- elseif arg(1) = 2 then
- return queryprofile(app_hini, TEX_APP, 'USER2_EXT')
- elseif arg(1) = 3 then
- return queryprofile(app_hini, TEX_APP, 'USER3_EXT')
- elseif arg(1) = 4 then
- return queryprofile(app_hini, TEX_APP, 'USER4_EXT')
- else
- return ''
- endif
- compile endif /* TEXFEPRO */
-
- -----------------------------------------------------------------------------
- compile if TEXFEPRO
- -- determine if TEX_USER?_MENU_TEXT is defined
-
- defproc tex_check_user_exec =
- universal app_hini
-
- if arg(1) = 1 then
- return queryprofile(app_hini, TEX_APP, 'USER1_MENU_TEXT') <> ''
- elseif arg(1) = 2 then
- return queryprofile(app_hini, TEX_APP, 'USER2_MENU_TEXT') <> ''
- elseif arg(1) = 3 then
- return queryprofile(app_hini, TEX_APP, 'USER3_MENU_TEXT') <> ''
- elseif arg(1) = 4 then
- return queryprofile(app_hini, TEX_APP, 'USER4_MENU_TEXT') <> ''
- else
- return 0
- endif
- compile endif /* TEXFEPRO */
-
- -----------------------------------------------------------------------------
- -- Check to see if current file has been modified. If it has, save it.
-
- defproc tex_check_for_save =
-
- if .modify then
- 'Save'
- endif
-
- -----------------------------------------------------------------------------
- /*
- Extract master file name from first line of file
-
- Returns: a) '' if master file is not specified;
- b) master file name with path added on if file exists;
- c) '-1', if master file is specified but doesn't exist.
-
- If arg(1) <> '' AND the master file is specified, but doesn't
- exist, a warning message is displayed, using arg(1) as the title.
- */
-
- defproc tex_master_name
- universal app_hini
-
- master = ''
- getline line, 1
- parse value line with '%' . 'master' ':' master .
- if master = '' then
- parse value line with '%' . 'master' master .
- if master = '' then
- parse value line with '%' . 'Master' ':' master .
- if master = '' then
- parse value line with '%' . 'Master' master .
- endif
- endif
- endif
-
- if master <> '' then
- master = translate(master,'\','/') -- convert to DOS format
- if lastpos('\', master) >= lastpos('.',master) then
- -- there is no '.' in the name
- master = master||'.tex'
- endif
- -- *** bug: filename. -> filename..tex
-
- -- Now, make the master filename fully qualified. We assume master is
- -- in current directory unless specified name is fully qualified.
- -- If only a stem.ext add current drive and dir
- tex_parse_filename(.filename,dr,dir,stem,ext)
- if lastpos('\',master) = 0 then
- master = dr||dir||master
- else
- -- if no drive letter add current drive
- if leftstr(master,1) = '\' then
- master = dr||master
- endif
- endif
- -- Does the master file exist?
- if not exist(master) then
- if arg(1) <> '' then
- call WinMessageBox(arg(1), TEX_M_MASTER_STRING||master||
- TEX_NOTFOUND_STRING,
- MB_OK+MB_WARNING+MB_MOVEABLE)
- endif
- master = '-1'
- endif
- endif
-
- return master
-
- -----------------------------------------------------------------------------
- -- Parse a file name: d:\dir1\dir2\file.ext
- -- \dir1\dir2\file.ext
- -- file.ext
- -- .ext
- -- \dir1\.ext
- -- ...etc, but NOT d:test2.ext
- -- returns dr d:
- -- dir \dir1\dir2\ if any of these does not exist,
- -- stem file a null is returned.
- -- ext ext
-
- defproc tex_parse_filename(fname, var dr, var dir, var stem, var ext)
-
- -- Translate from Unix-style to OS/2-style names
- fname = translate(fname,'\','/')
- n = lastpos('\',fname)
- tmp = substr(fname,n+1)
- parse value tmp with stem '.' ext
- tmp = substr(fname,1,n)
- n = pos(':',tmp)
- dr = substr(tmp,1,n)
- dir = substr(tmp,n+1)
-
-
-
- -----------------------------------------------------------------------------
- -- Determine if a file already is in ring.
-
- defproc tex_file_in_ring(fname)
- universal tex_debug
-
- getfileid id, fname
- return (id <> '')
- /*
- tex_parse_filename(fname,dr,dir,stem,ext)
- if ext = '' then
- return pfile_exists(stem)
- else
- return pfile_exists(stem||'.'||ext)
- endif
- */
-
- -----------------------------------------------------------------------------
- -- Called to determine whether or not to disable
- -- the error browsing facility.
- -- Returns 1 if there can be more errors,
- -- 0 if not or no "current" log file exists
-
- defproc tex_more_errors
- universal tex_log_file_line,
- tex_log_file_last,
- tex_log_file_name
-
- if tex_log_file_name <> '' then -- a current log file exists
- if tex_file_in_ring(tex_log_file_name) then -- loaded?
- -- can there still be errors in it?
- res = ( tex_log_file_line < tex_log_file_last )
- else
- res = 1
- endif -- file in ring
- else
- res = 0
- endif -- current log file exists
- return res
-
-
- -----------------------------------------------------------------------------
- -- Determine whether there is a "current" log file.
- -- Returns 1 if so.
-
- defproc tex_current_log
- universal tex_log_file_name
- return tex_log_file_name <> ''
-
- -----------------------------------------------------------------------------
- -- Read LOG file and find errors in source code
-
- defproc tex_find_errors
- universal tex_log_file_line,
- tex_log_file_curr,
- tex_log_file_last,
- tex_log_file_name,
- tex_error_fname,
- name_count,
- par_count,
- EPM_utility_array_ID,
- app_hini,
- tex_debug
-
- empty = ''
- getfileid tex_return_to_fid
-
- tex_parse_filename(tex_log_file_name,dr,dir,stem,ext)
-
- if tex_file_in_ring(tex_log_file_name) = 1 then
- getfileid log_fid,tex_log_file_name
- activatefile log_fid
- else
- if not exist(tex_log_file_name) then
- call WinMessageBox(TEX_LOCERR_TITLE, TEX_L_LOG_STRING||
- tex_log_file_name||TEX_NOTFOUND_STRING,
- MB_OK+MB_WARNING+MB_MOVEABLE)
- -- clear the current log file name
- tex_log_file_name = ''
- call setprofile(app_hini, TEX_APP, 'LOGFILE', '')
- RETURN
- endif
- 'edit /d /r' tex_log_file_name
- getfileid log_fid
- tex_error_fname = dr||dir||stem||'.tex' -- ?
- call tex_parse_init()
- endif
- call tex_cd()
-
- do while (tex_log_file_line < tex_log_file_last)
-
- getline line, tex_log_file_line
-
- if leftstr(line,1) = '!' then
- -- memorize line number of the current error
- tex_log_file_curr = tex_log_file_line
- parse value line with '!'error_msg
- -- search for line containing line number of error;
- -- if none is present, we must not run over the end of the file;
- -- better: realise this situation before -- how?
- do forever
- tex_log_file_line = tex_log_file_line + 1
- if tex_log_file_line > tex_log_file_last then leave endif
- getline line, tex_log_file_line
- if (leftstr(line,1) = 'l') or (leftstr(line,1) = '!') then
- leave
- endif
- enddo
- -- The message:
- parse value line with 'l.' linenum contexttext
- if isnum(linenum) then
- sayerror error_msg': 'contexttext
- else
- sayerror TEX_NOLOC_STRING||tex_error_fname
- endif
- -- Where is the error?
- if not isnum(linenum) then
- -- position of error cannot be determined,
- -- so we stay in the log file:
- .line = tex_log_file_curr
- elseif pos('.___',tex_error_fname) then
- -- A marked region has been processed;
- -- don't edit the temporary file!
- -- Stay on the error message in the .log file:
- .line = tex_log_file_line
- elseif tex_file_in_ring(tex_error_fname) = 1 then
- -- The file is already in the editor.
- getfileid tex_error_fid,tex_error_fname
- activatefile tex_error_fid
- if tex_debug > 1 then sayerror 'next file: 'tex_error_fname endif
- else
- -- This file should exist since we 'just' compiled it.
- 'edit /d' tex_error_fname
- if tex_debug > 1 then sayerror 'next file: 'tex_error_fname endif
- endif
- -- How to proceed?
- if not isnum(linenum) then
- -- Procced with line after the error message:
- tex_log_file_line = tex_log_file_curr + 1
- -- *** possible bug, perhaps ... +2 ?
- elseif pos('.___',tex_error_fname) then
- -- proceed with next line
- tex_log_file_line = tex_log_file_line + 1
- elseif linenum > .last then
- -- Don't run over the last line, show log file instead
- activatefile log_fid
- .line = tex_log_file_curr
- sayerror TEX_ERRERR_STRING||tex_error_fname
- else
- -- OK, proceed and show the error in the source code:
- getline errorline, linenum
- tex_log_file_line = tex_log_file_line + 1
- if length(contexttext) > 4 then
- chopum = 4
- else
- chopum = 1
- endif
- col1 = pos( substr(contexttext,chopum), errorline)
- col2 = col1 + length(contexttext) - chopum + 1
- .line = linenum
- .col = col2
- 'PostMe tex_circleit '||col1
- endif
- RETURN
- else /* This is not a line starting with '!' */
-
- do while not ( line = '')
-
- if tex_debug > 2 then sayerror 'line='line; endif
- left_par = pos('(',line)
- right_par = pos(')',line)
- if tex_debug > 2 then sayerror 'left_par='left_par' right_par='right_par; endif
- -- EPM5 can only handle lines of 255 chars anyway, so make them 256 if the
- -- are 0 to simplify things a bit.
- if left_par = 0 then left_par = 256 endif
- if right_par = 0 then right_par = 256 endif
-
- if (right_par < left_par) then
- par_count = par_count - 1
- if tex_debug > 2 then sayerror 'par_count (decreased) ='par_count; endif
- if par_count = 0 then
- if tex_debug > 2 then sayerror 'Erasing name 'name_count' from array'; endif
- do_array 2, EPM_utility_array_ID, 'tex_fname.'name_count, empty
- do_array 2, EPM_utility_array_ID, 'tex_par.'name_count, empty
- name_count = name_count - 1
- -- name_count will be 0 when we are finished
- if name_count > 0 then
- do_array 3, EPM_utility_array_ID, 'tex_fname.'name_count, tex_error_fname
- do_array 3, EPM_utility_array_ID, 'tex_par.'name_count, par_count
- if tex_debug > 2 then sayerror 'Got 'tex_error_fname'('name_count') and par_count='par_count; endif
- else
- if tex_debug > 2 then sayerror 'name_count = 0'; endif
- endif
- endif
- if tex_debug > 2 then sayerror 'line= 'line; endif
- line = substr(line,right_par+1)
- if tex_debug > 2 then sayerror 'newline='line; endif
- else
- if not (left_par = 256) then
- line = substr(line,left_par+1)
- if tex_debug > 1 then
- sayerror 'searching for filename in:'line
- endif
- if tex_extract_fname(line,dr,dir) = 0 then
- par_count = par_count + 1
- if tex_debug > 2 then sayerror 'par_count (increased) ='par_count; endif
- else
- par_count = 1
- if tex_debug > 2 then sayerror 'par_count set to 1'; endif
- endif
- else
- line = ''
- endif
- endif
- enddo /* while not (line='') */
- tex_log_file_line = tex_log_file_line + 1
- endif /* line starts with ! */
-
- enddo /* while (tex_log_file_line < tex_log_file_last) */
-
- if not (tex_log_file_line < tex_log_file_last) then
- activatefile tex_return_to_fid
- sayerror TEX_NOERRORS_STRING
- endif
-
- -----------------------------------------------------------------------------
- -- executed (if requested) after the above routine returns to the user
- defc tex_circleit
- circleit 3, .line, arg(1), .col, LIGHT_RED
- -- thick light-red circle; well visible,
- -- except on red background, which is unlikely
- return
-
- -----------------------------------------------------------------------------
- -- we are in the log file and initialize the error parsing facility
- defproc tex_parse_init
- universal tex_log_file_line,
- tex_log_file_curr,
- tex_log_file_last,
- name_count,
- par_count
-
- tex_log_file_line = 3
- tex_log_file_curr = 3
- tex_log_file_last = .last
- name_count = 0
- par_count = 1
- return
-
- -----------------------------------------------------------------------------
- -- This routine is called by tex_find_errors .
- -- Its 1st argument is a part of a line from the log file, starting after a '('.
- -- It determines whether or not the text following the '(' is a filename.
- -- If it is, tex_error_fname is changed to that name, and the routine
- -- returns 1. Otherwise, a 0 is returned.
- --
- -- The logic goes like this:
- -- 1) search for '(', ')' and ' '; throw away what follows
- -- 2) make sure there is a '.' in the remaining string
- -- 3) parse it into pieces before '.' and after '.'
- -- 4) make sure that the first part is not empty
- -- 5) the name is fully qualified and placed in
- -- tex_error_fname, and is also put into an array.
- -- 6) take name out of "line"
- -- 7) return
-
- defproc tex_extract_fname(var line, dr, dir)
- universal tex_error_fname,
- par_count,
- name_count,
- EPM_utility_array_ID,
- tex_debug
-
- flag = 0
- tmp = line
- -- truncate before a possible space, '(' or ')':
- ppos = pos(' ', tmp)
- if ppos > 0 then
- tmp = leftstr(tmp, (ppos-1))
- endif
- ppos = pos('(', tmp)
- if ppos > 0 then
- tmp = leftstr(tmp, (ppos-1))
- endif
- ppos = pos(')', tmp)
- if ppos > 0 then
- tmp = leftstr(tmp, (ppos-1))
- endif
- -- now make sure there is still a '.' in it:
- if pos('.', tmp) then
- -- break it into pieces before and after the '.'
- parse value tmp with tmp1 '.' tmp2
- if tmp1 <> '' then -- yes, it was a filename
- if tmp2 = '' then -- take tmp1 only
- tmpname = tmp1
- else
- tmpname = tmp1||'.'||tmp2
- endif
- -- Translate from Unix-style to OS/2-style file names
- tex_error_fname = translate(tmpname,'\','/')
- -- Now, name the name fully qualified
- -- If only a stem.ext
- if lastpos('\',tex_error_fname) = 0 then
- tex_error_fname = dr||dir||tex_error_fname
- if tex_debug > 2 then sayerror 'tex_error_fname (again1)='tex_error_fname; endif
- else
- -- if no drive letter
- if leftstr(tex_error_fname,1) = '\' then
- tex_error_fname = dr||tex_error_fname
- if tex_debug > 2 then sayerror 'tex_error_fname (again2)='tex_error_fname; endif
- endif
- endif
- name_count = name_count + 1
- if tex_debug > 2 then sayerror 'Putting 'tex_error_fname' on stack with par_count='par_count' at position 'name_count; endif
- do_array 2, EPM_utility_array_ID, 'tex_fname.'name_count, tex_error_fname
- do_array 2, EPM_utility_array_ID, 'tex_par.'name_count, par_count
- flag = 1
- -- Take the filename out of line for next loop
- ; line = substr(line,pos(tmpname,line)+length(tmpname))
- line = substr(line,pos(tmp,line)+length(tmp)) -- *** v1.1
- endif
- endif
-
- return flag
-
- -----------------------------------------------------------------------------
- /*
- -- A procedure to expand environment variables in user defined constants
- --
- -- searches for $variable: in user defined constants and expands 'variable'
- -- if found
-
- defproc Expand_Env(Input)
-
- Parse Value Input with Lead_Var '$' Env_Var ':' Trail_Var
-
- if Env_Var <> '' & LastPos(':',Input) > Pos('$',Input) then
- Output = Lead_Var || Get_Env(Env_Var) || Trail_Var
- else
- Output = Input
- endif
-
- return Output
- */
-
- -----------------------------------------------------------------------------
- -- A procedure to check whether the current file is a TeX document
-
- defproc tex_is_doc
- universal app_hini
-
- types = queryprofile( app_hini, TEX_APP, 'DOCTYPES')
- return wordpos(filetype(), types)
-
-
- -----------------------------------------------------------------------------
- -- A procedure to check whether the current file is a TeX style file
-
- defproc tex_is_style
- universal app_hini
-
- types = queryprofile( app_hini, TEX_APP, 'STYLETYPES')
- return wordpos(filetype(), types)
-
-
- -----------------------------------------------------------------------------
- -- A procedure to check whether the current file is a TeX auxiliary file
-
- defproc tex_is_aux
- universal app_hini
-
- types = queryprofile( app_hini, TEX_APP, 'FILETYPES')
- return wordpos(filetype(), types)
-
-
- ----------------------------------------------------------------------------
- -- A procedure to check whether the current file is a TeX file
-
- defproc tex_is_file
- universal app_hini
-
- auxtypes = queryprofile( app_hini, TEX_APP, 'FILETYPES')
- doctypes = queryprofile( app_hini, TEX_APP, 'DOCTYPES')
- styletypes = queryprofile( app_hini, TEX_APP, 'STYLETYPES')
- return wordpos(filetype(), doctypes auxtypes styletypes)
-
- -----------------------------------------------------------------------------
- -- Substitute the arg specifieres %**N and %**F within a command string
-
- defproc tex_makecmd(command, fname, ext)
- -- we perform the following substitutions:
- -- %**N -> filename without extension
- -- %**F -> filename with extension
-
- do forever
- posi=pos('%**N', command)
- if posi then
- command=delstr(command, posi, 4)
- command = insertstr(fname, command, (posi-1))
- else
- leave
- endif
- enddo
- do forever
- posi=pos('%**F', command)
- if posi then
- command=delstr(command, posi, 4)
- command = insertstr(fname'.'ext, command, (posi-1))
- else
- leave
- endif
- enddo
- return command
-
- -----------------------------------------------------------------------------
- -- check a variable from the INI file, return its value as 'ON' or 'OFF'
-
- defproc tex_querysetting(name)
- universal app_hini
- if queryprofile(app_hini, TEX_APP, name) then
- return(TEX_ON_STRING)
- else
- return(TEX_OFF_STRING)
- endif
- return
-
- -----------------------------------------------------------------------------
- -- toggle a variable from the INI file
-
- defproc tex_togglesetting(name)
- universal app_hini
- if queryprofile(app_hini, TEX_APP, name) then
- call setprofile(app_hini, TEX_APP, name, '')
- else
- call setprofile(app_hini, TEX_APP, name, '1')
- endif
- return
-
- -----------------------------------------------------------------------------
- -- Switch to the directory of the current file
-
- defproc tex_cd
- universal tex_debug
-
- dirpos=lastpos('\',.filename)
- if dirpos>1 then
- if tex_debug then
- sayerror '.filename ='.filename', cd 'substr(.filename,1,dirpos-1)
- endif
- call directory(substr(.filename,1,dirpos-1))
- endif
- return
-
- -----------------------------------------------------------------------------
- -- Pop up a warning about a command that crashed
-
- defproc tex_cmderror(title)
- call WinMessageBox(title, TEX_CMDERR_STRING,
- MB_OK+MB_ERROR+MB_MOVEABLE)
- return
-
-
- /************************************/
- /* */
- /* The OS/2 related procedures */
- /* */
- /************************************/
-
- defc tex_osshell
-
- call tex_cd()
- title = 'Shell - 'directory()
- command = 'start "'title'" /F /K MODE CO80, 40'
- command
- if rc <> 0 then
- sayerror command||TEX_CMDFAIL_STRING||rc
- call tex_cmderror(TEX_OSSHELL_TITLE)
- endif
- return
-
-
- defc tex_fm -- 'fm' means 'file manager' :-)
-
- call tex_cd()
- command = 'start /F /C /MIN TFEFM.CMD'
- command
- if rc <> 0 then
- sayerror command||TEX_CMDFAIL_STRING||rc
- call tex_cmderror(TEX_FOLDER_TITLE)
- endif
- return
-
-
- /********************************************************/
- /* */
- /* All the procedures to change/show the settings */
- /* */
- /********************************************************/
-
- defc tex_debuglevel
- universal tex_debug
- if arg(1) = '' then
- sayerror 'TeX_debuglevel: 'tex_debug
- else
- tex_debug = arg(1)
- endif
-
-
- compile if TEXFEPRO and WANT_TEX_MENU
-
- defproc check_tex_master -- check whether master file support is enabled
- universal app_hini
- if queryprofile(app_hini, TEX_APP, 'TEX_MASTERFILE') then
- return 1
- else
- return 0
- endif
- return
-
- defproc check_tex_menuon -- check whether menu should always be on
- universal app_hini
- if queryprofile(app_hini, TEX_APP, 'TEX_MENUON') then
- return 1
- else
- return 0
- endif
- return
-
- defc tex_master_file_support
- call tex_togglesetting('TEX_MASTERFILE')
- return
-
- defc tex_menu_always_on
- call tex_togglesetting('TEX_MENUON')
- return
-
- compile endif /* TEXFEPRO and WANT_TEX_MENU */
-
-
- defproc tex_set_data(id) -- change user settings
- universal app_hini
- compile if EXTENDED_LATEX_ASSIST
- universal TeX_Margin
- compile endif
-
- if id='1' then -- document file types
-
- current_types = queryprofile(app_hini, TEX_APP, 'DOCTYPES')
- types = strip(entrybox(TEX_DOCTYPES_STRING, TEX_EC_BUTTONS,
- current_types,60,40))
- if types <> '' then
- call setprofile(app_hini, TEX_APP, 'DOCTYPES', translate(types))
- endif
-
- elseif id='2' then -- style file types
-
- current_types = queryprofile(app_hini, TEX_APP, 'STYLETYPES')
- types = strip(entrybox(TEX_STYLETYPES_STRING, TEX_EC_BUTTONS,
- current_types,60,40))
- if types <> '' then
- call setprofile(app_hini, TEX_APP, 'STYLETYPES', translate(types))
- endif
-
- elseif id='3' then -- auxiliary file types
-
- current_types = queryprofile(app_hini, TEX_APP, 'FILETYPES')
- types = strip(entrybox(TEX_FILETYPES_STRING, TEX_EC_BUTTONS,
- current_types,60,40))
- if types <> '' then
- call setprofile(app_hini, TEX_APP, 'FILETYPES', translate(types))
- endif
-
- elseif id='4' then -- accelerator keys
-
- call tex_togglesetting('TEX_KEYS')
-
- elseif id='5' then -- highlighting
-
- call tex_togglesetting('TEX_SYNTAXHILITE')
-
- elseif id='6' then -- default format
-
- current_format = queryprofile(app_hini, TEX_APP, 'DEFAULT_FORMAT')
- format = strip(entrybox(TEX_FORMAT_TITLE, TEX_EC_BUTTONS,
- current_format,60,40))
- if format <> '' then
- call setprofile(app_hini, TEX_APP, 'DEFAULT_FORMAT', format)
- endif
-
- elseif id='7' then -- master file support
-
- call tex_togglesetting('TEX_MASTERFILE')
-
- compile if EXTENDED_LATEX_ASSIST
- elseif id='8' then -- TeX margin
-
- ma = strip(entrybox(TEX_MA_TITLE, TEX_EC_BUTTONS,
- TeX_Margin,60,40))
- if (ma <> '') and isnum(ma) then
- call setprofile(app_hini, TEX_APP, 'MARGIN', ma)
- TeX_Margin = ma
- -- We do not only save the value in the INI file,
- -- we also save it in a universal variable, because
- -- this value must be read each time the <space> or
- -- <enter> key is pressed.
- endif
- compile endif
-
- endif
- return /* tex_set_data() */
-
-
- defc texfe_settings_window
- -- contributed by Wonkoo Kim (wkim+@pitt.edu), November 14, 1997;
-
- universal app_hini
- compile if EXTENDED_LATEX_ASSIST
- universal TeX_Margin
- compile endif
-
- if arg(1) = '' then
- id = 1
- else
- id = arg(1)
- endif
-
- menu_title = TEX_CONF_TITLE
- settings = ''
- no = 1
- settings = settings||\1no||' 'TEX_S1' = '||queryprofile(app_hini, TEX_APP, 'DOCTYPES')
- no = no + 1
- settings = settings||\1no||' 'TEX_S2' = '||queryprofile(app_hini, TEX_APP, 'STYLETYPES')
- no = no + 1
- settings = settings||\1no||' 'TEX_S3' = '||queryprofile(app_hini, TEX_APP, 'FILETYPES')
- no = no + 1
- settings = settings||\1no||' 'TEX_S4' = '||tex_querysetting('TEX_KEYS')
- no = no + 1
- settings = settings||\1no||' 'TEX_S5' = '||tex_querysetting('TEX_SYNTAXHILITE')
- no = no + 1
- settings = settings||\1no||' 'TEX_S6' = '||queryprofile(app_hini, TEX_APP, 'DEFAULT_FORMAT')
- no = no + 1
- settings = settings||\1no||' 'TEX_S7' = '||tex_querysetting('TEX_MASTERFILE')
- compile if EXTENDED_LATEX_ASSIST
- no = no + 1
- settings = settings||\1no||' 'TEX_S8' = '||TeX_Margin
- compile endif
- --
- y = min(25,.windowheight+2)
- x = min(15,.windowwidth*.3)
- h = min(8,.windowheight*.75)
- w = min(70,.windowwidth)
- sbuf = listbox(menu_title, settings,
- TEX_MO_BUTTONS,
- y,x,h,w, -- row,col,height,width
- gethwnd(APP_HANDLE) ||
- atoi(id) || -- initial item # selected (start from 1)
- atoi(1) || -- default button # selected (start from 1)
- atoi(0) || -- help panel ID (0 for no help)
- ''\0); -- prompt
- button = asc(leftstr(sbuf,1))
- if button = 1 then
- EOS = pos(\0, sbuf, 2) -- CHR(0) signifies End Of String
- select = substr(sbuf, 2, EOS-2)
- else
- return
- endif
- -- 'TeX_'||word(select,2)
- call tex_set_data( word(select,1) )
- 'texfe_settings_window' word(select,1)
-
- /* Finis */
-
-