[gvim: vim variant?]
Richard L. Hamilton
rlhamil at smart.net
Sat Mar 25 04:36:05 UTC 2023
As an aside, perhaps the best example of using X resources to good effect to allow a user to adjust a program's behavior and appearance might be the xephem program (there's a port for that!), which uses Motif, and has GUI settings that effectively change X resources, which it can then save for subsequent runs.
Otherwise one would end up editing an .Xdefaults file by hand, putting in mysterious incantations mostly by luck, unless one had studied the source (or built libXt and libXaw (Athena Widgets) or libXm (Motif) with editres support, so one could explore the resources and change them on the fly).
Properly compiled and with LD_PRELOAD pointing to the resulting .so or .dylib, the following may add editres suport on the fly to a Motif program. Last I checked, it worked on Solaris, and I think I've used it on macOS, but I haven't tried that in a long time; and right now I don't think I have a copy of gvim built to use Motif. (I almost forgot I had this, so I'm not particularly prepared to answer questions about it.)
/* Here's a way on systems with ELFish dynamic linking to get
* editres support into source-less binaries, as long as they're
* dynamically linked with libXt, and are not setuid or setgid.
* Compile this however you must to produce a shared object,
* and set the LD_PRELOAD environment variable to point to said
* shared object, then start your binary, and enjoy.
*
* using gcc on Solaris, one might do something like:
* gcc -I$(OPENWINHOME)/include -mno-app-regs -fPIC -G -c use_editres.c
* ld -G -L$(OPENWINHOME)/lib -R$(OPENWINHOME)/lib -lXt -lXmu -o use_editres.so
*
* env LD_PRELOAD=./use_editres.so program [args]
*
* This works for me with CDE binaries on Solaris, and I'd like to
* think that with at most a few changes it would also work on Linux.
*
* It works by trapping access to the internal (but global) functions
* that at least R5 through R6.3 libXt uses to implement the four
* shell widget creation functions (two each traditional and varargs),
* calling the corresponding real functions, and if they successfully
* returned a widget, adding the editres event handler to those widgets,
* and returning the value that the real function returned.
*
* This is modelled on various similar examples by others that use
* LD_PRELOAD to modify the behavior of pre-existing routines, as well
* as the description in the Motif FAQ of how to alter the source of
* an application to use editres with Motif.
*
* This is only the 2nd X related program I've written, (there's enough
* command line and batch stuff to keep me from being bored, and I'm a
* command line kinda guy), so if it has problems that I'm not aware of,
* let me know - I may not know how to fix them, but would at least want to
* learn to recognize them.
*
* R Hamilton, 19 June 98 rlhamil at smart.net
*/
#include <dlfcn.h>
#include <X11/Intrinsic.h>
#include <X11/Xmu/Editres.h>
typedef void *XtTypedArgList; /* bogus, but gets around stuff hidden in
private libXt include file */
Widget _XtCreatePopupShell(name, widget_class, parent, args, num_args,
typed_args, num_typed_args)
String name;
WidgetClass widget_class;
Widget parent;
ArgList args;
Cardinal num_args;
XtTypedArgList typed_args;
Cardinal num_typed_args;
{
static Widget (*_XtCreatePopupShell_Real)();
Widget retval;
if (_XtCreatePopupShell_Real==NULL)
_XtCreatePopupShell_Real = (Widget (*) ())
dlsym(RTLD_NEXT, "_XtCreatePopupShell");
if ((retval = _XtCreatePopupShell_Real(name,widget_class,parent,args,
num_args, typed_args,num_typed_args)) != NULL)
XtAddEventHandler(retval, (EventMask)0, True,
_XEditResCheckMessages, NULL);
return retval;
}
Widget _XtAppCreateShell(name, class, widget_class, display, args, num_args,
typed_args, num_typed_args)
String name, class;
WidgetClass widget_class;
Display* display;
ArgList args;
Cardinal num_args;
XtTypedArgList typed_args;
Cardinal num_typed_args;
{
static Widget (*_XtAppCreateShell_Real)();
Widget retval;
if (_XtAppCreateShell_Real==NULL)
_XtAppCreateShell_Real = (Widget (*) ())
dlsym(RTLD_NEXT, "_XtAppCreateShell");
if ((retval = _XtAppCreateShell_Real(name,class,widget_class,display,
args, num_args, typed_args,num_typed_args)) != NULL)
XtAddEventHandler(retval, (EventMask)0, True,
_XEditResCheckMessages, NULL);
return retval;
}
> On Mar 24, 2023, at 23:51, raf via macports-users <macports-users at lists.macports.org> wrote:
>
> On Fri, Mar 24, 2023 at 05:12:33PM +0000, Maxim Abalenkov <maxim.abalenkov at gmail.com> wrote:
>
>> Dear all,
>>
>> How are you? I hope all is well with you. I need your help please. I
>> mostly work in the terminal and use vim as my text editor. But
>> occasionally I need a text editor with a graphical user interface. I
>> have heard good things about ‘gvim’. Would you please tell me, how
>> to install ‘gvim’ with MacPorts? Is it one of the ‘vim’ port’s
>> variants? Executing
>>
>> port variants vim
>>
>> returns multiple options:
>>
>> * athena: Build GUI version using Athena widgets
>> * gtk2: Build GUI version using GTK 2.x widgets
>> * gtk3: Build GUI version using GTK 3.x widgets
>> * motif: Build GUI version with Motif widgets
>>
>> Can you please tell me, how do they differ and which one would you
>> recommend? Thank you for your help and have a good weekend ahead!
>>
>> —
>> Best wishes,
>> Maxim
>>
>> Maxim Abalenkov \\ maxim.abalenkov at gmail.com
>> +44 7 486 486 505 \\ www.maxim.abalenkov.uk
>
> Hi,
>
> I think that Vim has abandoned Athena widgets in favour
> of Motif. They are very similar. Both look old compared
> to gtk2/gtk3 but have the advantage that they respect
> Xresources settings. This matters if you have
> configured gvim with Xresources, for example to specify
> a forced window size and location, rather than having
> the window manager decide or force the user to manually
> place windows every time.
>
> So, if you want to have your gvim window appear in the
> same location every time, choose motif. If not,
> probably choose gtk3. I don't know anything about
> differences between gtk2 and gtk3. However, all of
> these require X11. If you don't want X11, there is
> another choice: MacVim which is a port that uses a
> macOS native GUI library. But that's not a good choice
> if you use X11 in full screen mode.
>
> I use an Athena (or sometimes Motif) gvim that I
> compiled myself for use in full screen X11, and MacVim
> for use in the macOS native desktop.
>
> cheers,
> raf
>
More information about the macports-users
mailing list