Skip to content

Commit

Permalink
Fixes a type in the word response
Browse files Browse the repository at this point in the history
  • Loading branch information
xomachine committed Sep 24, 2020
1 parent 6891e69 commit d8081d6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions lua/vis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ local events = {
WIN_OPEN = "Event::WIN_OPEN", -- see @{win_open}
WIN_STATUS = "Event::WIN_STATUS", -- see @{win_status}
TERM_CSI = "Event::TERM_CSI", -- see @{term_csi}
PROCESS_RESPONCE = "Event::PROCESS_RESPONCE", -- see @{process_responce}
PROCESS_RESPONSE = "Event::PROCESS_RESPONSE", -- see @{process_response}
}

events.file_close = function(...) events.emit(events.FILE_CLOSE, ...) end
Expand All @@ -168,7 +168,7 @@ events.win_highlight = function(...) events.emit(events.WIN_HIGHLIGHT, ...) end
events.win_open = function(...) events.emit(events.WIN_OPEN, ...) end
events.win_status = function(...) events.emit(events.WIN_STATUS, ...) end
events.term_csi = function(...) events.emit(events.TERM_CSI, ...) end
events.process_responce = function(...) events.emit(events.PROCESS_RESPONCE, ...) end
events.process_response = function(...) events.emit(events.PROCESS_RESPONSE, ...) end

local handlers = {}

Expand Down
22 changes: 11 additions & 11 deletions vis-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ void vis_lua_win_close(Vis *vis, Win *win) { }
void vis_lua_win_highlight(Vis *vis, Win *win) { }
void vis_lua_win_status(Vis *vis, Win *win) { window_status_update(vis, win); }
void vis_lua_term_csi(Vis *vis, const long *csi) { }
void vis_lua_process_responce(Vis *vis, const char *name,
char *buffer, size_t len, ResponceType rtype) { }
void vis_lua_process_response(Vis *vis, const char *name,
char *buffer, size_t len, ResponseType rtype) { }


#else
Expand Down Expand Up @@ -1385,12 +1385,12 @@ static int close_subprocess(lua_State *L) {
/***
* Open new process and return its input handler.
* When the process will quit or will output anything to stdout or stderr,
* the @{process_responce} event will be fired.
* the @{process_response} event will be fired.
*
* The editor core won't be blocked while the external process is running.
*
* @function communicate
* @tparam string name the name of subprocess (to distinguish processes in the @{process_responce} event)
* @tparam string name the name of subprocess (to distinguish processes in the @{process_response} event)
* @tparam string command the command to execute
* @return the file handle to write data to the process, in case of error the return values are equivalent to @{io.open} error values.
*/
Expand Down Expand Up @@ -3180,18 +3180,18 @@ void vis_lua_term_csi(Vis *vis, const long *csi) {
}

/***
* The responce received from the process started via @{Vis:communicate}.
* @function process_responce
* The response received from the process started via @{Vis:communicate}.
* @function process_response
* @tparam string name the name of process given to @{Vis:communicate}
* @tparam string responce_type can be "STDOUT" or "STDERR" if new output was received in corresponding channel, "SIGNAL" if the process was terminated by a signal or "EXIT" when the process terminated normally
* @tparam string|int buffer the available content sent by process; it becomes the exit code number if responce\_type is "EXIT", or the signal number if responce\_type is "SIGNAL"
* @tparam string response_type can be "STDOUT" or "STDERR" if new output was received in corresponding channel, "SIGNAL" if the process was terminated by a signal or "EXIT" when the process terminated normally
* @tparam string|int buffer the available content sent by process; it becomes the exit code number if response\_type is "EXIT", or the signal number if response\_type is "SIGNAL"
*/
void vis_lua_process_responce(Vis *vis, const char *name,
char *buffer, size_t len, ResponceType rtype) {
void vis_lua_process_response(Vis *vis, const char *name,
char *buffer, size_t len, ResponseType rtype) {
lua_State *L = vis->lua;
if (!L)
return;
vis_lua_event_get(L, "process_responce");
vis_lua_event_get(L, "process_response");
if (lua_isfunction(L, -1)) {
lua_pushstring(L, name);
if (rtype == EXIT || rtype == SIGNAL)
Expand Down
2 changes: 1 addition & 1 deletion vis-lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ void vis_lua_win_close(Vis*, Win*);
void vis_lua_win_highlight(Vis*, Win*);
void vis_lua_win_status(Vis*, Win*);
void vis_lua_term_csi(Vis*, const long *);
void vis_lua_process_responce(Vis *, const char *, char *, size_t, ResponceType);
void vis_lua_process_response(Vis *, const char *, char *, size_t, ResponseType);

#endif
14 changes: 7 additions & 7 deletions vis-subprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ Process *vis_process_communicate(Vis *vis, const char *name,
* returns the subprocess information structure, containing file descriptors
* of the process.
* Also stores the subprocess information to the internal pool to track
* its status and responces.
* its status and responses.
* `name` - the string than should contain an unique name of the subprocess.
* This name will be passed to the PROCESS_RESPONCE event handler
* This name will be passed to the PROCESS_RESPONSE event handler
* to distinguish running subprocesses.
* `invalidator` - a pointer to the pointer which shows that the subprocess
* is invalid when set to NULL. When subprocess dies, it is being set to NULL.
Expand Down Expand Up @@ -134,14 +134,14 @@ int vis_process_before_tick(fd_set *readfds) {
return maxfd;
}

void read_and_fire(Vis* vis, int fd, const char *name, ResponceType rtype) {
void read_and_fire(Vis* vis, int fd, const char *name, ResponseType rtype) {
/* Reads data from the given subprocess file descriptor `fd` and fires
* the PROCESS_RESPONCE event in Lua with given subprocess `name`,
* the PROCESS_RESPONSE event in Lua with given subprocess `name`,
* `rtype` and the read data as arguments. */
static char buffer[MAXBUFFER];
size_t obtained = read(fd, &buffer, MAXBUFFER-1);
if (obtained > 0)
vis_lua_process_responce(vis, name, buffer, obtained, rtype);
vis_lua_process_response(vis, name, buffer, obtained, rtype);
}

void vis_process_tick(Vis *vis, fd_set *readfds) {
Expand All @@ -168,9 +168,9 @@ void vis_process_tick(Vis *vis, fd_set *readfds) {
waitpid(current->pid, &status, 0);
just_destroy:
if (WIFSIGNALED(status))
vis_lua_process_responce(vis, current->name, NULL, WTERMSIG(status), SIGNAL);
vis_lua_process_response(vis, current->name, NULL, WTERMSIG(status), SIGNAL);
else
vis_lua_process_responce(vis, current->name, NULL, WEXITSTATUS(status), EXIT);
vis_lua_process_response(vis, current->name, NULL, WEXITSTATUS(status), EXIT);
destroy(pointer);
}
}
2 changes: 1 addition & 1 deletion vis-subprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct Process {
};

typedef struct Process Process;
typedef enum { STDOUT, STDERR, SIGNAL, EXIT } ResponceType;
typedef enum { STDOUT, STDERR, SIGNAL, EXIT } ResponseType;

Process *vis_process_communicate(Vis *, const char *command, const char *name,
void **invalidator);
Expand Down

0 comments on commit d8081d6

Please sign in to comment.