[geany/geany] acacbe: Add sci_get_selected_text_length2() and deprecate sci_get_selected_text_length()

Jiří Techet git-noreply at geany.org
Sun Apr 24 15:07:14 UTC 2022


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Fri, 14 Jan 2022 20:53:29 UTC
Commit:      acacbe30574a42a698d49385628e84d9cbdc1241
             https://github.com/geany/geany/commit/acacbe30574a42a698d49385628e84d9cbdc1241

Log Message:
-----------
Add sci_get_selected_text_length2() and deprecate sci_get_selected_text_length()


Modified Paths:
--------------
    src/sciwrappers.c
    src/sciwrappers.h
    src/ui_utils.c

Modified: src/sciwrappers.c
12 lines changed, 12 insertions(+), 0 deletions(-)
===================================================================
@@ -792,6 +792,8 @@ gchar *sci_get_selection_contents(ScintillaObject *sci)
 
 
 /** Gets selected text length including the terminating NUL character.
+ * @deprecated sci_get_selected_text_length is deprecated and should not be used in newly-written code.
+ * Use sci_get_selected_text_length2() instead.
  * @param sci Scintilla widget.
  * @return Length. */
 GEANY_API_SYMBOL
@@ -801,6 +803,16 @@ gint sci_get_selected_text_length(ScintillaObject *sci)
 }
 
 
+/** Gets selected text length without the terminating NUL character.
+ * @param sci Scintilla widget.
+ * @return Length. */
+GEANY_API_SYMBOL
+gint sci_get_selected_text_length2(ScintillaObject *sci)
+{
+	return (gint) SSM(sci, SCI_GETSELTEXT, 0, 0);
+}
+
+
 gint sci_get_position_from_xy(ScintillaObject *sci, gint x, gint y, gboolean nearby)
 {
 	/* for nearby return -1 if there is no character near to the x,y point. */


Modified: src/sciwrappers.h
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -64,7 +64,7 @@ void				sci_set_selection_end		(ScintillaObject *sci, gint position);
 
 gint				sci_get_length				(ScintillaObject *sci);
 gchar*				sci_get_contents			(ScintillaObject *sci, gint buffer_len);
-gint				sci_get_selected_text_length(ScintillaObject *sci);
+gint				sci_get_selected_text_length2(ScintillaObject *sci);
 gchar*				sci_get_selection_contents	(ScintillaObject *sci);
 gchar*				sci_get_line				(ScintillaObject *sci, gint line_num);
 gint 				sci_get_line_length			(ScintillaObject *sci, gint line);
@@ -106,6 +106,7 @@ gint				sci_find_matching_brace		(ScintillaObject *sci, gint pos);
 void				sci_get_text				(ScintillaObject *sci, gint len, gchar *text) GEANY_DEPRECATED_FOR(sci_get_contents);
 void				sci_get_selected_text		(ScintillaObject *sci, gchar *text) GEANY_DEPRECATED_FOR(sci_get_selection_contents);
 void				sci_get_text_range			(ScintillaObject *sci, gint start, gint end, gchar *text) GEANY_DEPRECATED_FOR(sci_get_contents_range);
+gint				sci_get_selected_text_length(ScintillaObject *sci) GEANY_DEPRECATED_FOR(sci_get_selected_text_length2);
 #endif	/* GEANY_DISABLE_DEPRECATED */
 
 #ifdef GEANY_PRIVATE


Modified: src/ui_utils.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -227,7 +227,7 @@ static gchar *create_statusbar_statistics(GeanyDocument *doc,
 				break;
 			case 's':
 			{
-				gint len = sci_get_selected_text_length(sci) - 1;
+				gint len = sci_get_selected_text_length2(sci);
 				/* check if whole lines are selected */
 				if (!len || sci_get_col_from_position(sci,
 						sci_get_selection_start(sci)) != 0 ||
@@ -241,7 +241,7 @@ static gchar *create_statusbar_statistics(GeanyDocument *doc,
 			}
 			case 'n' :
 				g_string_append_printf(stats_str, "%d",
-					sci_get_selected_text_length(doc->editor->sci) - 1);
+					sci_get_selected_text_length2(doc->editor->sci));
 				break;
 			case 'w':
 				/* RO = read-only */



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list