WInput: make one-line APIs inline.

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

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2022-08-03 17:04:06 +03:00
parent 4e245291b4
commit 589155f6bf
2 changed files with 33 additions and 25 deletions

View File

@ -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)

View File

@ -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 */