commit - e910767243f781e99a99660bc36416b5905782f2
commit + 8b92991808127e109d39ff91f72dc67a5a3d93f5
blob - 28365607b0d283fc703da2a287dedeab4845386e
blob + 8cb4b79f1fb61189a557dd51b549b8b58fbe5f9f
--- mymenu.c
+++ mymenu.c
# define VERSION "unknown"
#endif
+// Comfy
#define nil NULL
+
#define resname "MyMenu"
#define resclass "mymenu"
cannot_allocate_memory; \
}
+// The possible state of the event loop.
enum state {LOOPING, OK, ERR};
+// for the drawing-related function. The text to be rendered could be
+// the prompt, a completion or a highlighted completion
enum text_type {PROMPT, COMPL, COMPL_HIGH};
+// These are the possible action to be performed after user input.
enum action {
EXIT,
CONFIRM,
#endif
};
+// A simple linked list to store the completions.
struct completions {
char *completion;
bool selected;
if (c != nil)
c->selected = true;
return c;
-
- /* if (n || c->selected) { // select the last one */
- /* c->selected = false; */
- /* while (cc != nil) { */
- /* if (cc->next == nil) { */
- /* cc->selected = true; */
- /* return cc; */
- /* } */
- /* cc = cc->next; */
- /* } */
- /* } */
- /* else // select the previous one */
- /* while (cc != nil) { */
- /* if (cc->next != nil && cc->next->selected) { */
- /* cc->next->selected = false; */
- /* cc->selected = true; */
- /* return cc; */
- /* } */
- /* cc = cc->next; */
- /* } */
- /* return nil; */
}
// create a completion list from a text and the list of possible completions
// `textlen' with the new lenght of `text'. If the memory cannot be
// allocated, `status' will be set to `ERR'.
void complete(struct completions *cs, bool first_selected, bool p, char **text, int *textlen, enum state *status) {
-
// if the first is always selected, and the first entry is different
// from the text, expand the text and return
if (first_selected
XFlush(d);
}
+// write the width and height of the window `w' respectively in `width'
+// and `height'.
void get_wh(Display *d, Window *w, int *width, int *height) {
XWindowAttributes win_attr;
XGetWindowAttributes(d, *w, &win_attr);
XUngrabKeyboard(d, CurrentTime);
}
+// Given a string, try to parse it as a number or return
+// `default_value'.
int parse_integer(const char *str, int default_value) {
errno = 0;
char *ep;