mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Command list size now calculated
No longer have to specify size, and keep it up to date when adding new commands
This commit is contained in:
parent
cd3a0ddeb8
commit
6644fa953e
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "contact_list.h"
|
#include "contact_list.h"
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
@ -89,8 +90,6 @@ static struct cmd_t commands[] = {
|
|||||||
{ "/help", _cmd_help }
|
{ "/help", _cmd_help }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int num_cmds = 19;
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
process_input(char *inp)
|
process_input(char *inp)
|
||||||
{
|
{
|
||||||
@ -124,8 +123,8 @@ command_init(void)
|
|||||||
{
|
{
|
||||||
commands_ac = p_autocomplete_new();
|
commands_ac = p_autocomplete_new();
|
||||||
|
|
||||||
int i;
|
unsigned int i;
|
||||||
for (i = 0; i < num_cmds; i++) {
|
for (i = 0; i < ARRAY_SIZE(commands); i++) {
|
||||||
struct cmd_t *pcmd = commands+i;
|
struct cmd_t *pcmd = commands+i;
|
||||||
p_autocomplete_add(commands_ac, (gchar *)pcmd->cmd);
|
p_autocomplete_add(commands_ac, (gchar *)pcmd->cmd);
|
||||||
}
|
}
|
||||||
@ -148,8 +147,8 @@ reset_command_completer(void)
|
|||||||
static gboolean
|
static gboolean
|
||||||
_handle_command(const char * const command, const char * const inp)
|
_handle_command(const char * const command, const char * const inp)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
for (i = 0; i < num_cmds; i++) {
|
for (i = 0; i < ARRAY_SIZE(commands); i++) {
|
||||||
struct cmd_t *pcmd = commands+i;
|
struct cmd_t *pcmd = commands+i;
|
||||||
if (strcmp(pcmd->cmd, command) == 0) {
|
if (strcmp(pcmd->cmd, command) == 0) {
|
||||||
return (pcmd->func(inp));
|
return (pcmd->func(inp));
|
||||||
|
@ -49,6 +49,8 @@ typedef enum {
|
|||||||
#define notify_notification_new(summary, body, icon) notify_notification_new(summary, body, icon, NULL)
|
#define notify_notification_new(summary, body, icon) notify_notification_new(summary, body, icon, NULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||||
|
|
||||||
void p_slist_free_full(GSList *items, GDestroyNotify free_func);
|
void p_slist_free_full(GSList *items, GDestroyNotify free_func);
|
||||||
void create_config_directory(void);
|
void create_config_directory(void);
|
||||||
void create_dir(char *name);
|
void create_dir(char *name);
|
||||||
|
Loading…
Reference in New Issue
Block a user