Loading ...
Sorry, an error occurred while loading the content.

Re: Vim themes without a terminal

Expand Messages
  • Tony Mechelynck
    ... If your Vim binary is compiled with GUI (see the first few lines of the output of :version ), try starting it as gvim or vim -g rather than plain
    Message 1 of 11 , Jan 5, 2008
    • 0 Attachment
      Cliff Stanford wrote:
      > -----BEGIN PGP SIGNED MESSAGE-----
      > Hash: SHA1
      >
      > For my subversion viewing site, I am using vim in a perl script to
      > venerate coloured output for display on a website.
      >
      > For an example, take a look at
      > http://svn.may.be/svnvi.pl?file=Rational.cs&repos=Rationals&path=/trunk/Rational
      > which is a c# source file.
      >
      > To do this, I call:
      >
      > vim -fXNn -u /dev/null/ -i NONE -c 'let html_use_css=1' \
      > - -c 'let use_xhtml=1' -c 'let html_use_encoding=utf8' \
      > - -c 'let html_ignore_folding=1' -c 'set number' \
      > - -c 'colorscheme simple256' -c 'syntax on' \
      > - -c 'TOhtml' -c "wq! $output" -c 'q!'
      >
      > The problem is that whichever colourscheme I use, it will always select
      > the term eight-colour version rather than the gui one that I would like
      > to use. Even the cterm 16-colour version would be an improvement.
      >
      > Is there any way anyone can think to force the above script to select
      > the gui colourset for the purposes of the TOhtml command?
      >
      > Regards,
      > Cliff.
      > - --
      > Cliff Stanford
      > Might Limited +44 845 0045 666 (Office)
      > Suite 67, Dorset House +44 7973 616 666 (Mobile)
      > Duke Street, Chelmsford, CM1 1TB

      If your Vim binary is compiled with GUI (see the first few lines of the output
      of ":version"), try starting it as "gvim" or "vim -g" rather than plain "vim"
      (also don't include the -X switch). You will then get a GUI rather than a
      terminal-bound session, and TOhtml (which always sets the HTML to show the
      colours you are currently displaying) will use whatever GUI colours are
      defined by your current colorscheme (or the default GUI colours, if you aren't
      using any colorscheme).

      (It _is_ permissible to run the GUI in batch mode.)


      Best regards,
      Tony.
      --
      "I do not know myself, and God forbid that I should."
      -- Johann Wolfgang von Goethe

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Cliff Stanford
      ... Hash: SHA1 ... The application gvim lost its connection to the display localhost:10.0; most likely the X server was shut down or you killed/destroyed the
      Message 2 of 11 , Jan 5, 2008
      • 0 Attachment
        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        Tony Mechelynck wrote:

        > If your Vim binary is compiled with GUI (see the first few lines of the output
        > of ":version"), try starting it as "gvim" or "vim -g" rather than plain "vim"

        The application 'gvim' lost its connection to the display localhost:10.0;
        most likely the X server was shut down or you killed/destroyed
        the application.

        > (It _is_ permissible to run the GUI in batch mode.)

        Yes but I'm trying to find a way to run it without a terminal.

        Cliff.
        - --
        Cliff Stanford
        Might Limited +44 845 0045 666 (Office)
        Suite 67, Dorset House +44 7973 616 666 (Mobile)
        Duke Street, Chelmsford, CM1 1TB
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.5 (MingW32)

        iD8DBQFHf7dhfNTx9pWyKfwRAmMJAKDt+jAWkcqtDaKv9mUUZq8MRwcSFgCgrnfR
        0fCMpuCzZsRTh3knZcoQwXM=
        =My5u
        -----END PGP SIGNATURE-----


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Tony Mechelynck
        Cliff Stanford wrote: [...] ... [...] You mean with neither a GUI nor a console? You can t. You can use an undisplayed terminal, but you cannot run Vim (nor
        Message 3 of 11 , Jan 5, 2008
        • 0 Attachment
          Cliff Stanford wrote:
          [...]
          > Yes but I'm trying to find a way to run it without a terminal.
          [...]

          You mean with neither a GUI nor a console? You can't. You can use an
          undisplayed terminal, but you cannot run Vim (nor can you run most programs,
          including the shell) with no terminal at all.

          If you want to use 2html.vim to generate GUI colors, you must run GUI vim
          (gvim), which in turn means, on Unix/Linux systems, that an X11 server must be
          available to the program, even if that X server is not currently displaying on
          a visible screen (for instance because it uses /dev/tty7, shown to X11 clients
          as :0, and you're currently working with /dev/tty2).


          Best regards,
          Tony.
          --
          ARIES (Mar 21 - Apr 19)
          You are the pioneer type and hold most people in contempt. You
          are quick tempered, impatient, and scornful of advice. You are
          not very nice.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • A.Politz
          ... You could make the script believe that the gui is running. This should work, because the synIDtrans function, which is used by the script to determine
          Message 4 of 11 , Jan 5, 2008
          • 0 Attachment
            Cliff Stanford wrote:

            >
            >The problem is that whichever colourscheme I use, it will always select
            >the term eight-colour version rather than the gui one that I would like
            >to use. Even the cterm 16-colour version would be an improvement.
            >
            >Is there any way anyone can think to force the above script to select
            >the gui colourset for the purposes of the TOhtml command?
            >
            >
            You could make the script believe that the gui is running. This
            should work, because the 'synIDtrans' function, which is used by the
            script to determine the colors, is able to retrieve the gui colors
            w/o it actually running.

            From syntax/2html.vim:9

            -------------------%<-----------------
            " When not in gui we can only guess the colors.
            if has("gui_running")
            let s:whatterm = "gui"
            else
            let s:whatterm = "cterm"
            -------------------%<-----------------

            Copy it to your ~.vim and change it maybe to this :
            -------------------%<-----------------

            " When not in gui we can only guess the colors.
            if has("gui_running") || exists('g:html_pretend_gui') && html_pretend_gui
            let s:whatterm = "gui"
            else
            let s:whatterm = "cterm"
            -------------------%<-----------------

            Quick test worked for me.

            -ap


            --
            Ich hab geträumt, der Krieg wär vorbei.


            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Cliff Stanford
            ... Hash: SHA1 ... No, I d tried this. The problem is that synIDattr() appears not to work with the last parameter set to gui whilst not actually in the
            Message 5 of 11 , Jan 7, 2008
            • 0 Attachment
              -----BEGIN PGP SIGNED MESSAGE-----
              Hash: SHA1

              A.Politz wrote:

              > Copy it to your ~.vim and change it maybe to this :
              > -------------------%<-----------------
              >
              > " When not in gui we can only guess the colors.
              > if has("gui_running") || exists('g:html_pretend_gui') && html_pretend_gui
              > let s:whatterm = "gui"
              > else
              > let s:whatterm = "cterm"
              > -------------------%<-----------------
              >
              > Quick test worked for me.

              No, I'd tried this. The problem is that synIDattr() appears not to work
              with the last parameter set to "gui" whilst not actually in the gui.

              For example:

              " Find out the background and foreground color.
              let s:fgc = s:HtmlColor(synIDattr(hlID("Normal"), "fg#", s:whatterm))
              let s:bgc = s:HtmlColor(synIDattr(hlID("Normal"), "bg#", s:whatterm))
              if s:fgc == ""
              let s:fgc = ( &background == "dark" ? "#ffffff" : "#000000" )
              endif

              s:fgc is always "" if s:whatterm is "gui" (except when run from the gui).

              What am I missing?

              Thanks,
              Cliff.

              - --
              Cliff Stanford
              Might Limited +44 845 0045 666 (Office)
              Suite 67, Dorset House +44 7973 616 666 (Mobile)
              Duke Street, Chelmsford, CM1 1TB
              -----BEGIN PGP SIGNATURE-----
              Version: GnuPG v1.4.5 (MingW32)

              iD8DBQFHgh8afNTx9pWyKfwRArvDAKC1W9BkxPMnyKINnVrOSVFZUW7NwACfYxCA
              8rRL+tGBh3o7UYCiZHdASdQ=
              =9QIF
              -----END PGP SIGNATURE-----


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Matt Wozniski
              ... If vim isn t compiled with gui support, the gui color information isn t stored, to save memory. So, the commands to access it plain won t work (try
              Message 6 of 11 , Jan 7, 2008
              • 0 Attachment
                On Jan 7, 2008 12:53 PM, A.Politz wrote:
                >
                > Cliff Stanford wrote:
                >
                > >No, I'd tried this. The problem is that synIDattr() appears not to work
                > > with the last parameter set to "gui" whilst not actually in the gui.
                > >
                > >For example:
                > >
                > >" Find out the background and foreground color.
                > >let s:fgc = s:HtmlColor(synIDattr(hlID("Normal"), "fg#", s:whatterm))
                > >let s:bgc = s:HtmlColor(synIDattr(hlID("Normal"), "bg#", s:whatterm))
                > >if s:fgc == ""
                > > let s:fgc = ( &background == "dark" ? "#ffffff" : "#000000" )
                > >endif
                > >
                > >s:fgc is always "" if s:whatterm is "gui" (except when run from the gui).
                > >
                > >What am I missing?
                > >
                >
                > I don't know it works for me. Maybe it is system dependend ?
                > ( Have gtk2-vim ).Or yours is not compiled with gui ?
                > The help file is not very specific about what does and
                > what doesn't work here ( "invalid value" ).
                >
                > Maybe I went insane without noticing ? No I would.

                If vim isn't compiled with gui support, the gui color information
                isn't stored, to save memory. So, the commands to access it plain
                won't work (try :highlight, you'll notice that even though the scheme
                set gui colors, they don't appear in the output). So, either use a
                larger vim build, or (if you have gvim and don't want to recompile)
                you can launch gvim with argv[0] set to 'vim'. zsh lets you use
                "ARGV0=vim gvim"; but I don't know of an easier way to do it in bash
                than just using "ln -s `which gvim` ./vim; ./vim".

                ~Matt

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • A.Politz
                ... I don t know it works for me. Maybe it is system dependend ? ( Have gtk2-vim ).Or yours is not compiled with gui ? The help file is not very specific about
                Message 7 of 11 , Jan 7, 2008
                • 0 Attachment
                  Cliff Stanford wrote:

                  >-----BEGIN PGP SIGNED MESSAGE-----
                  >Hash: SHA1
                  >
                  >A.Politz wrote:
                  >
                  >
                  >
                  >>Copy it to your ~.vim and change it maybe to this :
                  >>-------------------%<-----------------
                  >>
                  >>" When not in gui we can only guess the colors.
                  >>if has("gui_running") || exists('g:html_pretend_gui') && html_pretend_gui
                  >> let s:whatterm = "gui"
                  >>else
                  >> let s:whatterm = "cterm"
                  >>-------------------%<-----------------
                  >>
                  >>Quick test worked for me.
                  >>
                  >>
                  >
                  >No, I'd tried this. The problem is that synIDattr() appears not to work
                  > with the last parameter set to "gui" whilst not actually in the gui.
                  >
                  >For example:
                  >
                  >" Find out the background and foreground color.
                  >let s:fgc = s:HtmlColor(synIDattr(hlID("Normal"), "fg#", s:whatterm))
                  >let s:bgc = s:HtmlColor(synIDattr(hlID("Normal"), "bg#", s:whatterm))
                  >if s:fgc == ""
                  > let s:fgc = ( &background == "dark" ? "#ffffff" : "#000000" )
                  >endif
                  >
                  >s:fgc is always "" if s:whatterm is "gui" (except when run from the gui).
                  >
                  >What am I missing?
                  >
                  >
                  >
                  >
                  I don't know it works for me. Maybe it is system dependend ?
                  ( Have gtk2-vim ).Or yours is not compiled with gui ?
                  The help file is not very specific about what does and
                  what doesn't work here ( "invalid value" ).

                  Maybe I went insane without noticing ? No I would.

                  -ap

                  --
                  Ich hab geträumt, der Krieg wär vorbei.


                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Gary Johnson
                  ... You can also launch it as gvim -v Regards, Gary --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use
                  Message 8 of 11 , Jan 7, 2008
                  • 0 Attachment
                    On 2008-01-07, Matt Wozniski <mjw@...> wrote:


                    > So, either use a larger vim build, or (if you have gvim and don't
                    > want to recompile) you can launch gvim with argv[0] set to 'vim'.
                    > zsh lets you use "ARGV0=vim gvim"; but I don't know of an easier
                    > way to do it in bash than just using "ln -s `which gvim` ./vim;
                    > ./vim".

                    You can also launch it as

                    gvim -v

                    Regards,
                    Gary


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • Matt Wozniski
                    ... Heh, I knew about vim -g and figured there had to be an equivalent, but couldn t find it. Thanks for pointing that out! :) ~Matt
                    Message 9 of 11 , Jan 7, 2008
                    • 0 Attachment
                      On Jan 7, 2008 1:10 PM, Gary Johnson wrote:
                      > You can also launch it as
                      >
                      > gvim -v

                      Heh, I knew about "vim -g" and figured there had to be an equivalent,
                      but couldn't find it. Thanks for pointing that out! :)

                      ~Matt

                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_use" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • Cliff Stanford
                      ... Hash: SHA1 ... No I did! ... Thank you both. I m using the default install of vim/gvim from Fedora 7 and had forgotten that gvim and vim were not linked.
                      Message 10 of 11 , Jan 7, 2008
                      • 0 Attachment
                        -----BEGIN PGP SIGNED MESSAGE-----
                        Hash: SHA1

                        Matt Wozniski wrote:

                        > On Jan 7, 2008 12:53 PM, A.Politz wrote:
                        >>
                        >> Maybe I went insane without noticing ? No I would.

                        No I did!

                        > If vim isn't compiled with gui support, the gui color information
                        > isn't stored, to save memory.

                        Thank you both. I'm using the default install of vim/gvim from Fedora 7
                        and had forgotten that gvim and vim were not linked.

                        Works perfectly with gvim -v (thanks Gary too).

                        Excuse me now while I go and bang my head on the wall. I've been
                        struggling with this on and off for ages!

                        Thanks again,
                        Cliff.

                        - --
                        Cliff Stanford
                        Might Limited +44 845 0045 666 (Office)
                        Suite 67, Dorset House +44 7973 616 666 (Mobile)
                        Duke Street, Chelmsford, CM1 1TB
                        -----BEGIN PGP SIGNATURE-----
                        Version: GnuPG v1.4.5 (MingW32)

                        iD8DBQFHgpGffNTx9pWyKfwRAqE/AJ99yex+tXxD/VzgP/2uTVDzzSyGpQCeMthA
                        1LF7xypO/2pHUc86CMJSixA=
                        =bLuZ
                        -----END PGP SIGNATURE-----


                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_use" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      Your message has been successfully submitted and would be delivered to recipients shortly.