Re: open_webpage function

From: Robert <ro....at.web.de>
Date: Sun, 28 Mar 2010 11:14:00 -0700 (PDT)

Hi Mitchell,

I've been using this and it appears that (at least on my setup) xdg-
open doesn't allow returning to Textadept without closing the browser
(in my case Firefox) - with gnome-open there is no problem.
So either we shouldn't use xdg-open or add an & to the command string.
'xdg-open "%s" &'

Sorry, I thought had tested this.
Robert

On Mar 23, 4:43 pm, mitchell <mforal.n....at.gmail.com> wrote:
> Robert,
>
> Thanks. Added to hg (r527).
>
> Mitchell
>
> > since not even Microsoft is forcing Internet Explorer on its users
> > anymore I think Textadept shouldn't either. ;-)
> > I came up with the following in menu.lua
>
> > local function open_webpage(url)
> >   local cmd
> >   if WIN32 then
> >     cmd = string.format('start \"\" \"%s\"', url)
> >     if io.popen(cmd) == nil then error(l.MENU_BROWSER_ERROR..url) end
> >   else
> >     if MAC then
> >       cmd = string.format('"%s" "file://%s"', 'open', url)
> >     else
> >       cmd = string.format('%s "%s"', 'xdg-open', url)
> >     end
> >     if os.execute(cmd) ~= 0 then error(l.MENU_BROWSER_ERROR..url) end
> >   end
> > end
>
> > In Windows there is the 'start' command to open files and webpages
> > with the 'default application'. For some reason it didn't work (for
> > me) with os.execute, so I used io.popen. I'm not sure if it's a
> > problem that there is no closing of this object.
> > The first option for 'start' is the name of the window or something so
> > the command is e.g.
> > start "" index.html
> > (I also tried rundll32 url.dll,FileProtocolHandler index.html, but
> > this command only worked from the command line not when I tried to
> > call it through Textadept.)
>
> > On Linux there are as well options like the Mac 'open' command: I
> > found xdg-open, x-www-browser and gnome-open.
> > I believe that xdg-open (part of the package xdg-utils) is the most
> > common. x-www-browser appears to be part of Debian, and gnome-open
> > comes with libgnome. I have it installed even though I don't have a
> > Gnome desktop.
> > They all seem to use different mechanisms to define the 'default
> > browser'.
>
> > If the Error message in locale.conf is changed to:
> > % core/ext/menu.lua
> > % "Error loading webpage:
> > MENU_BROWSER_ERROR "Error loading webpage: "
>
> > The error message will tell the user which file it tried to load:
> > /home/robert/textadept/core/ext/menu.lua:352: Error loading webpage: /
> > home/robert/textadept/doc/index.html
>
> > So if no xdg-open or other launcher is found, the user could copy and
> > paste the path into his browser of choice.
>
> > - Robert
Received on Sun 28 Mar 2010 - 14:14:00 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:40:34 EST