Profiles.c reads ~/.dt/dtterm.profiles (else the config/ one), plain C with its test (make check: PASS test_profiles). A view with a profile is named profile_<name>; its colours are resources of that name, its font an Xft render table that TermView now passes on to the terminal, its command DtNsubprocessArgv unless -e gave one. Ctrl+Shift+T keeps the profile of the tab; the Window menu gets New Tab and New Tab with Profile through a hook in TermViewMenu.c; dtterm -profile NAME, and "Default" to start with. Tested on Xvfb with dtwm: -profile, a tab by key, a tab by the menu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
1.9 KiB
C
63 lines
1.9 KiB
C
/*
|
|
* Profiles.h -- MCDE: terminal profiles for dtterm (Profiles.c)
|
|
*
|
|
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
|
|
*
|
|
* C99 and POSIX only, no X: the parser has its own tests (test_profiles.c,
|
|
* make check). Tabs.c and DtTermMain.c turn a profile into a view.
|
|
*/
|
|
|
|
#ifndef _Dtterm_Profiles_h
|
|
#define _Dtterm_Profiles_h
|
|
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
#define MCDE_PROFILES_MAX 32
|
|
|
|
typedef struct {
|
|
char name[64]; /* as the menu shows it */
|
|
char font[96]; /* fontconfig family, "" = the default */
|
|
int fontSize; /* points, 0 = the default */
|
|
char foreground[32]; /* an X colour, "" = the default */
|
|
char background[32];
|
|
char command[512]; /* a shell command line, "" = the shell */
|
|
} McdeProfile;
|
|
|
|
/*
|
|
* Read profiles from FP into OUT (at most MAX). Returns the number read, or
|
|
* -1 with a message "LINE: what" in ERR. The format:
|
|
*
|
|
* # comment
|
|
* profile Dark
|
|
* font Hack 12
|
|
* foreground #d8d8d8
|
|
* background #1c1c1c
|
|
* command ksh -l
|
|
*
|
|
* A key before the first "profile" line, an unknown key, a repeated profile
|
|
* name or a font size outside 4..96 is an error.
|
|
*/
|
|
extern int McdeProfilesParse(FILE *fp, McdeProfile *out, int max,
|
|
char *err, size_t errlen);
|
|
|
|
/*
|
|
* The profiles of the user: the first of HOME/.dt/dtterm.profiles and the
|
|
* files in SYSFILES (NULL-terminated) that can be opened. An error is
|
|
* reported on stderr and gives no profiles.
|
|
*/
|
|
extern int McdeProfilesLoad(const char *home, const char *const *sysfiles,
|
|
McdeProfile *out, int max);
|
|
|
|
extern const McdeProfile *McdeProfileFind(const McdeProfile *p, int n,
|
|
const char *name);
|
|
|
|
/*
|
|
* The widget name of a view with profile NAME: "profile_" and NAME with
|
|
* every character outside [A-Za-z0-9_] as '_', so that it is one name in a
|
|
* resource specification. False if it does not fit.
|
|
*/
|
|
extern int McdeProfileWidgetName(const char *name, char *buf, size_t len);
|
|
|
|
#endif /* _Dtterm_Profiles_h */
|