This PR is in response to #819.
Changes: - add preferences option: 'Use collation based string compare' ![image](https://user-images.githubusercontent.com/15589754/62841538-6a2d6200-bc77-11...)
- `getcmpfns()` returns either `g_utf8_collate` or `strcmp` function pointer to line operations function based on user preference
Minor:
- add help function to redirect to online documentation - split files into `lo_prefs` and `lo_fns` - sorry about all the annoying indentation / spacing changes / file renaming.
I'm open to hear any suggestions/improvements. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-plugins/pull/897
-- Commit Summary --
* lineoperations: minor formatting changes * lineoperations: add preferences * lineoperations: split files into fns and prefs * lineoperations: abstract string compare fns * lineoperations: add documentation for prefs * lineoperations: match indentation
-- File Changes --
M lineoperations/ChangeLog (9) M lineoperations/README (102) M lineoperations/src/Makefile.am (6) M lineoperations/src/lineoperations.c (82) R lineoperations/src/lo_fns.c (137) R lineoperations/src/lo_fns.h (15) A lineoperations/src/lo_prefs.c (127) A lineoperations/src/lo_prefs.h (59)
-- Patch Links --
https://github.com/geany/geany-plugins/pull/897.patch https://github.com/geany/geany-plugins/pull/897.diff
Please update POTFILES.in
@smostertdev pushed 1 commit.
e6c82ba0613d4952c11ef897c608fa61434c5a88 lineoperations: update POTFILES with lo_fns and lo_prefs
LarsGit223 requested changes on this pull request.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/ + +#ifndef LO_PREFS_H +#define LO_PREFS_H + +#include <geanyplugin.h> +#include "lo_prefs.h" + + +typedef struct +{ + /* general settings */ + gchar *config_file; + gboolean use_collation_compare; +} AddonsInfo;
Is this intentionally named ```AddonsInfo``` or a copy&paste issue?
+#ifndef LO_PREFS_H
+#define LO_PREFS_H + +#include <geanyplugin.h> +#include "lo_prefs.h" + + +typedef struct +{ + /* general settings */ + gchar *config_file; + gboolean use_collation_compare; +} AddonsInfo; + + +extern AddonsInfo *lo_info;
Same question here.
+appear ("Tools" > "Line Operations"). Click on each menu item to apply
+the operation on whole file, or selection. See descriptions below to +see operations for each menu item. + +Preferences +----------- + +To enable preferences ("Tools" > "Plugin Manager"), check the checkbox to +enable Line Operations, and with the item highlighted click "Preferences" +on bottom of the "Plugin Manager" frame. + +**Use collation based string compare** - When this option is enabled it will +compare strings using linguistically correct rules for the current locale +(g_utf8_collate). + +When it is disabled it will compare strings based off numerical value of the
Should it be _"based off"_ or _"based on"_?
-#include "linefunctions.h"
+#include "lo_fns.h" +#include "lo_prefs.h" + + +/* Get sort function based on user preferences */ +lo_strcmpfns +getcmpfns(void) +{ + if(lo_info->use_collation_compare) + { + return g_utf8_collate; + } + else + { + return strcmp;
Maybe you like to prefer ```g_strcmp0``` from the glib here? The same as ```strcmp``` just a bit safer but from glib.
@smostertdev pushed 1 commit.
6befa8bb532faaacff11c2da57d419268c605896 lineoperations: docs changes, use g_strcmp0
smostertdev commented on this pull request.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/ + +#ifndef LO_PREFS_H +#define LO_PREFS_H + +#include <geanyplugin.h> +#include "lo_prefs.h" + + +typedef struct +{ + /* general settings */ + gchar *config_file; + gboolean use_collation_compare; +} AddonsInfo;
You are correct, updated
smostertdev commented on this pull request.
+#ifndef LO_PREFS_H
+#define LO_PREFS_H + +#include <geanyplugin.h> +#include "lo_prefs.h" + + +typedef struct +{ + /* general settings */ + gchar *config_file; + gboolean use_collation_compare; +} AddonsInfo; + + +extern AddonsInfo *lo_info;
You are correct, updated
smostertdev commented on this pull request.
+appear ("Tools" > "Line Operations"). Click on each menu item to apply
+the operation on whole file, or selection. See descriptions below to +see operations for each menu item. + +Preferences +----------- + +To enable preferences ("Tools" > "Plugin Manager"), check the checkbox to +enable Line Operations, and with the item highlighted click "Preferences" +on bottom of the "Plugin Manager" frame. + +**Use collation based string compare** - When this option is enabled it will +compare strings using linguistically correct rules for the current locale +(g_utf8_collate). + +When it is disabled it will compare strings based off numerical value of the
I think they're both [valid](https://english.stackexchange.com/questions/15081/based-on-instead-of-based-...). I changed it to "based on", I think it sounds a little better.
smostertdev commented on this pull request.
-#include "linefunctions.h"
+#include "lo_fns.h" +#include "lo_prefs.h" + + +/* Get sort function based on user preferences */ +lo_strcmpfns +getcmpfns(void) +{ + if(lo_info->use_collation_compare) + { + return g_utf8_collate; + } + else + { + return strcmp;
For some reason I changed it a few years ago https://github.com/geany/geany-plugins/commit/2e2e043318fd2630cd05f1ee95c49f..., I just don't remember why.
I agree with you, I think it is better with glib. I tested it and do not see any problems, so I'm not sure what I was thinking a few years ago.
LarsGit223 approved this pull request.
LGBI. The commits should be squashed before merging.
Merged #897 into master.
github-comments@lists.geany.org