aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjixiuf <jixiuf@qq.com>2021-02-17 15:37:06 +0800
committerjixiuf <jixiuf@qq.com>2021-02-17 15:37:06 +0800
commite19da61668783239e47b1a7390fca10f38ceffa9 (patch)
treee4925942b1e0222e86d604c72fcac28f769c1d2c
parentf93553d9916f90fcfe7750d1a9e3c3ab28022269 (diff)
run clang-format *.[ch]
-rw-r--r--elisp.c3
-rw-r--r--vterm-module.c39
-rw-r--r--vterm-module.h9
3 files changed, 28 insertions, 23 deletions
diff --git a/elisp.c b/elisp.c
index 9ae32a0..24c7601 100644
--- a/elisp.c
+++ b/elisp.c
@@ -178,7 +178,8 @@ void set_cursor_type(emacs_env *env, emacs_value cursor_type) {
}
void set_cursor_blink(emacs_env *env, bool blink) {
- env->funcall(env, Fblink_cursor_mode, 1, (emacs_value[]){env->make_integer(env, blink)});
+ env->funcall(env, Fblink_cursor_mode, 1,
+ (emacs_value[]){env->make_integer(env, blink)});
}
emacs_value vterm_get_color(emacs_env *env, int index) {
diff --git a/vterm-module.c b/vterm-module.c
index 97bca43..a2cd4e8 100644
--- a/vterm-module.c
+++ b/vterm-module.c
@@ -260,7 +260,7 @@ static void goto_col(Term *term, emacs_env *env, int row, int end_col) {
forward_char(env, env->make_integer(env, end_col - offset));
emacs_value space = env->make_string(env, " ", 1);
- for (int i = 0 ; i < beyond_eol ; i += 1)
+ for (int i = 0; i < beyond_eol; i += 1)
insert(env, space);
}
@@ -271,18 +271,19 @@ static void refresh_lines(Term *term, emacs_env *env, int start_row,
}
int i, j;
-#define PUSH_BUFFER(c) do { \
- if (length == capacity) { \
- capacity += end_col * 4; \
- buffer = realloc(buffer, capacity * sizeof(char)); \
- } \
- buffer[length] = (c); \
- length++; \
+#define PUSH_BUFFER(c) \
+ do { \
+ if (length == capacity) { \
+ capacity += end_col * 4; \
+ buffer = realloc(buffer, capacity * sizeof(char)); \
+ } \
+ buffer[length] = (c); \
+ length++; \
} while (0)
int capacity = ((end_row - start_row + 1) * end_col) * 4;
int length = 0;
- char* buffer = malloc(capacity * sizeof(char));
+ char *buffer = malloc(capacity * sizeof(char));
VTermScreenCell cell;
VTermScreenCell lastCell;
fetch_cell(term, start_row, 0, &lastCell);
@@ -550,7 +551,7 @@ static void term_redraw_cursor(Term *term, emacs_env *env) {
if (term->cursor.cursor_type_changed) {
term->cursor.cursor_type_changed = false;
- if (! term->cursor.cursor_visible) {
+ if (!term->cursor.cursor_visible) {
set_cursor_type(env, Qnil);
return;
}
@@ -596,7 +597,7 @@ static void term_redraw(Term *term, emacs_env *env) {
}
while (term->elisp_code_first) {
- ElispCodeListNode* node = term->elisp_code_first;
+ ElispCodeListNode *node = term->elisp_code_first;
term->elisp_code_first = node->next;
emacs_value elisp_code = env->make_string(env, node->code, node->code_len);
vterm_eval(env, elisp_code);
@@ -750,10 +751,11 @@ static emacs_value render_text(emacs_env *env, Term *term, char *buffer,
int emacs_major_version =
env->extract_integer(env, symbol_value(env, Qemacs_major_version));
emacs_value properties;
- emacs_value props[64]; int props_len = 0;
- if (env->is_not_nil (env, fg))
+ emacs_value props[64];
+ int props_len = 0;
+ if (env->is_not_nil(env, fg))
props[props_len++] = Qforeground, props[props_len++] = fg;
- if (env->is_not_nil (env, bg))
+ if (env->is_not_nil(env, bg))
props[props_len++] = Qbackground, props[props_len++] = bg;
if (bold != Qnil)
props[props_len++] = Qweight, props[props_len++] = bold;
@@ -768,7 +770,7 @@ static emacs_value render_text(emacs_env *env, Term *term, char *buffer,
if (emacs_major_version >= 27)
props[props_len++] = Qextend, props[props_len++] = Qt;
- properties = list (env, props, props_len);
+ properties = list(env, props, props_len);
if (props_len)
put_text_property(env, text, Qface, properties);
@@ -997,7 +999,7 @@ void term_finalize(void *object) {
}
while (term->elisp_code_first) {
- ElispCodeListNode* node = term->elisp_code_first;
+ ElispCodeListNode *node = term->elisp_code_first;
term->elisp_code_first = node->next;
free(node->code);
free(node);
@@ -1062,7 +1064,7 @@ static int handle_osc_cmd_51(Term *term, char subCmd, char *buffer) {
} else if (subCmd == 'E') {
/* "51;E" executes elisp code */
/* The elisp code is executed in term_redraw */
- ElispCodeListNode* node = malloc(sizeof(ElispCodeListNode));
+ ElispCodeListNode *node = malloc(sizeof(ElispCodeListNode));
node->code_len = strlen(buffer);
node->code = malloc(node->code_len + 1);
strcpy(node->code, buffer);
@@ -1425,7 +1427,8 @@ int emacs_module_init(struct emacs_runtime *ert) {
Qcursor_type = env->make_global_ref(env, env->intern(env, "cursor-type"));
// Functions
- Fblink_cursor_mode = env->make_global_ref(env, env->intern(env, "blink-cursor-mode"));
+ Fblink_cursor_mode =
+ env->make_global_ref(env, env->intern(env, "blink-cursor-mode"));
Fsymbol_value = env->make_global_ref(env, env->intern(env, "symbol-value"));
Flength = env->make_global_ref(env, env->intern(env, "length"));
Flist = env->make_global_ref(env, env->intern(env, "list"));
diff --git a/vterm-module.h b/vterm-module.h
index e642b76..5cb1f6d 100644
--- a/vterm-module.h
+++ b/vterm-module.h
@@ -31,9 +31,9 @@ typedef struct ScrollbackLine {
} ScrollbackLine;
typedef struct ElispCodeListNode {
- char* code;
+ char *code;
size_t code_len;
- struct ElispCodeListNode* next;
+ struct ElispCodeListNode *next;
} ElispCodeListNode;
/* c , p , q , s , 0 , 1 , 2 , 3 , 4 , 5 , 6 , and 7 */
@@ -79,8 +79,9 @@ typedef struct Term {
// Single-linked list of elisp_code.
// Newer commands are added at the tail.
- ElispCodeListNode* elisp_code_first;
- ElispCodeListNode** elisp_code_p_insert; // pointer to the position where new node should be inserted
+ ElispCodeListNode *elisp_code_first;
+ ElispCodeListNode **elisp_code_p_insert; // pointer to the position where new
+ // node should be inserted
/* c , p , q , s , 0 , 1 , 2 , 3 , 4 , 5 , 6 , and 7 */
/* clipboard, primary, secondary, select, or cut buffers 0 through 7 */