Skip to content

Commit

Permalink
Draw collaborator cursors on screen
Browse files Browse the repository at this point in the history
  • Loading branch information
newsch committed May 26, 2019
1 parent 34154bd commit 92fd3eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
22 changes: 12 additions & 10 deletions src/frontend.c
Expand Up @@ -423,8 +423,8 @@ int main(int argc, char *argv[]) {
} else if (fd == 0) { // process keyboard activity
master_handler(state, canvas_win, status_interface->info_win);
draw_collab_cursors(state);
net_update_pos(state);
refresh_screen();
net_update_pos(state);
}
}
}
Expand All @@ -449,12 +449,12 @@ void setup_colors() {

// TODO: Use #define to get colors for standard uses
// Assign color codes
init_pair(1, COLOR_RED, COLOR_BLACK);
init_pair(2, COLOR_GREEN, COLOR_BLACK);
init_pair(3, COLOR_BLUE, COLOR_BLACK);
init_pair(4, COLOR_CYAN, COLOR_BLACK);
init_pair(5, COLOR_MAGENTA, COLOR_BLACK);
init_pair(6, COLOR_YELLOW, COLOR_BLACK);
init_pair(1, COLOR_WHITE, COLOR_BLUE);
init_pair(2, COLOR_WHITE, COLOR_GREEN);
init_pair(3, COLOR_WHITE, COLOR_RED);
init_pair(4, COLOR_WHITE, COLOR_CYAN);
init_pair(5, COLOR_WHITE, COLOR_MAGENTA);
init_pair(6, COLOR_WHITE, COLOR_YELLOW);
init_pair(7, COLOR_BLACK, COLOR_WHITE);
}

Expand Down Expand Up @@ -508,9 +508,11 @@ void draw_collab_cursors(State *state) {
if (c != NULL && (c->x >= min_x && c->y <= max_x) &&
(c->y >= min_y && c->y <= max_y)) {
logd("Drawing collab %i\n", c->uid);
// TODO: set reverse video and color at this point
if (has_colors()) {
}
const int color = has_colors() ? (i % 6) + 1 : 0;
// TODO: blink cursor with A_BLINK attribute (needs to pause between
// updates/only move on changes?)
mvwchgat(canvas_win, c->y - view->y + 1, c->x - view->x + 1, 1, 0, color,
NULL);
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/network.c
Expand Up @@ -139,10 +139,7 @@ void collab_list_free(collab_list_t *l) {

int collab_list_add(collab_list_t *l, int uid, int y, int x) {
int i;
logd("Foo\n");
logd("list: %p\n", l);
for (i = 0; i < l->len; i++) {
logd("Loop %i\n", i);
if (l->list[i] == NULL) {
l->list[i] = collab_create(uid, y, x);
l->num++;
Expand Down Expand Up @@ -177,9 +174,7 @@ int collab_list_del(collab_list_t *l, int uid) {

int collab_list_upd(collab_list_t *l, int uid, int y, int x) {
int i;
logd("foo\n");
for (i = 0; i < l->len; i++) {
logd("upd Loop: %d\n", i);
if (l->list[i] != NULL && l->list[i]->uid == uid) {
l->list[i]->x = x;
l->list[i]->y = y;
Expand Down

0 comments on commit 92fd3eb

Please sign in to comment.