diff --git a/lib/configure.py b/lib/configure.py index 56c74486b8..af2de9bfd1 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -111,7 +111,7 @@ def checkCygwinPath(srcdir): ## Searching some useful programs -def checkProg(description, progs, rc_entry = [], path = [] ): +def checkProg(description, progs, rc_entry = [], path = [], not_found = ''): ''' This function will search a program in $PATH plus given path If found, return directory and program name (not the options). @@ -127,16 +127,19 @@ def checkProg(description, progs, rc_entry = [], path = [] ): rc_entry: entry to outfile, can be 1. emtpy: no rc entry will be added 2. one pattern: %% will be replaced by the first found program, - or 'none' is no program is found. - 3. several patterns for each prog and 'none'. This is used + or '' if no program is found. + 3. several patterns for each prog and not_found. This is used when different programs have different usages. If you do not - want 'none' entry to be added to the RC file, you can specify - an entry for each prog and use '' for the 'none' entry. + want not_found entry to be added to the RC file, you can specify + an entry for each prog and use '' for the not_found entry. + + not_found: the value that should be used instead of '' if no program + was found ''' - # one rc entry for each progs plus none entry + # one rc entry for each progs plus not_found entry if len(rc_entry) > 1 and len(rc_entry) != len(progs) + 1: - print "rc entry should have one item or item for each prog and none." + print "rc entry should have one item or item for each prog and not_found." sys.exit(2) print 'checking for ' + description + '...' ## print '(' + ','.join(progs) + ')', @@ -161,26 +164,30 @@ def checkProg(description, progs, rc_entry = [], path = [] ): print ' no' # write rc entries for 'not found' if len(rc_entry) > 0: # the last one. - addToRC(rc_entry[-1].replace('%%', 'none')) - return ['', 'none'] + addToRC(rc_entry[-1].replace('%%', not_found)) + return ['', not_found] + + +def checkViewer(description, progs, rc_entry = [], path = []): + ''' The same as checkProg, but for viewers and editors ''' + return checkProg(description, progs, rc_entry, path, not_found = 'auto') def checkLatex(): ''' Check latex, return lyx_check_config ''' # Find programs! Returned path is not used now - if os.name == 'nt' or sys.platform == 'cygwin': + if ((os.name == 'nt' or sys.platform == 'cygwin') and + checkProg('DVI to DTL converter', ['dv2dt']) != ['', ''] and + checkProg('DTL to DVI converter', ['dt2dv']) != ['', '']): # Windows only: DraftDVI - if checkProg('DVI to DTL converter', ['dv2dt']) != ['', 'none'] and checkProg('DTL to DVI converter', ['dt2dv']) != ['', 'none']: - converter_entry = r'''\converter latex dvi2 "%%" "latex" + converter_entry = r'''\converter latex dvi2 "%%" "latex" \converter dvi2 dvi "python $$s/scripts/clean_dvi.py $$i $$o" ""''' - else: - converter_entry = r'\converter latex dvi "%%" "latex"' else: converter_entry = r'\converter latex dvi "%%" "latex"' path, LATEX = checkProg('a Latex2e program', ['pplatex $$i', 'latex $$i', 'latex2e $$i'], rc_entry = [converter_entry]) # no latex - if LATEX != 'none': + if LATEX != '': # Check if latex is usable writeToFile('chklatex.ltx', ''' \\nonstopmode\\makeatletter @@ -202,20 +209,20 @@ def checkLatex(): def checkFormatEntries(): ''' Check all formats (\Format entries) ''' - checkProg('a Tgif viewer and editor', ['tgif'], - rc_entry = [ r'\Format tgif obj Tgif "" "%%" "%%"']) + checkViewer('a Tgif viewer and editor', ['tgif'], + rc_entry = [r'\Format tgif obj Tgif "" "%%" "%%"']) # - checkProg('a FIG viewer and editor', ['xfig'], - rc_entry = [ r'\Format fig fig FIG "" "%%" "%%"'] ) + checkViewer('a FIG viewer and editor', ['xfig'], + rc_entry = [r'\Format fig fig FIG "" "%%" "%%"']) # - checkProg('a Grace viewer and editor', ['xmgrace'], - rc_entry = [ r'\Format agr agr Grace "" "%%" "%%"'] ) + checkViewer('a Grace viewer and editor', ['xmgrace'], + rc_entry = [r'\Format agr agr Grace "" "%%" "%%"']) # - checkProg('a FEN viewer and editor', ['xboard -lpf $$i -mode EditPosition'], - rc_entry = [ r'\Format fen fen FEN "" "%%" "%%"' ]) + checkViewer('a FEN viewer and editor', ['xboard -lpf $$i -mode EditPosition'], + rc_entry = [r'\Format fen fen FEN "" "%%" "%%"']) # - path, iv = checkProg('a raster image viewer', ['xv', 'kview', 'gimp']) - path, ie = checkProg('a raster image editor', ['gimp']) + path, iv = checkViewer('a raster image viewer', ['xv', 'kview', 'gimp']) + path, ie = checkViewer('a raster image editor', ['gimp']) addToRC(r'''\Format bmp bmp BMP "" "%s" "%s" \Format gif gif GIF "" "%s" "%s" \Format jpg jpg JPEG "" "%s" "%s" @@ -228,9 +235,9 @@ def checkFormatEntries(): \Format xpm xpm XPM "" "%s" "%s"''' % \ (iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie) ) # - checkProg('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \ + checkViewer('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \ 'nedit', 'gedit', 'notepad'], - rc_entry = [ r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" + rc_entry = [r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" \Format asciiimage asc "Plain text (image)" "" "" "%%" \Format asciixfig asc "Plain text (Xfig output)" "" "" "%%" \Format dateout tmp "date (output)" "" "" "%%" @@ -245,25 +252,26 @@ def checkFormatEntries(): # #checkProg('a Postscript interpreter', ['gs'], # rc_entry = [ r'\ps_command "%%"' ]) - checkProg('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'], - rc_entry = [ r'''\Format eps eps EPS "" "%%" "" -\Format ps ps Postscript t "%%" ""''' ]) + checkViewer('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'], + rc_entry = [r'''\Format eps eps EPS "" "%%" "" +\Format ps ps Postscript t "%%" ""''']) # - checkProg('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \ + checkViewer('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \ 'xpdf', 'kpdf', 'kghostview'], - rc_entry = [ r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" + rc_entry = [r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" \Format pdf2 pdf "PDF (pdflatex)" F "%%" "" -\Format pdf3 pdf "PDF (dvipdfm)" m "%%" ""''' ]) +\Format pdf3 pdf "PDF (dvipdfm)" m "%%" ""''']) # - checkProg('a DVI previewer', ['xdvi', 'kdvi'], - rc_entry = [ r'\Format dvi dvi DVI D "%%" ""' ]) - if os.name == 'nt' or sys.platform == 'cygwin': + checkViewer('a DVI previewer', ['xdvi', 'kdvi'], + rc_entry = [r'\Format dvi dvi DVI D "%%" ""']) + if ((os.name == 'nt' or sys.platform == 'cygwin') and + checkProg('DVI to DTL converter', ['dv2dt']) != ['', ''] and + checkProg('DTL to DVI converter', ['dt2dv']) != ['', '']): # Windows only: DraftDVI - if checkProg('DVI to DTL converter', ['dv2dt']) != ['', 'none'] and checkProg('DTL to DVI converter', ['dt2dv']) != ['', 'none']: - addToRC(r'\Format dvi2 dvi DraftDVI "" "" ""') + addToRC(r'\Format dvi2 dvi DraftDVI "" ""') # - checkProg('a HTML previewer', ['mozilla file://$$p$$i', 'netscape'], - rc_entry = [ r'\Format html html HTML H "%%" ""' ]) + checkViewer('a HTML previewer', ['mozilla file://$$p$$i', 'netscape'], + rc_entry = [r'\Format html html HTML H "%%" ""']) # # entried that do not need checkProg addToRC(r'''\Format date "" "date command" "" "" "" @@ -394,11 +402,11 @@ def checkLinuxDoc(): \converter linuxdoc latex "sgml2latex $$i" "" \converter linuxdoc dvi "sgml2latex -o dvi $$i" "" \converter linuxdoc html "sgml2html $$i" ""''', - r'''\converter linuxdoc lyx "none" "" -\converter linuxdoc latex "none" "" -\converter linuxdoc dvi "none" "" -\converter linuxdoc html "none" ""''' ]) - if LINUXDOC != 'none': + r'''\converter linuxdoc lyx "" "" +\converter linuxdoc latex "" "" +\converter linuxdoc dvi "" "" +\converter linuxdoc html "" ""''' ]) + if LINUXDOC != '': return ('yes', 'true', '\\def\\haslinuxdoc{yes}') else: return ('no', 'false', '') @@ -412,10 +420,10 @@ def checkDocBook(): \converter docbook html "sgmltools -b html $$i" ""''', r'''\converter docbook dvi "db2dvi $$i" "" \converter docbook html "db2html $$i" ""''', - r'''\converter docbook dvi "none" "" -\converter docbook html "none" ""''']) + r'''\converter docbook dvi "" "" +\converter docbook html "" ""''']) # - if DOCBOOK != 'none': + if DOCBOOK != '': return ('yes', 'true', '\\def\\hasdocbook{yes}') else: return ('no', 'false', '') @@ -427,7 +435,7 @@ def checkOtherEntries(): rc_entry = [ r'\ascii_roff_command "groff -t -Tlatin1 $$FName"', r'\ascii_roff_command "tbl $$FName | nroff"', - r'\ascii_roff_command "none"' ]) + r'\ascii_roff_command ""' ]) checkProg('ChkTeX', ['chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38'], rc_entry = [ r'\chktex_command "%%"' ]) checkProg('a spellchecker', ['ispell'], diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 1d1d008a29..f6967af38e 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -1793,6 +1793,25 @@ odify . \end_layout +\begin_layout Standard +If the operating system has a default viewer associated to a format it is + used instead of the one you can define via the +\family sans +\bar under +T +\bar default +ools\SpecialChar \menuseparator + +\bar under +P +\bar default +references:Conversion +\family default + dialog. + This does currently only work in the Windows® port of LyX, but it is planned + to implement this feature on all other ports that can support it, too. +\end_layout + \begin_layout Standard Editors are like viewers: Each Format can have an Editor associated to it, and they can be altered via the diff --git a/src/format.C b/src/format.C index 79ba386604..1f555296fd 100644 --- a/src/format.C +++ b/src/format.C @@ -165,15 +165,15 @@ string fixCommand(string const & cmd, string const & ext, os::auto_open_mode mode) { // configure.py says we do not want a viewer/editor - if (cmd.empty()) - return cmd; + if (cmd.empty() || cmd == "none") + return string(); // Does the OS manage this format? if (os::canAutoOpenFile(ext, mode)) return "auto"; // if configure.py found nothing, clear the command - if (token(cmd, ' ', 0) == "none") + if (token(cmd, ' ', 0) == "auto") return string(); // use the command found by configure.py diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index eb4eb8b66d..d4fff05e79 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -2926,7 +2926,7 @@ void FormPreferences::SpellOptions::apply(LyXRC & rc) rc.isp_command = choice; #if 0 - // If spellchecker == "none", all other input set to off. + // If spellchecker == "", all other input set to off. if (fl_get_choice(dialog_->choice_spell_command) == 1) { rc.isp_use_alt_lang = false; rc.isp_alt_lang.erase(); @@ -3040,7 +3040,7 @@ bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob) // otherwise the function is called by an xforms CB via input(). #if 0 - // If spellchecker == "none", disable all input. + // If spellchecker == "", disable all input. if (!ob || ob == dialog_->choice_spell_command) { if (fl_get_choice(dialog_->choice_spell_command) == 1) { fl_deactivate_object(dialog_->check_alt_lang); @@ -3091,7 +3091,7 @@ void FormPreferences::SpellOptions::update(LyXRC const & rc) { int choice = 1; #if 0 - if (rc.isp_command == "none") + if (rc.isp_command == "" || rc.isp_command == "none") choice = 1; else if (rc.isp_command == "ispell") choice = 2; diff --git a/src/lyxrc.C b/src/lyxrc.C index 064b4caa05..99d21f8a9b 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -2072,7 +2072,7 @@ string const LyXRC::getDescription(LyXRCTags tag) break; case RC_ASCIIROFF_COMMAND: - str = _("Use to define an external program to render tables in plain text output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"none\" is specified, an internal routine is used."); + str = _("Use to define an external program to render tables in plain text output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"\" is specified, an internal routine is used."); break; case RC_ASCII_LINELEN: