Show relative paths in diff filename tags.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3951 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2009-07-10 15:57:12 +00:00
parent a6a847f4e7
commit 746a8d5834
2 changed files with 36 additions and 26 deletions

View File

@ -5,6 +5,8 @@
scrolling with the arrow keys.
* src/keybindings.c, src/keybindings.h, src/search.c, src/search.h:
Add 'Mark All' keybinding.
* tagmanager/diff.c:
Show relative paths in diff filename tags.
2009-07-09 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

View File

@ -24,11 +24,11 @@
* DATA DEFINITIONS
*/
typedef enum {
K_FUNCTION
K_FUNCTION
} diffKind;
static kindOption DiffKinds [] = {
{ TRUE, 'f', "function", "functions"}
{ TRUE, 'f', "function", "functions"}
};
/*
@ -37,32 +37,40 @@ static kindOption DiffKinds [] = {
static void findDiffTags (void)
{
vString *filename = vStringNew ();
const unsigned char *line, *tmp;
vString *filename = vStringNew ();
const unsigned char *line, *tmp;
while ((line = fileReadLine ()) != NULL)
{
while ((line = fileReadLine ()) != NULL)
{
const unsigned char* cp = line;
boolean skipSlash = TRUE;
boolean skipSlash = FALSE;
if (strncmp((const char*) cp, "--- ", (size_t) 4) == 0)
{
cp += 4;
if (isspace ((int) *cp)) continue;
tmp = (const unsigned char*) strrchr((const char*) cp, '/');
if (tmp == NULL)
{ /* if no / is contained try \ in case of a Windows filename */
tmp = (const unsigned char*) strrchr((const char*) cp, '\\');
/* strip any absolute path */
if (*cp == '/' || *cp == '\\')
{
skipSlash = TRUE;
tmp = (const unsigned char*) strrchr((const char*) cp, '/');
if (tmp == NULL)
{ /* last fallback, probably the filename doesn't contain a path, so take it */
if (strlen((const char*) cp) > 0)
{
tmp = cp;
skipSlash = FALSE;
{ /* if no / is contained try \ in case of a Windows filename */
tmp = (const unsigned char*) strrchr((const char*) cp, '\\');
if (tmp == NULL)
{ /* last fallback, probably the filename doesn't contain a path, so take it */
if (strlen((const char*) cp) > 0)
{
tmp = cp;
skipSlash = FALSE;
}
}
}
}
else
tmp = cp;
if (tmp != NULL)
{
if (skipSlash) tmp++; /* skip the leading slash or backslash */
@ -77,20 +85,20 @@ static void findDiffTags (void)
}
}
}
vStringDelete (filename);
vStringDelete (filename);
}
extern parserDefinition* DiffParser (void)
{
static const char *const patterns [] = { "*.diff", "*.patch", NULL };
static const char *const extensions [] = { "diff", NULL };
parserDefinition* const def = parserNew ("Diff");
def->kinds = DiffKinds;
def->kindCount = KIND_COUNT (DiffKinds);
def->patterns = patterns;
def->extensions = extensions;
def->parser = findDiffTags;
return def;
static const char *const patterns [] = { "*.diff", "*.patch", NULL };
static const char *const extensions [] = { "diff", NULL };
parserDefinition* const def = parserNew ("Diff");
def->kinds = DiffKinds;
def->kindCount = KIND_COUNT (DiffKinds);
def->patterns = patterns;
def->extensions = extensions;
def->parser = findDiffTags;
return def;
}
/* vi:set tabstop=8 shiftwidth=4: */