[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
--xrm on Windows
From: |
Juanma Barranquero |
Subject: |
--xrm on Windows |
Date: |
Wed, 13 Nov 2002 17:56:32 +0100 |
The following very crude patch is the beginning of a poor man's
emulation of xrdb resources on Windows. It allows to pass --xrm
arguments to Emacs, which override the equivalent registry entries.
For example, with HKLM\Software\GNU\Emacs\Emacs.Geometry = "100x40" and
runing Emacs with
emacs --xrm "Emacs.Geometry:40x20"
it would start on a 40x20 frame, as expected.
Questions:
1.- Which format should be used for --xrm arguments? The same as for
xrdb ones?
2.- Could someone give a pointer to good doc about the format of X
resources?
3.- Can someone suggest a reasonable behavior for Class.Resource vs.
Class*Resource vs. Class*resource vs. ...?
4.- Any other comment/suggestion/implementation idea/functionality?
Thanks,
/L/e/k/t/u
Index: w32fns.c
===================================================================
RCS file: /cvs/emacs/src/w32fns.c,v
retrieving revision 1.186
diff -u -2 -r1.186 w32fns.c
--- w32fns.c 23 Oct 2002 16:55:07 -0000 1.186
+++ w32fns.c 13 Nov 2002 16:50:04 -0000
@@ -3059,5 +3059,5 @@
strcat (name_key, SDATA (attribute));
- value = x_get_string_resource (Qnil,
+ value = x_get_string_resource (check_x_display_info (Qnil)->xrdb,
name_key, class_key);
@@ -3090,5 +3090,6 @@
sprintf (class_key, "%s.%s", EMACS_CLASS, class);
- return x_get_string_resource (sf, name_key, class_key);
+ return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
+ name_key, class_key);
}
Index: w32reg.c
===================================================================
RCS file: /cvs/emacs/src/w32reg.c,v
retrieving revision 1.7
diff -u -2 -r1.7 w32reg.c
--- w32reg.c 2 May 1999 10:28:55 -0000 1.7
+++ w32reg.c 13 Nov 2002 16:50:04 -0000
@@ -95,4 +95,19 @@
}
+char *
+w32_get_rdb_resource (rdb, resource)
+ char **rdb;
+ char *resource;
+{
+ int i;
+ int len = strlen (resource);
+
+ for (i = 0; rdb[i] != NULL; i++)
+ if ((rdb[i][len] == ':') &&
+ (! strncmp (rdb[i], resource, len)))
+ return (&rdb[i][len + 1]);
+ return NULL;
+}
+
/* Retrieve the string resource specified by NAME with CLASS from
database RDB. */
@@ -100,7 +115,17 @@
char *
x_get_string_resource (rdb, name, class)
- int rdb;
+ char **rdb;
char *name, *class;
{
+ char *resource;
+
+ if (rdb)
+ {
+ if (resource = w32_get_rdb_resource (rdb, name))
+ return (resource);
+ if (resource = w32_get_rdb_resource (rdb, class))
+ return (resource);
+ }
+
return (w32_get_string_resource (name, class, REG_SZ));
}
Index: w32term.c
===================================================================
RCS file: /cvs/emacs/src/w32term.c,v
retrieving revision 1.170
diff -u -2 -r1.170 w32term.c
--- w32term.c 8 Nov 2002 08:42:03 -0000 1.170
+++ w32term.c 13 Nov 2002 16:50:05 -0000
@@ -11071,4 +11071,42 @@
}
+char **
+w32_make_rdb (xrm_option)
+ char *xrm_option;
+{
+ char *rbuf[20];
+ int len = strlen(xrm_option);
+
+ char *option = (char *) alloca (len + 2);
+ char *start = option;
+ char *end;
+
+ int n = 0;
+ int size;
+
+ char **rdb;
+
+ strcpy (option, xrm_option);
+ option[len] = '\n';
+ option[len + 1] = 0;
+
+ while (*start) {
+ end = strchr(start, '\n');
+ rbuf[n] = xmalloc (end - start + 1);
+ *end = 0;
+ strcpy (rbuf[n++], start);
+ start = end + 1;
+ end = start;
+ }
+
+ size = (n + 1) * sizeof (char *);
+
+ rdb = xmalloc (size);
+ memcpy (rdb, rbuf, size);
+ rdb[n] = NULL;
+
+ return rdb;
+}
+
struct w32_display_info *
w32_term_init (display_name, xrm_option, resource_name)
@@ -11088,20 +11126,11 @@
}
- {
- int argc = 0;
- char *argv[3];
-
- argv[0] = "";
- argc = 1;
- if (xrm_option)
- {
- argv[argc++] = "-xrm";
- argv[argc++] = xrm_option;
- }
- }
-
w32_initialize_display_info (display_name);
dpyinfo = &one_w32_display_info;
+
+ /* Put the rdb where we can find it in a way that works on
+ all versions. */
+ dpyinfo->xrdb = xrm_option ? w32_make_rdb (xrm_option) : NULL;
/* Put this display on the chain. */
Index: w32term.h
===================================================================
RCS file: /cvs/emacs/src/w32term.h,v
retrieving revision 1.49
diff -u -2 -r1.49 w32term.h
--- w32term.h 30 Aug 2002 13:20:36 -0000 1.49
+++ w32term.h 13 Nov 2002 16:50:05 -0000
@@ -135,4 +135,7 @@
Cursor vertical_scroll_bar_cursor;
+ /* Resource data base */
+ char **xrdb;
+
/* color palette information. */
int has_palette;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- --xrm on Windows,
Juanma Barranquero <=