mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Command tidy
This commit is contained in:
parent
4a956d41de
commit
0f7f0a259d
5
maketags.sh
Executable file
5
maketags.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
rm -f tags
|
||||||
|
rm -f cscope.out
|
||||||
|
ctags -R .
|
||||||
|
cscope -R -b
|
@ -37,9 +37,12 @@
|
|||||||
#include "tinyurl.h"
|
#include "tinyurl.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
/* command structure
|
/*
|
||||||
* cmd - The actual string of the command
|
* Command structure
|
||||||
|
*
|
||||||
|
* cmd - The command string including leading '/'
|
||||||
* func - The function to execute for the command
|
* func - The function to execute for the command
|
||||||
|
* help - A help struct containing usage info etc
|
||||||
*/
|
*/
|
||||||
struct cmd_t {
|
struct cmd_t {
|
||||||
const gchar *cmd;
|
const gchar *cmd;
|
||||||
@ -47,8 +50,6 @@ struct cmd_t {
|
|||||||
struct cmd_help_t help;
|
struct cmd_help_t help;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// helpers
|
|
||||||
static struct cmd_t * _cmd_get_command(const char * const command);
|
static struct cmd_t * _cmd_get_command(const char * const command);
|
||||||
static gboolean _handle_command(const char * const command,
|
static gboolean _handle_command(const char * const command,
|
||||||
const char * const inp);
|
const char * const inp);
|
||||||
@ -78,7 +79,12 @@ static gboolean _cmd_chat(const char * const inp, struct cmd_help_t help);
|
|||||||
static gboolean _cmd_xa(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_xa(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_default(const char * const inp);
|
static gboolean _cmd_default(const char * const inp);
|
||||||
|
|
||||||
// The commands
|
/*
|
||||||
|
* The commands are broken down into three groups:
|
||||||
|
* Main commands
|
||||||
|
* Commands to change preferences
|
||||||
|
* Commands to change users status
|
||||||
|
*/
|
||||||
static struct cmd_t main_commands[] =
|
static struct cmd_t main_commands[] =
|
||||||
{
|
{
|
||||||
{ "/help",
|
{ "/help",
|
||||||
@ -327,25 +333,34 @@ static struct cmd_t status_commands[] =
|
|||||||
|
|
||||||
static PAutocomplete commands_ac;
|
static PAutocomplete commands_ac;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Take a line of input and process it, return TRUE if profanity is to
|
||||||
|
* continue, FALSE otherwise
|
||||||
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
process_input(char *inp)
|
process_input(char *inp)
|
||||||
{
|
{
|
||||||
log_msg(PROF_LEVEL_DEBUG, PROF, "Input recieved: %s", inp);
|
log_msg(PROF_LEVEL_DEBUG, PROF, "Input recieved: %s", inp);
|
||||||
|
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
|
||||||
g_strstrip(inp);
|
g_strstrip(inp);
|
||||||
|
|
||||||
if (strlen(inp) > 0)
|
// add line to history if something typed
|
||||||
|
if (strlen(inp) > 0) {
|
||||||
history_append(inp);
|
history_append(inp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// just carry on if no input
|
||||||
if (strlen(inp) == 0) {
|
if (strlen(inp) == 0) {
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
|
|
||||||
|
// habdle command if input starts with a '/'
|
||||||
} else if (inp[0] == '/') {
|
} else if (inp[0] == '/') {
|
||||||
char inp_cpy[strlen(inp) + 1];
|
char inp_cpy[strlen(inp) + 1];
|
||||||
strcpy(inp_cpy, inp);
|
strcpy(inp_cpy, inp);
|
||||||
char *command = strtok(inp_cpy, " ");
|
char *command = strtok(inp_cpy, " ");
|
||||||
result = _handle_command(command, inp);
|
result = _handle_command(command, inp);
|
||||||
|
|
||||||
|
// call a default handler if input didn't start with '/'
|
||||||
} else {
|
} else {
|
||||||
result = _cmd_default(inp);
|
result = _cmd_default(inp);
|
||||||
}
|
}
|
||||||
@ -357,6 +372,9 @@ process_input(char *inp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialise command autocompleter and history
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
command_init(void)
|
command_init(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user