From c085601e5c6370b955abd9965d88fd2b3d319cac Mon Sep 17 00:00:00 2001 From: Filip Kliber Date: Tue, 30 Aug 2016 20:02:41 +0200 Subject: [PATCH] readme --- LaTeX.c | 20 ++++++++--------- LaTeX.h | 5 +++++ README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 11 deletions(-) diff --git a/LaTeX.c b/LaTeX.c index bdb971f..100b0b6 100644 --- a/LaTeX.c +++ b/LaTeX.c @@ -1,3 +1,7 @@ +/* + * This program is licensed under MIT license. For full text of + * the license, see ./LICENSE file. + */ #define PURPLE_PLUGINS #include @@ -5,14 +9,8 @@ #include #include #include +#include #include -#ifdef _WIN32 - #include -#else - #include - #include - #include -#endif #include @@ -58,7 +56,7 @@ static char* getdirname(const char const *file) GetCurrentDirectory(MAX_PATH, result); return result; #else - return getcwd(NULL, 0); + return get_current_dir_name(); #endif } result = (char*) malloc((occurence - file + 1) * sizeof(char)); @@ -171,7 +169,7 @@ char* latex_to_png(const char* full_text, size_t from, size_t len) if (!font_size) font_size = DEFAULT_FONTSIZE; - fprintf(tex_file, LATEX_FORMAT_STRING, bgcolor, fgcolor, (int) len, full_text + from); + fprintf(tex_file, LATEX_FORMAT_STRING, bgcolor, fgcolor, len, full_text + from); tmp_dir = getdirname(file_tex); if (!tmp_dir || chdir(tmp_dir)) @@ -253,7 +251,7 @@ static gboolean analyze(char **message, size_t from) if (start >= length || end >= length) break; - purple_debug_info("LaTeX", "Found occurence in msg '%s' (at %zu to %zu)\n", *message, start, end); + purple_debug_info("LaTeX", "Found occurence in msg '%s' (at %u to %u)\n", *message, start, end); sbstr_len = end - start - strlen(LATEX_DELIMITER); if (!(png_file = latex_to_png(*message, start + strlen(LATEX_DELIMITER), sbstr_len))) { @@ -296,7 +294,7 @@ static gboolean analyze(char **message, size_t from) length = strlen(*message); from = start + strlen(LATEX_DELIMITER) + img_text_len; - purple_debug_info("LaTeX", "Looking for another occurence beginning at %zu\n", from); + purple_debug_info("LaTeX", "Looking for another occurence beginning at %u\n", from); } return TRUE; } diff --git a/LaTeX.h b/LaTeX.h index 3774d3d..14c3879 100644 --- a/LaTeX.h +++ b/LaTeX.h @@ -1,3 +1,8 @@ +/* + * This program is licensed under MIT license. For full text of + * the license, see ./LICENSE file. + */ + #include #define PLUGIN_PREF_ROOT "/plugins/core/latex" diff --git a/README.md b/README.md index bff3255..d350fdd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,68 @@ # pidgin-latex Reimplementation of popular pidgin plugin used to display LaTeX formulas directly to IM chat. + +### Requirements +- Latex (in `PATH`) +- [Dvipng](http://savannah.nongnu.org/projects/dvipng/) (in `PATH`) + +On windows `dvipng` is usually part of texlive installation, which is what most windows users use. +On unix, if you don't have dvipng installed, use your distro's package manager (*aptitude*, *pacman*) to install it. + +Both platforms usually add those programs to `PATH` environment variable automaticaly. + +### Usage +Plugin searches for text between `$$` and `$$`. When found, this text is substituted for `%TEXT%` in this file + + \documentclass[preview]{standalone} + \usepackage{amsmath} + \usepackage{color} + \usepackage{amsfonts} + \usepackage{amssymb} + \definecolor{bgcolor}{RGB}{%SETTINGS_BG%} + \definecolor{fgcolor}{RGB}{%SETTINGS_FG%} + \begin{document} + \setlength{\\fboxsep}{0pt} + \colorbox{bgcolor}{ + \color{fgcolor} + $%TEXT%$ + } + \end{document} + +Which is then processed by `latex` to create *dvi* file. Such file is then processed with `dvipng` to create `png` image containing desired output. That image is inserted directly into a displayed message. + +Plugin is enabled in IM chats, not in group chats (like IRC). + +Plugin is configurable directly from pidgin GUI. It has following options +- background color: In format `R,G,B`. It's substituted for `%SETTINGS_BG%`. Default value is white. +- foreground color: In format `R,G,B`. It's substituted for `%SETTINGS_FG%`. Default value is black. +- font size: Desired font size of formula in the image. Default value is 9px. + +### Download +Windows users can download plugin from this link. +Unix users have to compile it, package is not available. + +### Installation +Place library file (`.dll` or `.so`) to `path-to-pidgin/plugins/` (all users) or `.purple/plugins` (current user) and turn the plugin on in pidgin. + +### Compilation +In order to compile the plugin, you have to compile pidgin from sources (at least *libpurple*). See [pidgin wiki](https://developer.pidgin.im/wiki#DevelopmentInformation) for instructions. + +Once *libpurple* is compiled, place `LaTeX.c` and `LaTeX.h` to `pidgin-2.x.y/libpurple/plugins` and execute + + make LaTeX.so + +On windows platform, execute + + make -f Makefile.mingw LaTeX.dll + +instead. + +### ToDo +- Retrieve bgcolor, fgcolor and font size from gtk settings, pidgin preferences or directly from message, whichever has higher priority. +- Figure out how to resolve quite long (1second) Latex and dvipng calls which causes pidgin to stop responding. + +### Bugs +Please report any bugs you found to zereges<at>ekirei.cz or message me directly at github. Attach debug widnow output or screenshots if necessary. + +### License +This program is licensed under MIT licence. For full text of the license, see `./LICENSE` file in this repository. \ No newline at end of file