1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 22:06:38 +02:00

script: add diff between current script and version in repository

New options:
- script.look.diff_command
- script.look.diff_color

Key alt-d has been changed to alt-v on script buffer (view script).
Key alt-d is now used on detail of script to jump to diff (if diff is displayed).
This commit is contained in:
Sebastien Helleu
2012-08-30 08:50:22 +02:00
parent 186053f90c
commit 80e740b72f
29 changed files with 599 additions and 88 deletions
+56
View File
@@ -23,6 +23,7 @@
#define _XOPEN_SOURCE 700
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
@@ -146,6 +147,61 @@ script_repo_search_by_name_ext (const char *name_with_extension)
return NULL;
}
/*
* script_repo_get_filename_loaded: get filename of a loaded script
* (it returns name of file and not the link,
* if there is a symbolic to file)
* Note: result has to be free() after use
*/
char *
script_repo_get_filename_loaded (struct t_repo_script *script)
{
const char *weechat_home;
char *filename, resolved_path[PATH_MAX];
int length;
struct stat st;
weechat_home = weechat_info_get ("weechat_dir", NULL);
length = strlen (weechat_home) + strlen (script->name_with_extension) + 64;
filename = malloc (length);
if (filename)
{
snprintf (filename, length, "%s/%s/autoload/%s",
weechat_home,
script_language[script->language],
script->name_with_extension);
if (stat (filename, &st) != 0)
{
snprintf (filename, length, "%s/%s/%s",
weechat_home,
script_language[script->language],
script->name_with_extension);
if (stat (filename, &st) != 0)
{
filename[0] = '\0';
}
}
}
if (!filename[0])
{
free (filename);
return NULL;
}
if (realpath (filename, resolved_path))
{
if (strcmp (filename, resolved_path) != 0)
{
free (filename);
return strdup (resolved_path);
}
}
return filename;
}
/*
* script_repo_get_status_for_display: get status for display
* list is the codes of status to display