Revision: 1876 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1876&view=re... Author: frlan Date: 2011-01-26 18:42:41 +0000 (Wed, 26 Jan 2011)
Log Message: ----------- Add new plugin HTMLTable
Modified Paths: -------------- trunk/geany-plugins/Makefile.am trunk/geany-plugins/configure.ac trunk/geany-plugins/po/POTFILES.in
Added Paths: ----------- trunk/geany-plugins/build/htmltable.m4 trunk/geany-plugins/htmltable/ trunk/geany-plugins/htmltable/AUTHORS trunk/geany-plugins/htmltable/COPYING trunk/geany-plugins/htmltable/ChangeLog trunk/geany-plugins/htmltable/Makefile.am trunk/geany-plugins/htmltable/NEWS trunk/geany-plugins/htmltable/README trunk/geany-plugins/htmltable/src/ trunk/geany-plugins/htmltable/src/Makefile.am trunk/geany-plugins/htmltable/src/htmltable.c trunk/geany-plugins/htmltable/wscript_build
Modified: trunk/geany-plugins/Makefile.am =================================================================== --- trunk/geany-plugins/Makefile.am 2011-01-26 18:41:42 UTC (rev 1875) +++ trunk/geany-plugins/Makefile.am 2011-01-26 18:42:41 UTC (rev 1876) @@ -13,6 +13,7 @@ geanyprj \ geanysendmail \ geanyvc \ + htmltable \ pretty-printer \ shiftcolumn \ spellcheck \
Added: trunk/geany-plugins/build/htmltable.m4 =================================================================== --- trunk/geany-plugins/build/htmltable.m4 (rev 0) +++ trunk/geany-plugins/build/htmltable.m4 2011-01-26 18:42:41 UTC (rev 1876) @@ -0,0 +1,9 @@ +AC_DEFUN([GP_CHECK_HTMLTABLE], +[ + GP_ARG_DISABLE([HTMLTable], [yes]) + GP_STATUS_PLUGIN_ADD([HTMLTable], [$enable_htmltable]) + AC_CONFIG_FILES([ + htmltable/Makefile + htmltable/src/Makefile + ]) +])
Modified: trunk/geany-plugins/configure.ac =================================================================== --- trunk/geany-plugins/configure.ac 2011-01-26 18:41:42 UTC (rev 1875) +++ trunk/geany-plugins/configure.ac 2011-01-26 18:42:41 UTC (rev 1876) @@ -36,6 +36,7 @@ GP_CHECK_GEANYPRJ GP_CHECK_GEANYSENDMAIL GP_CHECK_GEANYVC +GP_CHECK_HTMLTABLE GP_CHECK_PRETTYPRINTER GP_CHECK_SHIFTCOLUMN GP_CHECK_SPELLCHECK
Added: trunk/geany-plugins/htmltable/AUTHORS =================================================================== Added: trunk/geany-plugins/htmltable/COPYING =================================================================== Added: trunk/geany-plugins/htmltable/ChangeLog =================================================================== --- trunk/geany-plugins/htmltable/ChangeLog (rev 0) +++ trunk/geany-plugins/htmltable/ChangeLog 2011-01-26 18:42:41 UTC (rev 1876) @@ -0,0 +1,3 @@ +2011-01-26 Frank Lanitz frank@frank.uvena.de + + * Initial Entry. New plugin: HTMLTable.
Added: trunk/geany-plugins/htmltable/Makefile.am =================================================================== --- trunk/geany-plugins/htmltable/Makefile.am (rev 0) +++ trunk/geany-plugins/htmltable/Makefile.am 2011-01-26 18:42:41 UTC (rev 1876) @@ -0,0 +1,8 @@ +if ENABLE_HTMLTABLE +include $(top_srcdir)/build/vars.auxfiles.mk +else +include $(top_srcdir)/build/vars.docs.mk +endif + +SUBDIRS = src +plugin = htmltable
Added: trunk/geany-plugins/htmltable/NEWS =================================================================== Added: trunk/geany-plugins/htmltable/README =================================================================== --- trunk/geany-plugins/htmltable/README (rev 0) +++ trunk/geany-plugins/htmltable/README 2011-01-26 18:42:41 UTC (rev 1876) @@ -0,0 +1,82 @@ +HTMLTable +----------- + +.. contents:: + +About +------ +HTMLTable is a plugin which helps on converting a tabulator +separated selection into a HTML-like table. + + +Installation +------------ + +This version of the plugin is installed with the combined +geany-plugins release. Please check README of this package + + +Usage +----- + +After installed successfully, load the plugin in Geany's plugin +manager. This will add a new keybinding into Geany's list of +keybindings inside the preferences dialog. You might like to set up +a keybinding for the function. Once this is done, the plugin is +ready to use. + +When using the plugin, just mark the area you like to transform and +push your keybinding. All line endings will be token as end of a row +and therefor transformed to <tr> and </tr>. Occurrences of tabulator +will be interpreted as column separators and replaced by <td> and +</td>. + +Rectangle selections are currently not supported and might lead to +some weird output you didn't expect -- just don't try it if you have +heart issues or working on an important document :) + +Development +----------- + +You can checkout the current source code from the Subversion repository at +Sourceforge.net. Get the code from: + +svn checkout +http://geany-plugins.svn.sourceforge.net/svnroot/geany-plugins/trunk/geany-p... + +If you want to create a patch, please respect the license of +HTMLTable as well as intellectual property of third. Patches that +should be included to the default distribution must be licensed under +the same conditions as HTMLTable by the copyright owner (GPL2+). + + +Known issues +------------ + +The plugin currently is not supporting rectangle selections very +well. Also it is not able to support <thead> and <tbody> at the +moment. However, at least the second point is planned for some later +release. + +For more recent information all reported issues will be tracked at +http://sourceforge.net/tracker/?group_id=222729 + + +License +------- + +HTMLTable and all its parts is distributed under the terms of the +GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any +later version. A copy of this license can be found in the file COPYING +included with the source code of this program. If not, you will be +able to get a copy by contacting the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +Bugs, questions, bugs, homepage +------------------------------- + +If you found any bugs or want to provide a patch, please contact Frank +Lanitz (frank(at)geany(dot)org). Please also do so, if you got any +questions.
Added: trunk/geany-plugins/htmltable/src/Makefile.am =================================================================== --- trunk/geany-plugins/htmltable/src/Makefile.am (rev 0) +++ trunk/geany-plugins/htmltable/src/Makefile.am 2011-01-26 18:42:41 UTC (rev 1876) @@ -0,0 +1,10 @@ +include $(top_srcdir)/build/vars.build.mk + +if ENABLE_HTMLTABLE +geanyplugins_LTLIBRARIES = htmltable.la +else +EXTRA_LTLIBRARIES = htmltable.la +endif + +htmltable_la_SOURCES = htmltable.c +htmltable_la_LIBADD = $(COMMONLIBS)
Added: trunk/geany-plugins/htmltable/src/htmltable.c =================================================================== --- trunk/geany-plugins/htmltable/src/htmltable.c (rev 0) +++ trunk/geany-plugins/htmltable/src/htmltable.c 2011-01-26 18:42:41 UTC (rev 1876) @@ -0,0 +1,148 @@ +/* + * htmltable.c + * + * Copyright 2011 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "geanyplugin.h" + +GeanyPlugin *geany_plugin; +GeanyData *geany_data; +GeanyFunctions *geany_functions; + +PLUGIN_VERSION_CHECK(200) + +PLUGIN_SET_TRANSLATABLE_INFO( + LOCALEDIR, GETTEXT_PACKAGE, _("HTMLTable"), + _("A little plugin to convert list into HTML-like tables"), + VERSION, "Frank Lanitz frank@frank.uvena.de"); + +enum +{ + KB_HTMLTABLE_CONVERT_TO_TABLE, + COUNT_KB +}; + + +void convert_to_table(gboolean header) +{ + GeanyDocument *doc = NULL; + doc = document_get_current(); + + g_return_if_fail(doc != NULL); + + if (sci_has_selection(doc->editor->sci)) + { + gchar *selection = NULL; + gchar **rows = NULL; + GString *replacement_str = NULL; + gchar *replacement = NULL; + + /* Actually grabbing selection and splitting it into single + * lines we will work on later */ + selection = sci_get_selection_contents(doc->editor->sci); + rows = g_strsplit_set(selection, "\r\n", -1); + g_free(selection); + + /* Checking whether we do have something we can work on - Returning if not */ + if (rows != NULL) + { + + /* Adding header to replacement */ + replacement_str = g_string_new("<table>\n"); + + /* Iteration onto rows and building up lines of table for + * replacement */ + + if (header == TRUE) + { + /* If the first line is given to be a header, we do use + * <thead> and <tbody> inside table for real XHTML */ + } + else + { + /* There is no header at selection. */ + guint i; + guint j; + for (i = 0; rows[i] != NULL ; i++) + { + gchar **columns = NULL; + columns = g_strsplit_set(rows[i], "\t", -1); + g_string_append(replacement_str, "\t<tr>\n"); + for (j = 0; columns[j] != NULL; j++) + { + g_string_append(replacement_str, "\t\t<td>"); + g_string_append(replacement_str, columns[j]); + g_string_append(replacement_str, "</td>\n"); + } + g_string_append(replacement_str, + "\t</tr>\n"); + g_free(columns); + } + } + + /* Adding the footer of table */ + g_string_append(replacement_str, "</table>\n"); + + /* Replacing selection with new table */ + replacement = g_string_free(replacement_str, FALSE); + sci_replace_sel(doc->editor->sci, replacement); + + g_free(rows); + g_free(replacement); + } + else + { + /* OK. Something went not as expected. + * We did have a selection but cannot parse it into rows. + * Aborting */ + g_warning(_("Something went went wrong on parsing selection. Aborting")); + return; + } + } /* Selection was gien -- end + * in case of there was no selection we are just doing nothing */ + return; +} + +void kb_convert_to_table(G_GNUC_UNUSED guint key_id) +{ + g_return_if_fail(document_get_current() != NULL); + convert_to_table(FALSE); +} + + +static void init_keybindings(void) +{ + GeanyKeyGroup *key_group; + key_group = plugin_set_key_group(geany_plugin, "htmltable", COUNT_KB, NULL); + keybindings_set_item(key_group, KB_HTMLTABLE_CONVERT_TO_TABLE, + kb_convert_to_table, 0, 0, "convert_to_table", + _("Convert selection to table"), NULL); +} + + +void plugin_init(GeanyData *data) +{ + init_keybindings(); + main_locale_init(LOCALEDIR, GETTEXT_PACKAGE); +} + + +void plugin_cleanup(void) +{ + /* We don't need to do anything here at the moment */ +}
Added: trunk/geany-plugins/htmltable/wscript_build =================================================================== --- trunk/geany-plugins/htmltable/wscript_build (rev 0) +++ trunk/geany-plugins/htmltable/wscript_build 2011-01-26 18:42:41 UTC (rev 1876) @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# +# WAF build script for geany-plugins - HTMLTable +# +# Copyright 2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> +# Copyright 2111 Frank Lanitz <frank(at)frank(dot)uvena(dot)de> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# $Id$ + +from build.wafutils import build_plugin + + +name = 'HTMLTable' +includes = ['htmltable/src'] + +build_plugin(bld, name, includes=includes)
Modified: trunk/geany-plugins/po/POTFILES.in =================================================================== --- trunk/geany-plugins/po/POTFILES.in 2011-01-26 18:41:42 UTC (rev 1875) +++ trunk/geany-plugins/po/POTFILES.in 2011-01-26 18:42:41 UTC (rev 1876) @@ -83,6 +83,9 @@ geanyvc/src/vc_svn.c geanyvc/src/utils.c
+# htmltable +htmltable/src/htmltable.c + # Spell Check spellcheck/src/speller.c spellcheck/src/scplugin.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org