Skip to content

Instantly share code, notes, and snippets.

@joshgoebel
Created May 23, 2017 13:08
Show Gist options
  • Save joshgoebel/31679976804adbe8db218acc48e6a280 to your computer and use it in GitHub Desktop.
Save joshgoebel/31679976804adbe8db218acc48e6a280 to your computer and use it in GitHub Desktop.
#define PROMPT(buffer, direction, index, result) \
do { \
char *after; \
char before[MAX_LINE_LEN]; \
fprintf(stderr, "(search %c%d) `%s':", direction[0], index, buffer); \
if (index > 0) {\
int i = 0; \
after = strstr(result,buffer); \
int len = strlen(result) - strlen(after); \
strcpy(before, result); \
before[len] = 0; \
i = fprintf(stderr, " %s%s", before, after); \
fprintf(stderr, "\033[%dD", strlen(after)); \
} \
} while (0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment