Browse Source

WInput: make one-line APIs inline.

  * (input_get_text): make inline.
  * (input_is_empty): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 2 years ago
parent
commit
589155f6bf
2 changed files with 33 additions and 25 deletions
  1. 0 23
      lib/widget/input.c
  2. 33 2
      lib/widget/input.h

+ 0 - 23
lib/widget/input.c

@@ -1151,29 +1151,6 @@ input_assign_text (WInput * in, const char *text)
 
 /* --------------------------------------------------------------------------------------------- */
 
-/**
- * Get text of input line.
- *
- * @param in input line
- *
- * @return newly allocated string that contains a copy of @in's text.
- */
-char *
-input_get_text (const WInput * in)
-{
-    return g_strndup (in->buffer->str, in->buffer->len);
-}
-
-/* --------------------------------------------------------------------------------------------- */
-
-gboolean
-input_is_empty (const WInput * in)
-{
-    return in->buffer->len == 0;
-}
-
-/* --------------------------------------------------------------------------------------------- */
-
 /* Inserts text in input line */
 void
 input_insert (WInput * in, const char *text, gboolean insert_extra_space)

+ 33 - 2
lib/widget/input.h

@@ -91,8 +91,6 @@ cb_ret_t input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm
 void input_set_default_colors (void);
 cb_ret_t input_handle_char (WInput * in, int key);
 void input_assign_text (WInput * in, const char *text);
-char *input_get_text (const WInput * in);
-gboolean input_is_empty (const WInput * in);
 void input_insert (WInput * in, const char *text, gboolean insert_extra_space);
 void input_set_point (WInput * in, int pos);
 void input_update (WInput * in, gboolean clear_first);
@@ -104,6 +102,39 @@ void input_clean (WInput * in);
 void input_complete (WInput * in);
 void input_complete_free (WInput * in);
 
+/* --------------------------------------------------------------------------------------------- */
 /*** inline functions ****************************************************************************/
+/* --------------------------------------------------------------------------------------------- */
+
+/**
+ * Get text of input line.
+ *
+ * @param in input line
+ *
+ * @return newly allocated string that contains a copy of @in's text.
+ */
+static inline char *
+input_get_text (const WInput * in)
+{
+    return g_strndup (in->buffer->str, in->buffer->len);
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
+/**
+ * Is input line empty or not.
+ *
+ * @param in input line
+ *
+ * @return TRUE if buffer of @in is empty, FALSE othewise.
+ */
+static inline gboolean
+input_is_empty (const WInput * in)
+{
+    return (in->buffer->len == 0);
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
 
 #endif /* MC__WIDGET_INPUT_H */