Skip to content

Commit a1a5ceb

Browse files
committed
rename command_stack to command_log
1 parent 2cf317f commit a1a5ceb

6 files changed

Lines changed: 25 additions & 25 deletions

File tree

src/commands.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
#include "commands.h"
55
#include "controller.h"
66

7-
command_stack_t *init_command_stack(void) {
8-
command_stack_t *cs = malloc(sizeof(command_stack_t));
7+
command_log_t *init_command_log(void) {
8+
command_log_t *cs = malloc(sizeof(command_log_t));
99
cs->top = NULL;
1010
cs->bottom = NULL;
1111

1212
return cs;
1313
}
1414

15-
void destroy_command_stack(command_stack_t *cs) {
15+
void destroy_command_log(command_log_t *cs) {
1616
command_t *c = cs->bottom, *tmp;
1717

1818
while (c) {
@@ -40,7 +40,7 @@ bool is_nav_command(command_t *c) {
4040
// -------------------------
4141
// -- History Stack methods
4242
// -------------------------
43-
command_t *append_command(command_stack_t *cs, command_t *c) {
43+
command_t *append_command(command_log_t *cs, command_t *c) {
4444
// assert valid state
4545
assert((!cs->top && !cs->bottom) || (cs->top && cs->bottom));
4646

@@ -61,7 +61,7 @@ command_t *append_command(command_stack_t *cs, command_t *c) {
6161
return c;
6262
}
6363

64-
command_t *pop_command(command_stack_t *cs) {
64+
command_t *pop_command(command_log_t *cs) {
6565
assert((!cs->top && !cs->bottom) || (cs->top && cs->bottom));
6666

6767
if (!cs->top && !cs->bottom) {

src/commands.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ typedef struct command {
2828
struct command *prev;
2929
} command_t;
3030

31-
typedef struct command_stack {
31+
typedef struct command_log {
3232
struct command *bottom;
3333
struct command *top;
34-
} command_stack_t;
34+
} command_log_t;
3535

36-
command_stack_t *init_command_stack(void);
36+
command_log_t *init_command_log(void);
3737

38-
void destroy_command_stack(command_stack_t *cs);
38+
void destroy_command_log(command_log_t *);
3939

4040
command_t *init_command(COMMAND_TYPE t, COMMAND_PAYLOAD p);
4141

42-
bool is_nav_command(command_t *c);
42+
bool is_nav_command(command_t *);
4343

44-
command_t *append_command(command_stack_t *cs, command_t *c);
44+
command_t *append_command(command_log_t *cs, command_t *c);
4545

46-
command_t *pop_command(command_stack_t *cs);
46+
command_t *pop_command(command_log_t *cs);
4747

4848
#endif

src/controller.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static void dispatch_command(state_t *st, command_t *c) {
185185
}
186186

187187
void replay_history(state_t *st) {
188-
command_stack_t *hs = st->hs;
188+
command_log_t *hs = st->hs;
189189
command_t *c = hs->bottom;
190190

191191
// TODO copy init buffer but not reconstruct it
@@ -210,8 +210,8 @@ void apply_command(state_t *st, COMMAND_TYPE t, COMMAND_PAYLOAD p) {
210210
dispatch_command(st, c);
211211

212212
// FIXME kill this when implemented redo
213-
destroy_command_stack(st->rs);
214-
st->rs = init_command_stack();
213+
destroy_command_log(st->rs);
214+
st->rs = init_command_log();
215215
}
216216

217217
/*

src/state.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ state_t *init_state(const char *filename) {
1515
st->scr = init_screen(LINES);
1616

1717
// history stack
18-
st->hs = init_command_stack();
18+
st->hs = init_command_log();
1919
// redo stack
20-
st->rs = init_command_stack();
20+
st->rs = init_command_log();
2121

2222
st->status_row = init_row(NULL);
2323
st->prev_key = '\0';
@@ -31,8 +31,8 @@ void destroy_state(state_t *st) {
3131
destroy_buffer(st->buf);
3232
destroy_screen(st->scr);
3333
destroy_row(st->status_row);
34-
destroy_command_stack(st->hs);
35-
destroy_command_stack(st->rs);
34+
destroy_command_log(st->hs);
35+
destroy_command_log(st->rs);
3636
free(st);
3737
}
3838

src/state.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ typedef struct state {
1212
buffer_t *buf;
1313
screen_t *scr;
1414

15-
command_stack_t *hs;
16-
command_stack_t *rs;
15+
command_log_t *hs;
16+
command_log_t *rs;
1717

1818
size_t cx, cy;
1919
size_t top_row;

tests/commands-test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#include "../src/commands.h"
66

7-
static void test_command_stack(void) {
8-
command_stack_t *cs = init_command_stack();
7+
static void test_command_log(void) {
8+
command_log_t *cs = init_command_log();
99
COMMAND_PAYLOAD p;
1010

1111
COMMAND_TYPE t1 = HANDLE_APPEND_ROW;
@@ -76,11 +76,11 @@ static void test_command_stack(void) {
7676
assert(c1->next == NULL);
7777
free(tmp);
7878

79-
destroy_command_stack(cs);
79+
destroy_command_log(cs);
8080
}
8181

8282
int main(void) {
83-
test_command_stack();
83+
test_command_log();
8484

8585
return 0;
8686
}

0 commit comments

Comments
 (0)