Auteur: Laurent Bercot Datum: Aan: dng Onderwerp: Re: [Dng] OT: separate GUI from commands
On 27/05/2015 12:12, Hendrik Boom wrote: > I'm in the process of writing (yet) a(nother) editor and output formatter,
> and on reading this, I started to wonder -- just how could one separate
> a command-line version from the UI? I can see that the output
> formatter can be so separated (and very usefully), but the actual
> editing?
Maybe I'm misunderstanding the question, as I'm unfamiliar with the
internal of editors. But IIUC, an editor is, by definition, a user
interface, so the command-line / UI separation looks impossible or
irrelevant to me here.
However, there are still some separations that you can perform when
designing an editor. Right off the top of my head:
- Core functions vs. actual interface, which could be terminal-based
or X-based. Think vim vs. gvim, or emacs -nw.
- programmable editor commands vs. interface to enter those commands.
Think the sed engine in vi, or the LISP engine in emacs.
If you factor your work correctly, it should be trivial for a program
to get access to your editor commands via a library function call - and
you can make a command-line tool to wrap useful calls. Also, there could
be an editor-base package with very few dependencies, providing your main
library; and an editor-text package depending on editor-base and ncurses
(for instance), and an editor-gui package depending on editor-base and
your favorite graphical libraries. So text-only users wouldn't have to
install editor-gui and pull the whole plate of spaghetti.