]> git.lyx.org Git - lyx.git/commitdiff
Change the semantics of 'none' and 'auto' viewers/editors: 'none' means now
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 25 May 2006 11:57:22 +0000 (11:57 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 25 May 2006 11:57:22 +0000 (11:57 +0000)
"Don't view/edit this format", and 'auto' means "Use the default viewer/editor".
* src/format.C
(fixCommand): Change semantics: "none" is equal to "", and "auto"
is removed if canAutoOpenFile returns false.

* src/frontends/xforms/FormPreferences.C
(FormPreferences::SpellOptions::apply): "none" -> ""

* src/lyxrc.C
(LyXRC::read): "none" -> ""

* lib/doc/Customization.lyx: Document the autoopen feature

* lib/configure.py
(checkProg): add optional not_found argument, defaulting to 'none'
(checkViewer): new, equivalent to checkProg with not_found = 'auto'
(checkFormatEntries): call checkViewer instead of checkProg for
viewers and editors

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13929 a592a061-630c-0410-9148-cb99ea01b6c8

lib/configure.py
lib/doc/Customization.lyx
src/format.C
src/frontends/xforms/FormPreferences.C
src/lyxrc.C

index 80b453511604470d113bb55eec90542582d191f7..b8862d332218a13c0fc54f18f3707d340d72b6db 100644 (file)
@@ -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 Tif 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  "%%"      ""      "document"''' ])
+  checkViewer('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'],
+    rc_entry = [r'''\Format eps        eps     EPS                    "" "%%"  ""      ""
+\Format ps         ps      Postscript             t  "%%"      ""      "document"'''])
   #
-  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  "%%" ""      "document"
+    rc_entry = [r'''\Format pdf        pdf    "PDF (ps2pdf)"          P  "%%"  ""      "document"
 \Format pdf2       pdf    "PDF (pdflatex)"        F  "%%"      ""      "document"
-\Format pdf3       pdf    "PDF (dvipdfm)"         m  "%%"      ""      "document"''' ])
+\Format pdf3       pdf    "PDF (dvipdfm)"         m  "%%"      ""      "document"'''])
   #
-  checkProg('a DVI previewer', ['xdvi', 'kdvi'],
-    rc_entry = [ r'\Format dvi        dvi     DVI                    D  "%%"   ""      "document"' ])
-  if os.name == 'nt' or sys.platform == 'cygwin':
+  checkViewer('a DVI previewer', ['xdvi', 'kdvi'],
+    rc_entry = [r'\Format dvi        dvi     DVI                    D  "%%"    ""      "document"'])
+  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               "" ""        "document"')
+    addToRC(r'\Format dvi2       dvi     DraftDVI               ""     ""      "document"')
   #
-  checkProg('a HTML previewer', ['mozilla file://$$p$$i', 'netscape'],
-    rc_entry = [ r'\Format html       html    HTML                   H  "%%"   ""      "document"' ])
+  checkViewer('a HTML previewer', ['mozilla file://$$p$$i', 'netscape'],
+    rc_entry = [r'\Format html       html    HTML                   H  "%%"    ""      "document"'])
   #
   # 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'],
index c674197fd47d44a4d0f769db6809a734ead6eb10..15cbb4b46bf0753d615ad77d25f8e70d4cf33c0f 100644 (file)
@@ -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 
index 3cb3926f78d1cae0fe25a8846b7952e5caeea3ea..099402c872c040ccae8225bb78cee9411a6e8a16 100644 (file)
@@ -176,7 +176,7 @@ string fixCommand(string const & cmd, string const & ext,
                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
index 14f0c4b0a7d35f3144ab2489d4c3a7d2bd16b1b2..f7f064f11cb97f8057a702677ea19ad75fd8a443 100644 (file)
@@ -2930,7 +2930,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();
@@ -3044,7 +3044,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);
@@ -3095,7 +3095,7 @@ void FormPreferences::SpellOptions::update(LyXRC const & rc)
 {
        int choice = 1;
 #if 0
-       if (rc.isp_command == "none")
+       if (rc.isp_command == "")
                choice = 1;
        else if (rc.isp_command == "ispell")
                choice = 2;
index 3b7a3d408a305822c658941f65d856eabaee6d72..316f64796ebca21ea01765c521495eaa58741844 100644 (file)
@@ -1052,8 +1052,7 @@ int LyXRC::read(LyXLex & lexrc)
                        if (lexrc.next()) {
                                flags = lexrc.getString();
                        }
-                       if (command.empty()
-                           || token(command, ' ', 0) == "none") {
+                       if (command.empty()) {
                                converters.erase(from, to);
                        } else {
                                converters.add(from, to, command, flags);
@@ -2146,7 +2145,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: