mirror of
https://github.com/zoriya/ash.git
synced 2026-06-01 02:08:06 +00:00
Adding quoted insert commandé
This commit is contained in:
@@ -52,7 +52,8 @@ SRC = src/shell.c \
|
||||
src/my_ncurses/string_utils.c \
|
||||
src/my_ncurses/pause_utils.c \
|
||||
src/key_bindings/autocompletion.c \
|
||||
src/builtin/builtin_bindkey.c
|
||||
src/builtin/builtin_bindkey.c \
|
||||
src/key_bindings/other_bindings.c
|
||||
|
||||
OBJ = $(SRC:%.c=%.o)
|
||||
OBJ += src/main.o
|
||||
|
||||
@@ -44,6 +44,6 @@ int end_of_line_command(int key, buffer_t *buffer, env_t *env);
|
||||
int up_history_command(int key, buffer_t *buffer, env_t *env);
|
||||
int down_history_command(int key, buffer_t *buffer, env_t *env);
|
||||
|
||||
int quoted_insert_command(int key, buffer_t *buffer, env_t *env);
|
||||
int clear_screen_command(int key, buffer_t *buffer, env_t *env);
|
||||
|
||||
int complete_command(int key, buffer_t *buffer, env_t *env);
|
||||
@@ -33,6 +33,7 @@ typedef struct buffer
|
||||
int startx;
|
||||
int history_index;
|
||||
char *saved_buffer;
|
||||
bool quoted_insert;
|
||||
} buffer_t;
|
||||
|
||||
typedef struct alias_s
|
||||
|
||||
@@ -24,6 +24,7 @@ const key_function_t key_functions[] = {
|
||||
{"down-history", &down_history_command},
|
||||
{"complete-command", &complete_command},
|
||||
{"clear-screen", &clear_screen_command},
|
||||
{"quoted-insert", "ed_insert_command},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -41,6 +42,7 @@ const binding_t emacs_bindings[] = {
|
||||
{KEY_DOWN, &down_history_command},
|
||||
{'\t', &complete_command},
|
||||
{CTRL('l'), &clear_screen_command},
|
||||
{CTRL('v'), "ed_insert_command},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** ash
|
||||
** File description:
|
||||
** other_bindings
|
||||
*/
|
||||
|
||||
#include "shell.h"
|
||||
#include "key_functions.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
int quoted_insert_command(int key, buffer_t *buffer, env_t *env)
|
||||
{
|
||||
buffer->quoted_insert = true;
|
||||
return (0);
|
||||
}
|
||||
+5
-1
@@ -24,6 +24,10 @@ int process_key(int key, buffer_t *buffer, env_t *env)
|
||||
if (key <= 0)
|
||||
return (0);
|
||||
my_clrtobot();
|
||||
if (buffer->quoted_insert) {
|
||||
buffer->quoted_insert = false;
|
||||
return (self_insert_command(key, buffer, env));
|
||||
}
|
||||
for (int i = 0; env->bindings[i].func; i++)
|
||||
if (key == env->bindings[i].key)
|
||||
return (env->bindings[i].func(key, buffer, env));
|
||||
@@ -67,7 +71,7 @@ void shell_refresh(buffer_t *buffer, env_t *env)
|
||||
|
||||
void start_shell(env_t *env)
|
||||
{
|
||||
buffer_t buffer = {NULL, 0, 0, 0, 0, NULL};
|
||||
buffer_t buffer = {NULL, 0, 0, 0, 0, NULL, false};
|
||||
int key;
|
||||
|
||||
if (isatty(0)) {
|
||||
|
||||
Reference in New Issue
Block a user