Load X resources from a settings file like other programs on Haiku
* doc/emacs/haiku.texi (Haiku Basics): Document how X resources are discovered on Haiku. * src/haiku_support.cc (class Emacs): Load settings file. (be_find_setting): New function. * src/haiku_support.h (be_find_setting): New prototype. * src/haikuterm.c (get_string_resource): Look in the settings file if there's nothing in the in-memory resource database.
This commit is contained in:
parent
cda372bfc2
commit
b1f33ff951
4 changed files with 58 additions and 0 deletions
|
@ -96,6 +96,19 @@ the nil value, and Emacs will use its own implementation of tooltips.
|
|||
the menu bar, so help text in the menu bar will display in the echo
|
||||
area instead.
|
||||
|
||||
@cindex X resources on Haiku
|
||||
Unlike the X window system, Haiku does not have a system-wide
|
||||
resource database. Since many important options are are specified via
|
||||
X resources (@pxref{X Resources}), an emulation is provided: upon
|
||||
startup, Emacs will load a file named @file{GNU Emacs} inside the user
|
||||
configuration directory (normally @file{/boot/home/config/settings}),
|
||||
which should be a flattened system message where keys and values are
|
||||
both strings, and correspond to attributes and their values
|
||||
respectively.
|
||||
|
||||
You can create such a file with the tool @code{xmlbmessage}, which is
|
||||
free software.
|
||||
|
||||
@subsection What to do when Emacs crashes
|
||||
@cindex crashes, Haiku
|
||||
@cindex haiku debugger
|
||||
|
|
|
@ -291,8 +291,25 @@ map_normal (uint32_t kc, uint32_t *ch)
|
|||
class Emacs : public BApplication
|
||||
{
|
||||
public:
|
||||
BMessage settings;
|
||||
bool settings_valid_p = false;
|
||||
|
||||
Emacs () : BApplication ("application/x-vnd.GNU-emacs")
|
||||
{
|
||||
BPath settings_path;
|
||||
|
||||
if (find_directory (B_USER_SETTINGS_DIRECTORY, &settings_path) != B_OK)
|
||||
return;
|
||||
|
||||
settings_path.Append (PACKAGE_NAME);
|
||||
|
||||
BEntry entry (settings_path.Path ());
|
||||
BFile settings_file (&entry, B_READ_ONLY | B_CREATE_FILE);
|
||||
|
||||
if (settings.Unflatten (&settings_file) != B_OK)
|
||||
return;
|
||||
|
||||
settings_valid_p = true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3131,3 +3148,23 @@ BWindow_set_override_redirect (void *window, bool override_redirect_p)
|
|||
w->UnlockLooper ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Find a resource by the name NAME inside the settings file. The
|
||||
string returned is in UTF-8 encoding, and will stay allocated as
|
||||
long as the BApplication (a.k.a display) is alive. */
|
||||
const char *
|
||||
be_find_setting (const char *name)
|
||||
{
|
||||
Emacs *app = (Emacs *) be_app;
|
||||
const char *value;
|
||||
|
||||
/* Note that this is thread-safe since the constructor of `Emacs'
|
||||
runs in the main thread. */
|
||||
if (!app->settings_valid_p)
|
||||
return NULL;
|
||||
|
||||
if (app->settings.FindString (name, 0, &value) != B_OK)
|
||||
return NULL;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -855,6 +855,9 @@ extern "C"
|
|||
extern void
|
||||
BWindow_set_override_redirect (void *window, bool override_redirect_p);
|
||||
|
||||
extern const char *
|
||||
be_find_setting (const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern void *
|
||||
find_appropriate_view_for_draw (void *vw);
|
||||
|
|
|
@ -107,6 +107,8 @@ haiku_delete_terminal (struct terminal *terminal)
|
|||
static const char *
|
||||
get_string_resource (void *ignored, const char *name, const char *class)
|
||||
{
|
||||
const char *native;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
|
@ -115,6 +117,9 @@ get_string_resource (void *ignored, const char *name, const char *class)
|
|||
if (!NILP (lval))
|
||||
return SSDATA (XCDR (lval));
|
||||
|
||||
if ((native = be_find_setting (name)))
|
||||
return native;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue