ref: beeb85720e59861cd9f726752b119c8a52e47fde
parent: bb6552178c9b4704c26478df3b4a850b9f8a6dec
author: cancel <cancel@cancel.fm>
date: Mon Jan 13 05:59:11 EST 2020
[Automated] Change style to right-pointers
--- a/.clang-format
+++ b/.clang-format
@@ -1,5 +1,4 @@
BasedOnStyle: LLVM
-PointerAlignment: Left
ReflowComments: false
MacroBlockBegin: "^BEGIN_OPERATOR"
--- a/bank.c
+++ b/bank.c
@@ -1,13 +1,13 @@
#include "bank.h"
-void oevent_list_init(Oevent_list* olist) {
+void oevent_list_init(Oevent_list *olist) {
olist->buffer = NULL;
olist->count = 0;
olist->capacity = 0;
}
-void oevent_list_deinit(Oevent_list* olist) { free(olist->buffer); }
-void oevent_list_clear(Oevent_list* olist) { olist->count = 0; }
-void oevent_list_copy(Oevent_list const* src, Oevent_list* dest) {
+void oevent_list_deinit(Oevent_list *olist) { free(olist->buffer); }
+void oevent_list_clear(Oevent_list *olist) { olist->count = 0; }
+void oevent_list_copy(Oevent_list const *src, Oevent_list *dest) {
Usz src_count = src->count;
if (dest->capacity < src_count) {
Usz new_cap = orca_round_up_power2(src_count);
@@ -17,7 +17,7 @@
memcpy(dest->buffer, src->buffer, src_count * sizeof(Oevent));
dest->count = src_count;
}
-Oevent* oevent_list_alloc_item(Oevent_list* olist) {
+Oevent *oevent_list_alloc_item(Oevent_list *olist) {
Usz count = olist->count;
if (olist->capacity == count) {
// Note: no overflow check, but you're probably out of memory if this
@@ -27,7 +27,7 @@
olist->buffer = realloc(olist->buffer, capacity * sizeof(Oevent));
olist->capacity = capacity;
}
- Oevent* result = olist->buffer + count;
+ Oevent *result = olist->buffer + count;
olist->count = count + 1;
return result;
}
--- a/bank.h
+++ b/bank.h
@@ -45,15 +45,15 @@
} Oevent;
typedef struct {
- Oevent* buffer;
+ Oevent *buffer;
Usz count;
Usz capacity;
} Oevent_list;
-void oevent_list_init(Oevent_list* olist);
-void oevent_list_deinit(Oevent_list* olist);
-void oevent_list_clear(Oevent_list* olist);
+void oevent_list_init(Oevent_list *olist);
+void oevent_list_deinit(Oevent_list *olist);
+void oevent_list_clear(Oevent_list *olist);
ORCA_FORCE_NO_INLINE
-void oevent_list_copy(Oevent_list const* src, Oevent_list* dest);
+void oevent_list_copy(Oevent_list const *src, Oevent_list *dest);
ORCA_FORCE_NO_INLINE
-Oevent* oevent_list_alloc_item(Oevent_list* olist);
+Oevent *oevent_list_alloc_item(Oevent_list *olist);
--- a/cli_main.c
+++ b/cli_main.c
@@ -18,11 +18,11 @@
// clang-format on
}
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
static struct option cli_options[] = {{"help", no_argument, 0, 'h'},
{NULL, 0, NULL, 0}};
- char* input_file = NULL;
+ char *input_file = NULL;
int ticks = 1;
for (;;) {
@@ -73,7 +73,7 @@
Field_load_error fle = field_load_file(input_file, &field);
if (fle != Field_load_error_ok) {
field_deinit(&field);
- char const* errstr = "Unknown";
+ char const *errstr = "Unknown";
switch (fle) {
case Field_load_error_ok:
break;
--- a/field.c
+++ b/field.c
@@ -2,13 +2,13 @@
#include "gbuffer.h"
#include <ctype.h>
-void field_init(Field* f) {
+void field_init(Field *f) {
f->buffer = NULL;
f->height = 0;
f->width = 0;
}
-void field_init_fill(Field* f, Usz height, Usz width, Glyph fill_char) {
+void field_init_fill(Field *f, Usz height, Usz width, Glyph fill_char) {
assert(height <= ORCA_Y_MAX && width <= ORCA_X_MAX);
Usz num_cells = height * width;
f->buffer = malloc(num_cells * sizeof(Glyph));
@@ -17,9 +17,9 @@
f->width = (U16)width;
}
-void field_deinit(Field* f) { free(f->buffer); }
+void field_deinit(Field *f) { free(f->buffer); }
-void field_resize_raw(Field* f, Usz height, Usz width) {
+void field_resize_raw(Field *f, Usz height, Usz width) {
assert(height <= ORCA_Y_MAX && width <= ORCA_X_MAX);
Usz cells = height * width;
f->buffer = realloc(f->buffer, cells * sizeof(Glyph));
@@ -27,13 +27,13 @@
f->width = (U16)width;
}
-void field_resize_raw_if_necessary(Field* field, Usz height, Usz width) {
+void field_resize_raw_if_necessary(Field *field, Usz height, Usz width) {
if (field->height != height || field->width != width) {
field_resize_raw(field, height, width);
}
}
-void field_copy(Field* src, Field* dest) {
+void field_copy(Field *src, Field *dest) {
field_resize_raw_if_necessary(dest, src->height, src->width);
gbuffer_copy_subrect(src->buffer, dest->buffer, src->height, src->width,
dest->height, dest->width, 0, 0, 0, 0, src->height,
@@ -42,16 +42,16 @@
static inline bool glyph_char_is_valid(char c) { return c >= '!' && c <= '~'; }
-void field_fput(Field* f, FILE* stream) {
+void field_fput(Field *f, FILE *stream) {
enum { Column_buffer_count = 4096 };
char out_buffer[Column_buffer_count];
Usz f_height = f->height;
Usz f_width = f->width;
- Glyph* f_buffer = f->buffer;
+ Glyph *f_buffer = f->buffer;
if (f_width > Column_buffer_count - 2)
return;
for (Usz iy = 0; iy < f_height; ++iy) {
- Glyph* row_p = f_buffer + f_width * iy;
+ Glyph *row_p = f_buffer + f_width * iy;
for (Usz ix = 0; ix < f_width; ++ix) {
char c = row_p[ix];
out_buffer[ix] = glyph_char_is_valid(c) ? c : '?';
@@ -62,8 +62,8 @@
}
}
-Field_load_error field_load_file(char const* filepath, Field* field) {
- FILE* file = fopen(filepath, "r");
+Field_load_error field_load_file(char const *filepath, Field *field) {
+ FILE *file = fopen(filepath, "r");
if (file == NULL) {
return Field_load_error_cant_open_file;
}
@@ -72,7 +72,7 @@
Usz first_row_columns = 0;
Usz rows = 0;
for (;;) {
- char* s = fgets(buf, Bufsize, file);
+ char *s = fgets(buf, Bufsize, file);
if (s == NULL)
break;
if (rows == ORCA_Y_MAX) {
@@ -105,7 +105,7 @@
return Field_load_error_not_a_rectangle;
}
field_resize_raw(field, rows + 1, first_row_columns);
- Glyph* rowbuff = field->buffer + first_row_columns * rows;
+ Glyph *rowbuff = field->buffer + first_row_columns * rows;
for (Usz i = 0; i < len; ++i) {
char c = buf[i];
rowbuff[i] = glyph_char_is_valid(c) ? c : '.';
@@ -116,8 +116,8 @@
return Field_load_error_ok;
}
-char const* field_load_error_string(Field_load_error fle) {
- char const* errstr = "Unknown";
+char const *field_load_error_string(Field_load_error fle) {
+ char const *errstr = "Unknown";
switch (fle) {
case Field_load_error_ok:
errstr = "OK";
@@ -141,12 +141,12 @@
return errstr;
}
-void mbuf_reusable_init(Mbuf_reusable* mbr) {
+void mbuf_reusable_init(Mbuf_reusable *mbr) {
mbr->buffer = NULL;
mbr->capacity = 0;
}
-void mbuf_reusable_ensure_size(Mbuf_reusable* mbr, Usz height, Usz width) {
+void mbuf_reusable_ensure_size(Mbuf_reusable *mbr, Usz height, Usz width) {
Usz capacity = height * width;
if (mbr->capacity < capacity) {
mbr->buffer = realloc(mbr->buffer, capacity);
@@ -154,4 +154,4 @@
}
}
-void mbuf_reusable_deinit(Mbuf_reusable* mbr) { free(mbr->buffer); }
+void mbuf_reusable_deinit(Mbuf_reusable *mbr) { free(mbr->buffer); }
--- a/field.h
+++ b/field.h
@@ -7,18 +7,18 @@
// might want to do. Not used by the VM.
typedef struct {
- Glyph* buffer;
+ Glyph *buffer;
U16 height;
U16 width;
} Field;
-void field_init(Field* field);
-void field_init_fill(Field* field, Usz height, Usz width, Glyph fill_char);
-void field_deinit(Field* field);
-void field_resize_raw(Field* field, Usz height, Usz width);
-void field_resize_raw_if_necessary(Field* field, Usz height, Usz width);
-void field_copy(Field* src, Field* dest);
-void field_fput(Field* field, FILE* stream);
+void field_init(Field *field);
+void field_init_fill(Field *field, Usz height, Usz width, Glyph fill_char);
+void field_deinit(Field *field);
+void field_resize_raw(Field *field, Usz height, Usz width);
+void field_resize_raw_if_necessary(Field *field, Usz height, Usz width);
+void field_copy(Field *src, Field *dest);
+void field_fput(Field *field, FILE *stream);
typedef enum {
Field_load_error_ok = 0,
@@ -29,9 +29,9 @@
Field_load_error_not_a_rectangle = 5,
} Field_load_error;
-Field_load_error field_load_file(char const* filepath, Field* field);
+Field_load_error field_load_file(char const *filepath, Field *field);
-char const* field_load_error_string(Field_load_error fle);
+char const *field_load_error_string(Field_load_error fle);
// A reusable buffer for the per-grid-cell flags. Similar to how Field is a
// reusable buffer for Glyph, Mbuf_reusable is for Mark. The naming isn't so
@@ -42,10 +42,10 @@
// that functionality.
typedef struct Mbuf_reusable {
- Mark* buffer;
+ Mark *buffer;
Usz capacity;
} Mbuf_reusable;
-void mbuf_reusable_init(Mbuf_reusable* mbr);
-void mbuf_reusable_ensure_size(Mbuf_reusable* mbr, Usz height, Usz width);
-void mbuf_reusable_deinit(Mbuf_reusable* mbr);
+void mbuf_reusable_init(Mbuf_reusable *mbr);
+void mbuf_reusable_ensure_size(Mbuf_reusable *mbr, Usz height, Usz width);
+void mbuf_reusable_deinit(Mbuf_reusable *mbr);
--- a/gbuffer.c
+++ b/gbuffer.c
@@ -1,6 +1,6 @@
#include "gbuffer.h"
-void gbuffer_copy_subrect(Glyph* src, Glyph* dest, Usz src_height,
+void gbuffer_copy_subrect(Glyph *src, Glyph *dest, Usz src_height,
Usz src_width, Usz dest_height, Usz dest_width,
Usz src_y, Usz src_x, Usz dest_y, Usz dest_x,
Usz height, Usz width) {
@@ -24,8 +24,8 @@
if (row_copy_1 < row_copy)
row_copy = row_copy_1;
Usz copy_bytes = row_copy * sizeof(Glyph);
- Glyph* src_p = src + src_y * src_width + src_x;
- Glyph* dest_p = dest + dest_y * dest_width + dest_x;
+ Glyph *src_p = src + src_y * src_width + src_x;
+ Glyph *dest_p = dest + dest_y * dest_width + dest_x;
Isz src_stride;
Isz dest_stride;
if (src_y >= dest_y) {
@@ -48,7 +48,7 @@
}
}
-void gbuffer_fill_subrect(Glyph* gbuffer, Usz f_height, Usz f_width, Usz y,
+void gbuffer_fill_subrect(Glyph *gbuffer, Usz f_height, Usz f_width, Usz y,
Usz x, Usz height, Usz width, Glyph fill_char) {
if (y >= f_height || x >= f_width)
return;
@@ -63,7 +63,7 @@
if (columns_0 < columns)
columns = columns_0;
Usz fill_bytes = columns * sizeof(Glyph);
- Glyph* p = gbuffer + y * f_width + x;
+ Glyph *p = gbuffer + y * f_width + x;
Usz iy = 0;
for (;;) {
memset(p, fill_char, fill_bytes);
@@ -74,7 +74,7 @@
}
}
-void mbuffer_clear(Mark* mbuf, Usz height, Usz width) {
+void mbuffer_clear(Mark *mbuf, Usz height, Usz width) {
Usz cleared_size = height * width;
memset(mbuf, 0, cleared_size);
}
--- a/gbuffer.h
+++ b/gbuffer.h
@@ -1,7 +1,7 @@
#pragma once
#include "base.h"
-ORCA_PURE static inline Glyph gbuffer_peek(Glyph* gbuf, Usz height, Usz width,
+ORCA_PURE static inline Glyph gbuffer_peek(Glyph *gbuf, Usz height, Usz width,
Usz y, Usz x) {
assert(y < height && x < width);
(void)height;
@@ -8,7 +8,7 @@
return gbuf[y + width + x];
}
-ORCA_PURE static inline Glyph gbuffer_peek_relative(Glyph* gbuf, Usz height,
+ORCA_PURE static inline Glyph gbuffer_peek_relative(Glyph *gbuf, Usz height,
Usz width, Usz y, Usz x,
Isz delta_y, Isz delta_x) {
Isz y0 = (Isz)y + delta_y;
@@ -18,7 +18,7 @@
return gbuf[(Usz)y0 * width + (Usz)x0];
}
-static inline void gbuffer_poke(Glyph* gbuf, Usz height, Usz width, Usz y,
+static inline void gbuffer_poke(Glyph *gbuf, Usz height, Usz width, Usz y,
Usz x, Glyph g) {
assert(y < height && x < width);
(void)height;
@@ -25,7 +25,7 @@
gbuf[y * width + x] = g;
}
-static inline void gbuffer_poke_relative(Glyph* gbuf, Usz height, Usz width,
+static inline void gbuffer_poke_relative(Glyph *gbuf, Usz height, Usz width,
Usz y, Usz x, Isz delta_y, Isz delta_x,
Glyph g) {
Isz y0 = (Isz)y + delta_y;
@@ -36,13 +36,13 @@
}
ORCA_FORCE_NO_INLINE
-void gbuffer_copy_subrect(Glyph* src, Glyph* dest, Usz src_grid_h,
+void gbuffer_copy_subrect(Glyph *src, Glyph *dest, Usz src_grid_h,
Usz src_grid_w, Usz dest_grid_h, Usz dest_grid_w,
Usz src_y, Usz src_x, Usz dest_y, Usz dest_x,
Usz height, Usz width);
ORCA_FORCE_NO_INLINE
-void gbuffer_fill_subrect(Glyph* gbuf, Usz grid_h, Usz grid_w, Usz y, Usz x,
+void gbuffer_fill_subrect(Glyph *gbuf, Usz grid_h, Usz grid_w, Usz y, Usz x,
Usz height, Usz width, Glyph fill_char);
typedef enum {
@@ -55,7 +55,7 @@
} Mark_flags;
ORCA_OK_IF_UNUSED
-static Mark_flags mbuffer_peek(Mark* mbuf, Usz height, Usz width, Usz y,
+static Mark_flags mbuffer_peek(Mark *mbuf, Usz height, Usz width, Usz y,
Usz x) {
(void)height;
return mbuf[y * width + x];
@@ -62,7 +62,7 @@
}
ORCA_OK_IF_UNUSED
-static Mark_flags mbuffer_peek_relative(Mark* mbuf, Usz height, Usz width,
+static Mark_flags mbuffer_peek_relative(Mark *mbuf, Usz height, Usz width,
Usz y, Usz x, Isz offs_y, Isz offs_x) {
Isz y0 = (Isz)y + offs_y;
Isz x0 = (Isz)x + offs_x;
@@ -72,7 +72,7 @@
}
ORCA_OK_IF_UNUSED
-static void mbuffer_poke_flags_or(Mark* mbuf, Usz height, Usz width, Usz y,
+static void mbuffer_poke_flags_or(Mark *mbuf, Usz height, Usz width, Usz y,
Usz x, Mark_flags flags) {
(void)height;
mbuf[y * width + x] |= (Mark)flags;
@@ -79,7 +79,7 @@
}
ORCA_OK_IF_UNUSED
-static void mbuffer_poke_relative_flags_or(Mark* mbuf, Usz height, Usz width,
+static void mbuffer_poke_relative_flags_or(Mark *mbuf, Usz height, Usz width,
Usz y, Usz x, Isz offs_y, Isz offs_x,
Mark_flags flags) {
Isz y0 = (Isz)y + offs_y;
@@ -89,4 +89,4 @@
mbuf[(Usz)y0 * width + (Usz)x0] |= (Mark)flags;
}
-void mbuffer_clear(Mark* mbuf, Usz height, Usz width);
+void mbuffer_clear(Mark *mbuf, Usz height, Usz width);
--- a/osc_out.c
+++ b/osc_out.c
@@ -11,13 +11,13 @@
int fd;
// Just keep the whole list around, since juggling the strict-aliasing
// problems with sockaddr_storage is not worth it.
- struct addrinfo* chosen;
- struct addrinfo* head;
+ struct addrinfo *chosen;
+ struct addrinfo *head;
};
-Oosc_udp_create_error oosc_dev_create_udp(Oosc_dev** out_ptr,
- char const* dest_addr,
- char const* dest_port) {
+Oosc_udp_create_error oosc_dev_create_udp(Oosc_dev **out_ptr,
+ char const *dest_addr,
+ char const *dest_port) {
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
@@ -24,8 +24,8 @@
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = 0;
hints.ai_flags = AI_ADDRCONFIG;
- struct addrinfo* chosen = NULL;
- struct addrinfo* head = NULL;
+ struct addrinfo *chosen = NULL;
+ struct addrinfo *head = NULL;
int err = getaddrinfo(dest_addr, dest_port, &hints, &head);
if (err != 0) {
fprintf(stderr, "Failed to get address info, error: %d\n", errno);
@@ -43,7 +43,7 @@
if (!dest_addr) {
#endif
{
- for (struct addrinfo* a = head; a; a = a->ai_next) {
+ for (struct addrinfo *a = head; a; a = a->ai_next) {
if (a->ai_family != AF_INET)
continue;
chosen = a;
@@ -77,7 +77,7 @@
freeaddrinfo(head);
return Oosc_udp_create_error_couldnt_open_socket;
}
- Oosc_dev* dev = malloc(sizeof(Oosc_dev));
+ Oosc_dev *dev = malloc(sizeof(Oosc_dev));
dev->fd = udpfd;
dev->chosen = chosen;
dev->head = head;
@@ -85,13 +85,13 @@
return Oosc_udp_create_error_ok;
}
-void oosc_dev_destroy(Oosc_dev* dev) {
+void oosc_dev_destroy(Oosc_dev *dev) {
close(dev->fd);
freeaddrinfo(dev->head);
free(dev);
}
-void oosc_send_datagram(Oosc_dev* dev, char const* data, Usz size) {
+void oosc_send_datagram(Oosc_dev *dev, char const *data, Usz size) {
ssize_t res = sendto(dev->fd, data, size, 0, dev->chosen->ai_addr,
dev->chosen->ai_addrlen);
if (res < 0) {
@@ -100,8 +100,8 @@
}
}
-static bool oosc_write_strn(char* restrict buffer, Usz buffer_size,
- Usz* buffer_pos, char const* restrict in_str,
+static bool oosc_write_strn(char *restrict buffer, Usz buffer_size,
+ Usz *buffer_pos, char const *restrict in_str,
Usz in_str_len) {
// no overflow check, should be fine
Usz in_plus_null = in_str_len + 1;
@@ -122,7 +122,7 @@
return true;
}
-void oosc_send_int32s(Oosc_dev* dev, char const* osc_address, I32 const* vals,
+void oosc_send_int32s(Oosc_dev *dev, char const *osc_address, I32 const *vals,
Usz count) {
char buffer[2048];
Usz buf_pos = 0;
@@ -160,20 +160,20 @@
oosc_send_datagram(dev, buffer, buf_pos);
}
-void susnote_list_init(Susnote_list* sl) {
+void susnote_list_init(Susnote_list *sl) {
sl->buffer = NULL;
sl->count = 0;
sl->capacity = 0;
}
-void susnote_list_deinit(Susnote_list* sl) { free(sl->buffer); }
+void susnote_list_deinit(Susnote_list *sl) { free(sl->buffer); }
-void susnote_list_clear(Susnote_list* sl) { sl->count = 0; }
+void susnote_list_clear(Susnote_list *sl) { sl->count = 0; }
-void susnote_list_add_notes(Susnote_list* sl, Susnote const* restrict notes,
- Usz added_count, Usz* restrict start_removed,
- Usz* restrict end_removed) {
- Susnote* buffer = sl->buffer;
+void susnote_list_add_notes(Susnote_list *sl, Susnote const *restrict notes,
+ Usz added_count, Usz *restrict start_removed,
+ Usz *restrict end_removed) {
+ Susnote *buffer = sl->buffer;
Usz count = sl->count;
Usz cap = sl->capacity;
Usz rem = count + added_count;
@@ -205,11 +205,11 @@
*end_removed = rem;
}
-void susnote_list_advance_time(Susnote_list* sl, double delta_time,
- Usz* restrict start_removed,
- Usz* restrict end_removed,
- double* soonest_deadline) {
- Susnote* restrict buffer = sl->buffer;
+void susnote_list_advance_time(Susnote_list *sl, double delta_time,
+ Usz *restrict start_removed,
+ Usz *restrict end_removed,
+ double *soonest_deadline) {
+ Susnote *restrict buffer = sl->buffer;
Usz count = sl->count;
*end_removed = count;
float delta_float = (float)delta_time;
@@ -233,9 +233,9 @@
sl->count = count;
}
-double susnote_list_soonest_deadline(Susnote_list const* sl) {
+double susnote_list_soonest_deadline(Susnote_list const *sl) {
float soonest = 1.0f;
- Susnote const* buffer = sl->buffer;
+ Susnote const *buffer = sl->buffer;
for (Usz i = 0, n = sl->count; i < n; ++i) {
float rem = buffer[i].remaining;
if (rem < soonest)
--- a/osc_out.h
+++ b/osc_out.h
@@ -9,17 +9,17 @@
Oosc_udp_create_error_couldnt_open_socket = 2,
} Oosc_udp_create_error;
-Oosc_udp_create_error oosc_dev_create_udp(Oosc_dev** out_ptr,
- char const* dest_addr,
- char const* dest_port);
-void oosc_dev_destroy(Oosc_dev* dev);
+Oosc_udp_create_error oosc_dev_create_udp(Oosc_dev **out_ptr,
+ char const *dest_addr,
+ char const *dest_port);
+void oosc_dev_destroy(Oosc_dev *dev);
// Send a raw UDP datagram.
-void oosc_send_datagram(Oosc_dev* dev, char const* data, Usz size);
+void oosc_send_datagram(Oosc_dev *dev, char const *data, Usz size);
// Send a list/array of 32-bit integers in OSC format to the specified "osc
// address" (a path like /foo) as a UDP datagram.
-void oosc_send_int32s(Oosc_dev* dev, char const* osc_address, I32 const* vals,
+void oosc_send_int32s(Oosc_dev *dev, char const *osc_address, I32 const *vals,
Usz count);
// Susnote is for handling MIDI note sustains -- each MIDI on event should be
@@ -33,22 +33,22 @@
} Susnote;
typedef struct {
- Susnote* buffer;
+ Susnote *buffer;
Usz count;
Usz capacity;
} Susnote_list;
-void susnote_list_init(Susnote_list* sl);
-void susnote_list_deinit(Susnote_list* sl);
-void susnote_list_clear(Susnote_list* sl);
-void susnote_list_add_notes(Susnote_list* sl, Susnote const* restrict notes,
- Usz count, Usz* restrict start_removed,
- Usz* restrict end_removed);
+void susnote_list_init(Susnote_list *sl);
+void susnote_list_deinit(Susnote_list *sl);
+void susnote_list_clear(Susnote_list *sl);
+void susnote_list_add_notes(Susnote_list *sl, Susnote const *restrict notes,
+ Usz count, Usz *restrict start_removed,
+ Usz *restrict end_removed);
void susnote_list_advance_time(
- Susnote_list* sl, double delta_time, Usz* restrict start_removed,
- Usz* restrict end_removed,
+ Susnote_list *sl, double delta_time, Usz *restrict start_removed,
+ Usz *restrict end_removed,
// 1.0 if no notes remain or none are shorter than 1.0
- double* soonest_deadline);
+ double *soonest_deadline);
// Returns 1.0 if no notes remain or none are shorter than 1.0
-double susnote_list_soonest_deadline(Susnote_list const* sl);
+double susnote_list_soonest_deadline(Susnote_list const *sl);
--- a/sim.c
+++ b/sim.c
@@ -81,9 +81,9 @@
(caser & Case_bit));
}
-ORCA_PURE static bool oper_has_neighboring_bang(Glyph const* gbuf, Usz h, Usz w,
+ORCA_PURE static bool oper_has_neighboring_bang(Glyph const *gbuf, Usz h, Usz w,
Usz y, Usz x) {
- Glyph const* gp = gbuf + w * y + x;
+ Glyph const *gp = gbuf + w * y + x;
if (x < w - 1 && gp[1] == '*')
return true;
if (x > 0 && *(gp - 1) == '*')
@@ -146,12 +146,12 @@
}
typedef struct {
- Glyph* vars_slots;
- Oevent_list* oevent_list;
+ Glyph *vars_slots;
+ Oevent_list *oevent_list;
Usz random_seed;
} Oper_extra_params;
-static void oper_poke_and_stun(Glyph* restrict gbuffer, Mark* restrict mbuffer,
+static void oper_poke_and_stun(Glyph *restrict gbuffer, Mark *restrict mbuffer,
Usz height, Usz width, Usz y, Usz x, Isz delta_y,
Isz delta_x, Glyph g) {
Isz y0 = (Isz)y + delta_y;
@@ -167,9 +167,9 @@
#define BEGIN_OPERATOR(_oper_name) \
OPER_FUNCTION_ATTRIBS oper_behavior_##_oper_name( \
- Glyph* const restrict gbuffer, Mark* const restrict mbuffer, \
+ Glyph *const restrict gbuffer, Mark *const restrict mbuffer, \
Usz const height, Usz const width, Usz const y, Usz const x, \
- Usz Tick_number, Oper_extra_params* const extra_params, \
+ Usz Tick_number, Oper_extra_params *const extra_params, \
Mark const cell_flags, Glyph const This_oper_char) { \
(void)gbuffer; \
(void)mbuffer; \
@@ -288,7 +288,7 @@
gbuffer[y * width + x] = '*';
return;
}
- Glyph* restrict g_at_dest = gbuffer + (Usz)y0 * width + (Usz)x0;
+ Glyph *restrict g_at_dest = gbuffer + (Usz)y0 * width + (Usz)x0;
if (*g_at_dest == '.') {
*g_at_dest = This_oper_char;
gbuffer[y * width + x] = '.';
@@ -304,8 +304,8 @@
BEGIN_OPERATOR(comment)
// restrict probably ok here...
- Glyph const* restrict gline = gbuffer + y * width;
- Mark* restrict mline = mbuffer + y * width;
+ Glyph const *restrict gline = gbuffer + y * width;
+ Mark *restrict mline = mbuffer + y * width;
Usz max_x = x + 255;
if (width < max_x)
max_x = width;
@@ -342,8 +342,8 @@
Usz channel_num = index_of(channel_g);
if (channel_num > 15)
channel_num = 15;
- Oevent_midi* oe =
- (Oevent_midi*)oevent_list_alloc_item(extra_params->oevent_list);
+ Oevent_midi *oe =
+ (Oevent_midi *)oevent_list_alloc_item(extra_params->oevent_list);
oe->oevent_type = (U8)Oevent_type_midi;
oe->channel = (U8)channel_num;
oe->octave = octave_num;
@@ -356,8 +356,8 @@
Usz n = width - x - 1;
if (n > 16)
n = 16;
- Glyph const* restrict gline = gbuffer + y * width + x + 1;
- Mark* restrict mline = mbuffer + y * width + x + 1;
+ Glyph const *restrict gline = gbuffer + y * width + x + 1;
+ Mark *restrict mline = mbuffer + y * width + x + 1;
Glyph cpy[Oevent_udp_string_count];
Usz i;
for (i = 0; i < n; ++i) {
@@ -369,8 +369,8 @@
}
n = i;
STOP_IF_NOT_BANGED;
- Oevent_udp_string* oe =
- (Oevent_udp_string*)oevent_list_alloc_item(extra_params->oevent_list);
+ Oevent_udp_string *oe =
+ (Oevent_udp_string *)oevent_list_alloc_item(extra_params->oevent_list);
oe->oevent_type = (U8)Oevent_type_udp_string;
oe->count = (U8)n;
for (i = 0; i < n; ++i) {
@@ -394,7 +394,7 @@
for (Usz i = 0; i < len; ++i) {
buff[i] = (U8)index_of(PEEK(0, (Isz)i + 3));
}
- Oevent_osc_ints* oe =
+ Oevent_osc_ints *oe =
&oevent_list_alloc_item(extra_params->oevent_list)->osc_ints;
oe->oevent_type = (U8)Oevent_type_osc_ints;
oe->glyph = g;
@@ -737,8 +737,8 @@
//////// Run simulation
-void orca_run(Glyph* restrict gbuf, Mark* restrict mbuf, Usz height, Usz width,
- Usz tick_number, Oevent_list* oevent_list, Usz random_seed) {
+void orca_run(Glyph *restrict gbuf, Mark *restrict mbuf, Usz height, Usz width,
+ Usz tick_number, Oevent_list *oevent_list, Usz random_seed) {
Glyph vars_slots[Glyphs_index_count];
memset(vars_slots, '.', sizeof(vars_slots));
Oper_extra_params extras;
@@ -747,8 +747,8 @@
extras.random_seed = random_seed;
for (Usz iy = 0; iy < height; ++iy) {
- Glyph const* glyph_row = gbuf + iy * width;
- Mark const* mark_row = mbuf + iy * width;
+ Glyph const *glyph_row = gbuf + iy * width;
+ Mark const *mark_row = mbuf + iy * width;
for (Usz ix = 0; ix < width; ++ix) {
Glyph glyph_char = glyph_row[ix];
if (ORCA_LIKELY(glyph_char == '.'))
--- a/sim.h
+++ b/sim.h
@@ -2,6 +2,6 @@
#include "bank.h"
#include "base.h"
-void orca_run(Glyph* restrict gbuffer, Mark* restrict mbuffer, Usz height,
- Usz width, Usz tick_number, Oevent_list* oevent_list,
+void orca_run(Glyph *restrict gbuffer, Mark *restrict mbuffer, Usz height,
+ Usz width, Usz tick_number, Oevent_list *oevent_list,
Usz random_seed);
--- a/sysmisc.c
+++ b/sysmisc.c
@@ -6,15 +6,15 @@
#include <sys/stat.h>
ORCA_FORCE_NO_INLINE
-Cboard_error cboard_copy(Glyph const* gbuffer, Usz field_height,
+Cboard_error cboard_copy(Glyph const *gbuffer, Usz field_height,
Usz field_width, Usz rect_y, Usz rect_x, Usz rect_h,
Usz rect_w) {
(void)field_height;
- FILE* fp = popen("xclip -i -selection clipboard 2>/dev/null", "w");
+ FILE *fp = popen("xclip -i -selection clipboard 2>/dev/null", "w");
if (!fp)
return Cboard_error_popen_failed;
for (Usz iy = 0; iy < rect_h; iy++) {
- Glyph const* row = gbuffer + (rect_y + iy) * field_width + rect_x;
+ Glyph const *row = gbuffer + (rect_y + iy) * field_width + rect_x;
fwrite(row, sizeof(Glyph), rect_w, fp);
if (iy + 1 < rect_h)
fputc('\n', fp);
@@ -24,9 +24,9 @@
}
ORCA_FORCE_NO_INLINE
-Cboard_error cboard_paste(Glyph* gbuffer, Usz height, Usz width, Usz y, Usz x,
- Usz* out_h, Usz* out_w) {
- FILE* fp = popen("xclip -o -selection clipboard 2>/dev/null", "r");
+Cboard_error cboard_paste(Glyph *gbuffer, Usz height, Usz width, Usz y, Usz x,
+ Usz *out_h, Usz *out_w) {
+ FILE *fp = popen("xclip -o -selection clipboard 2>/dev/null", "r");
Usz start_y = y, start_x = x, max_y = y, max_x = x;
if (!fp)
return Cboard_error_popen_failed;
@@ -60,14 +60,14 @@
}
ORCA_FORCE_NO_INLINE
-Conf_read_result conf_read_line(FILE* file, char* buf, Usz bufsize,
- char** out_left, Usz* out_leftsize,
- char** out_right, Usz* out_rightsize) {
+Conf_read_result conf_read_line(FILE *file, char *buf, Usz bufsize,
+ char **out_left, Usz *out_leftsize,
+ char **out_right, Usz *out_rightsize) {
// a0 and a1 are the start and end positions of the left side of an "foo=bar"
// pair. b0 and b1 are the positions right side. Leading and trailing spaces
// will be removed.
Usz len, a0, a1, b0, b1;
- char* s;
+ char *s;
if (bufsize < 2)
goto insufficient_buffer;
#if SIZE_MAX > INT_MAX
@@ -177,12 +177,12 @@
Conf_dir_no_home,
} Conf_dir_error;
-static char const* const xdg_config_home_env = "XDG_CONFIG_HOME";
-static char const* const home_env = "HOME";
-static char const* const conf_file_name = "/orca.conf";
+static char const *const xdg_config_home_env = "XDG_CONFIG_HOME";
+static char const *const home_env = "HOME";
+static char const *const conf_file_name = "/orca.conf";
-static Conf_dir_error try_get_conf_dir(oso** out) {
- char const* xdgcfgdir = getenv(xdg_config_home_env);
+static Conf_dir_error try_get_conf_dir(oso **out) {
+ char const *xdgcfgdir = getenv(xdg_config_home_env);
if (xdgcfgdir) {
Usz xdgcfgdirlen = strlen(xdgcfgdir);
if (xdgcfgdirlen > 0) {
@@ -190,7 +190,7 @@
return Conf_dir_ok;
}
}
- char const* homedir = getenv(home_env);
+ char const *homedir = getenv(home_env);
if (homedir) {
Usz homedirlen = strlen(homedir);
if (homedirlen > 0) {
@@ -201,21 +201,21 @@
return Conf_dir_no_home;
}
-FILE* conf_file_open_for_reading(void) {
- oso* path = NULL;
+FILE *conf_file_open_for_reading(void) {
+ oso *path = NULL;
if (try_get_conf_dir(&path))
return NULL;
osocat(&path, conf_file_name);
if (!path)
return NULL;
- FILE* file = fopen(osoc(path), "r");
+ FILE *file = fopen(osoc(path), "r");
osofree(path);
return file;
}
-Conf_save_start_error conf_save_start(Conf_save* p) {
+Conf_save_start_error conf_save_start(Conf_save *p) {
memset(p, 0, sizeof(Conf_save));
- oso* dir = NULL;
+ oso *dir = NULL;
Conf_save_start_error err;
if (try_get_conf_dir(&dir)) {
err = Conf_save_start_no_home;
@@ -276,7 +276,7 @@
return err;
}
-void conf_save_cancel(Conf_save* p) {
+void conf_save_cancel(Conf_save *p) {
osofree(p->canonpath);
osofree(p->temppath);
if (p->origfile)
@@ -286,7 +286,7 @@
memset(p, 0, sizeof(Conf_save));
}
-Conf_save_commit_error conf_save_commit(Conf_save* p) {
+Conf_save_commit_error conf_save_commit(Conf_save *p) {
Conf_save_commit_error err;
fclose(p->tempfile);
p->tempfile = NULL;
--- a/sysmisc.h
+++ b/sysmisc.h
@@ -9,12 +9,12 @@
Cboard_error_process_exit_error,
} Cboard_error;
-Cboard_error cboard_copy(Glyph const* gbuffer, Usz field_height,
+Cboard_error cboard_copy(Glyph const *gbuffer, Usz field_height,
Usz field_width, Usz rect_y, Usz rect_x, Usz rect_h,
Usz rect_w);
-Cboard_error cboard_paste(Glyph* gbuffer, Usz height, Usz width, Usz y, Usz x,
- Usz* out_h, Usz* out_w);
+Cboard_error cboard_paste(Glyph *gbuffer, Usz height, Usz width, Usz y, Usz x,
+ Usz *out_h, Usz *out_w);
typedef enum {
Conf_read_left_and_right = 0, // left and right will be set
@@ -24,11 +24,11 @@
Conf_read_io_error, // "
} Conf_read_result;
-Conf_read_result conf_read_line(FILE* file, char* buf, Usz bufsize,
- char** out_left, Usz* out_leftlen,
- char** out_right, Usz* out_rightlen);
+Conf_read_result conf_read_line(FILE *file, char *buf, Usz bufsize,
+ char **out_left, Usz *out_leftlen,
+ char **out_right, Usz *out_rightlen);
-FILE* conf_file_open_for_reading(void);
+FILE *conf_file_open_for_reading(void);
typedef struct {
FILE *origfile, *tempfile;
@@ -53,7 +53,7 @@
Conf_save_commit_rename_failed,
} Conf_save_commit_error;
-Conf_save_start_error conf_save_start(Conf_save* p);
+Conf_save_start_error conf_save_start(Conf_save *p);
// `*p` may be passed in uninitialized or zeroed -- either is fine. If the
// return value is `Conf_save_start_ok`, then you must call either
// `conf_save_cancel()` or `conf_save_commit()`, otherwise file handles and
@@ -65,11 +65,11 @@
// there to be no existing config file. It might be the first time a config
// file is being written.
-void conf_save_cancel(Conf_save* p);
+void conf_save_cancel(Conf_save *p);
// Cancels a config save. Closes any file handles and frees any necessary
// strings. Calling with a zeroed `*p` is fine, but don't call it with
// uninitialized data. Afterwards, `*p` will be zeroed.
-Conf_save_commit_error conf_save_commit(Conf_save* p);
+Conf_save_commit_error conf_save_commit(Conf_save *p);
// Finishes. Do not call this with a zeroed `*p`. Afterwards, `*p` will be
// zeroed.
--- a/term_util.c
+++ b/term_util.c
@@ -30,7 +30,8 @@
}
#define ORCA_CONTAINER_OF(ptr, type, member) \
- ((type*)((char*)(1 ? (ptr) : &((type*)0)->member) - offsetof(type, member)))
+ ((type *)((char *)(1 ? (ptr) : &((type *)0)->member) - \
+ offsetof(type, member)))
struct Qmsg {
Qblock qblock;
@@ -44,11 +45,11 @@
struct Qmenu {
Qblock qblock;
- MENU* ncurses_menu;
- ITEM** ncurses_items;
+ MENU *ncurses_menu;
+ ITEM **ncurses_items;
Usz items_count;
Usz items_cap;
- ITEM* initial_item;
+ ITEM *initial_item;
int id;
// Flag for right-padding hack. Temp until we do our own menus
U8 has_submenu_item : 1;
@@ -56,8 +57,8 @@
struct Qform {
Qblock qblock;
- FORM* ncurses_form;
- FIELD* ncurses_fields[32];
+ FORM *ncurses_form;
+ FIELD *ncurses_fields[32];
Usz fields_count;
int id;
};
@@ -73,7 +74,7 @@
while (qnav_stack.count != 0)
qnav_stack_pop();
}
-static ORCA_FORCE_NO_INLINE void qnav_stack_push(Qblock* qb, int height,
+static ORCA_FORCE_NO_INLINE void qnav_stack_push(Qblock *qb, int height,
int width) {
#ifndef NDEBUG
for (Usz i = 0; i < qnav_stack.count; ++i) {
@@ -83,7 +84,7 @@
int top = 0, left = 0;
int total_h = height + 2, total_w = width + 2;
if (qnav_stack.count > 0) {
- WINDOW* w = qnav_stack.blocks[qnav_stack.count - 1]->outer_window;
+ WINDOW *w = qnav_stack.blocks[qnav_stack.count - 1]->outer_window;
int prev_y, prev_x, prev_h, prev_w;
getbegyx(w, prev_y, prev_x);
getmaxyx(w, prev_h, prev_w);
@@ -123,13 +124,13 @@
qnav_stack.stack_changed = true;
}
-Qblock* qnav_top_block() {
+Qblock *qnav_top_block() {
if (qnav_stack.count == 0)
return NULL;
return qnav_stack.blocks[qnav_stack.count - 1];
}
-void qblock_init(Qblock* qb, Qblock_type_tag tag) {
+void qblock_init(Qblock *qb, Qblock_type_tag tag) {
qb->tag = tag;
qb->outer_window = NULL;
qb->content_window = NULL;
@@ -136,13 +137,13 @@
qb->title = NULL;
}
-void qmenu_free(Qmenu* qm);
-void qform_free(Qform* qf);
+void qmenu_free(Qmenu *qm);
+void qform_free(Qform *qf);
-void qnav_free_block(Qblock* qb) {
+void qnav_free_block(Qblock *qb) {
switch (qb->tag) {
case Qblock_type_qmsg: {
- Qmsg* qm = qmsg_of(qb);
+ Qmsg *qm = qmsg_of(qb);
free(qm);
} break;
case Qblock_type_qmenu: {
@@ -158,9 +159,9 @@
assert(qnav_stack.count > 0);
if (qnav_stack.count == 0)
return;
- Qblock* qb = qnav_stack.blocks[qnav_stack.count - 1];
- WINDOW* content_window = qb->content_window;
- WINDOW* outer_window = qb->outer_window;
+ Qblock *qb = qnav_stack.blocks[qnav_stack.count - 1];
+ WINDOW *content_window = qb->content_window;
+ WINDOW *outer_window = qb->outer_window;
// erase any stuff underneath where this window is, in case it's outside of
// the grid in an area that isn't actively redraw
werase(outer_window);
@@ -173,13 +174,13 @@
qnav_stack.stack_changed = true;
}
-void qblock_print_border(Qblock* qb, unsigned int attr) {
+void qblock_print_border(Qblock *qb, unsigned int attr) {
wborder(qb->outer_window, ACS_VLINE | attr, ACS_VLINE | attr,
ACS_HLINE | attr, ACS_HLINE | attr, ACS_ULCORNER | attr,
ACS_URCORNER | attr, ACS_LLCORNER | attr, ACS_LRCORNER | attr);
}
-void qblock_print_title(Qblock* qb, char const* title, int attr) {
+void qblock_print_title(Qblock *qb, char const *title, int attr) {
wmove(qb->outer_window, 0, 1);
attr_t attrs = A_NORMAL;
short pair = 0;
@@ -191,15 +192,15 @@
wattr_set(qb->outer_window, attrs, pair, NULL);
}
-void qblock_set_title(Qblock* qb, char const* title) { qb->title = title; }
+void qblock_set_title(Qblock *qb, char const *title) { qb->title = title; }
-void qblock_print_frame(Qblock* qb, bool active) {
+void qblock_print_frame(Qblock *qb, bool active) {
qblock_print_border(qb, active ? A_NORMAL : A_DIM);
if (qb->title) {
qblock_print_title(qb, qb->title, active ? A_NORMAL : A_DIM);
}
if (qb->tag == Qblock_type_qform) {
- Qform* qf = qform_of(qb);
+ Qform *qf = qform_of(qb);
if (qf->ncurses_form) {
pos_form_cursor(qf->ncurses_form);
}
@@ -206,26 +207,26 @@
}
}
-WINDOW* qmsg_window(Qmsg* qm) { return qm->qblock.content_window; }
+WINDOW *qmsg_window(Qmsg *qm) { return qm->qblock.content_window; }
-void qmsg_set_title(Qmsg* qm, char const* title) {
+void qmsg_set_title(Qmsg *qm, char const *title) {
qblock_set_title(&qm->qblock, title);
}
-Qmsg* qmsg_push(int height, int width) {
- Qmsg* qm = malloc(sizeof(Qmsg));
+Qmsg *qmsg_push(int height, int width) {
+ Qmsg *qm = malloc(sizeof(Qmsg));
qblock_init(&qm->qblock, Qblock_type_qmsg);
qnav_stack_push(&qm->qblock, height, width);
return qm;
}
-void qmsg_printf_push(char const* title, char const* fmt, ...) {
+void qmsg_printf_push(char const *title, char const *fmt, ...) {
int titlewidth = title ? (int)strlen(title) : 0;
va_list ap;
va_start(ap, fmt);
int msgbytes = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
- char* buffer = malloc((Usz)msgbytes + 1);
+ char *buffer = malloc((Usz)msgbytes + 1);
if (!buffer)
exit(1);
va_start(ap, fmt);
@@ -251,8 +252,8 @@
maxlinewidth = curlinewidth;
int width = titlewidth > maxlinewidth ? titlewidth : maxlinewidth;
width += 2; // 1 padding on left and right each
- Qmsg* msg = qmsg_push(lines, width); // no wrapping yet, no real wcwidth, etc
- WINDOW* msgw = qmsg_window(msg);
+ Qmsg *msg = qmsg_push(lines, width); // no wrapping yet, no real wcwidth, etc
+ WINDOW *msgw = qmsg_window(msg);
int i = 0;
int offset = 0;
for (;;) {
@@ -269,7 +270,7 @@
qmsg_set_title(msg, title);
}
-bool qmsg_drive(Qmsg* qm, int key) {
+bool qmsg_drive(Qmsg *qm, int key) {
(void)qm;
switch (key) {
case ' ':
@@ -281,10 +282,10 @@
return false;
}
-Qmsg* qmsg_of(Qblock* qb) { return ORCA_CONTAINER_OF(qb, Qmsg, qblock); }
+Qmsg *qmsg_of(Qblock *qb) { return ORCA_CONTAINER_OF(qb, Qmsg, qblock); }
-Qmenu* qmenu_create(int id) {
- Qmenu* qm = (Qmenu*)malloc(sizeof(Qmenu));
+Qmenu *qmenu_create(int id) {
+ Qmenu *qm = (Qmenu *)malloc(sizeof(Qmenu));
qblock_init(&qm->qblock, Qblock_type_qmenu);
qm->ncurses_menu = NULL;
qm->ncurses_items = NULL;
@@ -295,32 +296,32 @@
qm->has_submenu_item = 0;
return qm;
}
-void qmenu_destroy(Qmenu* qm) { qmenu_free(qm); }
-int qmenu_id(Qmenu const* qm) { return qm->id; }
+void qmenu_destroy(Qmenu *qm) { qmenu_free(qm); }
+int qmenu_id(Qmenu const *qm) { return qm->id; }
static ORCA_FORCE_NO_INLINE void
-qmenu_allocitems(Qmenu* qm, Usz count, Usz* out_idx, ITEM*** out_items,
- struct Qmenu_item_extra** out_extras) {
+qmenu_allocitems(Qmenu *qm, Usz count, Usz *out_idx, ITEM ***out_items,
+ struct Qmenu_item_extra **out_extras) {
Usz old_count = qm->items_count;
// Add 1 for the extra null terminator guy
Usz new_count = old_count + count + 1;
Usz items_cap = qm->items_cap;
- ITEM** items = qm->ncurses_items;
+ ITEM **items = qm->ncurses_items;
if (new_count > items_cap) {
// todo overflow check, realloc fail check
Usz old_cap = items_cap;
Usz new_cap = new_count < 32 ? 32 : orca_round_up_power2(new_count);
- Usz new_size = new_cap * (sizeof(ITEM*) + sizeof(struct Qmenu_item_extra));
- ITEM** new_items = (ITEM**)realloc(items, new_size);
+ Usz new_size = new_cap * (sizeof(ITEM *) + sizeof(struct Qmenu_item_extra));
+ ITEM **new_items = (ITEM **)realloc(items, new_size);
if (!new_items)
exit(1);
items = new_items;
items_cap = new_cap;
// Move old extras data to new position
- Usz old_extras_offset = sizeof(ITEM*) * old_cap;
- Usz new_extras_offset = sizeof(ITEM*) * new_cap;
+ Usz old_extras_offset = sizeof(ITEM *) * old_cap;
+ Usz new_extras_offset = sizeof(ITEM *) * new_cap;
Usz old_extras_size = sizeof(struct Qmenu_item_extra) * old_count;
- memmove((char*)items + new_extras_offset, (char*)items + old_extras_offset,
- old_extras_size);
+ memmove((char *)items + new_extras_offset,
+ (char *)items + old_extras_offset, old_extras_size);
qm->ncurses_items = new_items;
qm->items_cap = new_cap;
}
@@ -327,58 +328,58 @@
// Not using new_count here in order to leave an extra 1 for the null
// terminator as required by ncurses.
qm->items_count = old_count + count;
- Usz extras_offset = sizeof(ITEM*) * items_cap;
+ Usz extras_offset = sizeof(ITEM *) * items_cap;
*out_idx = old_count;
*out_items = items + old_count;
*out_extras =
- (struct Qmenu_item_extra*)((char*)items + extras_offset) + old_count;
+ (struct Qmenu_item_extra *)((char *)items + extras_offset) + old_count;
}
-ORCA_FORCE_STATIC_INLINE struct Qmenu_item_extra*
-qmenu_item_extras_ptr(Qmenu* qm) {
- Usz offset = sizeof(ITEM*) * qm->items_cap;
- return (struct Qmenu_item_extra*)((char*)qm->ncurses_items + offset);
+ORCA_FORCE_STATIC_INLINE struct Qmenu_item_extra *
+qmenu_item_extras_ptr(Qmenu *qm) {
+ Usz offset = sizeof(ITEM *) * qm->items_cap;
+ return (struct Qmenu_item_extra *)((char *)qm->ncurses_items + offset);
}
// Get the curses menu item user pointer out, turn it to an int, and use it as
// an index into the 'extras' arrays.
ORCA_FORCE_STATIC_INLINE
-struct Qmenu_item_extra* qmenu_itemextra(struct Qmenu_item_extra* extras,
- ITEM* item) {
+struct Qmenu_item_extra *qmenu_itemextra(struct Qmenu_item_extra *extras,
+ ITEM *item) {
return extras + (int)(intptr_t)(item_userptr(item));
}
-void qmenu_set_title(Qmenu* qm, char const* title) {
+void qmenu_set_title(Qmenu *qm, char const *title) {
qblock_set_title(&qm->qblock, title);
}
-void qmenu_add_choice(Qmenu* qm, int id, char const* text) {
+void qmenu_add_choice(Qmenu *qm, int id, char const *text) {
assert(id != 0);
Usz idx;
- ITEM** items;
- struct Qmenu_item_extra* extras;
+ ITEM **items;
+ struct Qmenu_item_extra *extras;
qmenu_allocitems(qm, 1, &idx, &items, &extras);
items[0] = new_item(text, NULL);
- set_item_userptr(items[0], (void*)(uintptr_t)idx);
+ set_item_userptr(items[0], (void *)(uintptr_t)idx);
extras[0].user_id = id;
extras[0].owns_string = false;
extras[0].is_spacer = false;
}
-void qmenu_add_submenu(Qmenu* qm, int id, char const* text) {
+void qmenu_add_submenu(Qmenu *qm, int id, char const *text) {
assert(id != 0);
qm->has_submenu_item = true; // don't add +1 right padding to subwindow
Usz idx;
- ITEM** items;
- struct Qmenu_item_extra* extras;
+ ITEM **items;
+ struct Qmenu_item_extra *extras;
qmenu_allocitems(qm, 1, &idx, &items, &extras);
items[0] = new_item(text, ">");
- set_item_userptr(items[0], (void*)(uintptr_t)idx);
+ set_item_userptr(items[0], (void *)(uintptr_t)idx);
extras[0].user_id = id;
extras[0].owns_string = false;
extras[0].is_spacer = false;
}
-void qmenu_add_printf(Qmenu* qm, int id, char const* fmt, ...) {
+void qmenu_add_printf(Qmenu *qm, int id, char const *fmt, ...) {
va_list ap;
va_start(ap, fmt);
int textsize = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
- char* buffer = malloc((Usz)textsize + 1);
+ char *buffer = malloc((Usz)textsize + 1);
if (!buffer)
exit(1);
va_start(ap, fmt);
@@ -387,33 +388,33 @@
if (printedsize != textsize)
exit(1); // todo better handling?
Usz idx;
- ITEM** items;
- struct Qmenu_item_extra* extras;
+ ITEM **items;
+ struct Qmenu_item_extra *extras;
qmenu_allocitems(qm, 1, &idx, &items, &extras);
items[0] = new_item(buffer, NULL);
- set_item_userptr(items[0], (void*)(uintptr_t)idx);
+ set_item_userptr(items[0], (void *)(uintptr_t)idx);
extras[0].user_id = id;
extras[0].owns_string = true;
extras[0].is_spacer = false;
}
-void qmenu_add_spacer(Qmenu* qm) {
+void qmenu_add_spacer(Qmenu *qm) {
Usz idx;
- ITEM** items;
- struct Qmenu_item_extra* extras;
+ ITEM **items;
+ struct Qmenu_item_extra *extras;
qmenu_allocitems(qm, 1, &idx, &items, &extras);
items[0] = new_item(" ", NULL);
item_opts_off(items[0], O_SELECTABLE);
- set_item_userptr(items[0], (void*)(uintptr_t)idx);
+ set_item_userptr(items[0], (void *)(uintptr_t)idx);
extras[0].user_id = 0;
extras[0].owns_string = false;
extras[0].is_spacer = true;
}
-void qmenu_set_current_item(Qmenu* qm, int id) {
- ITEM** items = qm->ncurses_items;
- struct Qmenu_item_extra* extras = qmenu_item_extras_ptr(qm);
- ITEM* found = NULL;
+void qmenu_set_current_item(Qmenu *qm, int id) {
+ ITEM **items = qm->ncurses_items;
+ struct Qmenu_item_extra *extras = qmenu_item_extras_ptr(qm);
+ ITEM *found = NULL;
for (Usz i = 0, n = qm->items_count; i < n; i++) {
- ITEM* item = items[i];
+ ITEM *item = items[i];
if (qmenu_itemextra(extras, item)->user_id == id) {
found = item;
break;
@@ -427,13 +428,13 @@
qm->initial_item = found;
}
}
-void qmenu_set_displayed_active(Qmenu* qm, bool active) {
+void qmenu_set_displayed_active(Qmenu *qm, bool active) {
// Could add a flag in the Qmenu to avoid redundantly changing this stuff.
set_menu_fore(qm->ncurses_menu, active ? A_BOLD : A_DIM);
set_menu_back(qm->ncurses_menu, active ? A_NORMAL : A_DIM);
set_menu_grey(qm->ncurses_menu, active ? A_DIM : A_DIM);
}
-void qmenu_push_to_nav(Qmenu* qm) {
+void qmenu_push_to_nav(Qmenu *qm) {
// new_menu() will get angry if there are no items in the menu. We'll get a
// null pointer back, and our code will get angry. Instead, just add an empty
// spacer item. This will probably only ever occur as a programming error,
@@ -474,19 +475,19 @@
post_menu(qm->ncurses_menu);
}
-void qmenu_free(Qmenu* qm) {
+void qmenu_free(Qmenu *qm) {
unpost_menu(qm->ncurses_menu);
free_menu(qm->ncurses_menu);
- struct Qmenu_item_extra* extras = qmenu_item_extras_ptr(qm);
+ struct Qmenu_item_extra *extras = qmenu_item_extras_ptr(qm);
for (Usz i = 0; i < qm->items_count; ++i) {
- ITEM* item = qm->ncurses_items[i];
- struct Qmenu_item_extra* extra = qmenu_itemextra(extras, item);
- char const* freed_str = NULL;
+ ITEM *item = qm->ncurses_items[i];
+ struct Qmenu_item_extra *extra = qmenu_itemextra(extras, item);
+ char const *freed_str = NULL;
if (extra->owns_string)
freed_str = item_name(item);
free_item(qm->ncurses_items[i]);
if (freed_str)
- free((void*)freed_str);
+ free((void *)freed_str);
}
free(qm->ncurses_items);
free(qm);
@@ -493,17 +494,17 @@
}
ORCA_FORCE_NO_INLINE
-static void qmenu_drive_upordown(Qmenu* qm, int req_up_or_down) {
- struct Qmenu_item_extra* extras = qmenu_item_extras_ptr(qm);
- ITEM* starting = current_item(qm->ncurses_menu);
+static void qmenu_drive_upordown(Qmenu *qm, int req_up_or_down) {
+ struct Qmenu_item_extra *extras = qmenu_item_extras_ptr(qm);
+ ITEM *starting = current_item(qm->ncurses_menu);
menu_driver(qm->ncurses_menu, req_up_or_down);
- ITEM* cur = current_item(qm->ncurses_menu);
+ ITEM *cur = current_item(qm->ncurses_menu);
for (;;) {
if (!cur || cur == starting)
break;
if (!qmenu_itemextra(extras, cur)->is_spacer)
break;
- ITEM* prev = cur;
+ ITEM *prev = cur;
menu_driver(qm->ncurses_menu, req_up_or_down);
cur = current_item(qm->ncurses_menu);
if (cur == prev)
@@ -511,8 +512,8 @@
}
}
-bool qmenu_drive(Qmenu* qm, int key, Qmenu_action* out_action) {
- struct Qmenu_item_extra* extras = qmenu_item_extras_ptr(qm);
+bool qmenu_drive(Qmenu *qm, int key, Qmenu_action *out_action) {
+ struct Qmenu_item_extra *extras = qmenu_item_extras_ptr(qm);
switch (key) {
case 27: {
out_action->any.type = Qmenu_action_type_canceled;
@@ -521,7 +522,7 @@
case ' ':
case '\r':
case KEY_ENTER: {
- ITEM* cur = current_item(qm->ncurses_menu);
+ ITEM *cur = current_item(qm->ncurses_menu);
out_action->picked.type = Qmenu_action_type_picked;
out_action->picked.id = cur ? qmenu_itemextra(extras, cur)->user_id : 0;
return true;
@@ -536,20 +537,20 @@
return false;
}
-Qmenu* qmenu_of(Qblock* qb) { return ORCA_CONTAINER_OF(qb, Qmenu, qblock); }
+Qmenu *qmenu_of(Qblock *qb) { return ORCA_CONTAINER_OF(qb, Qmenu, qblock); }
bool qmenu_top_is_menu(int id) {
- Qblock* qb = qnav_top_block();
+ Qblock *qb = qnav_top_block();
if (!qb)
return false;
if (qb->tag != Qblock_type_qmenu)
return false;
- Qmenu* qm = qmenu_of(qb);
+ Qmenu *qm = qmenu_of(qb);
return qm->id == id;
}
-Qform* qform_create(int id) {
- Qform* qf = (Qform*)malloc(sizeof(Qform));
+Qform *qform_create(int id) {
+ Qform *qf = (Qform *)malloc(sizeof(Qform));
qblock_init(&qf->qblock, Qblock_type_qform);
qf->ncurses_form = NULL;
qf->ncurses_fields[0] = NULL;
@@ -558,15 +559,15 @@
return qf;
}
-Qform* qform_of(Qblock* qb) { return ORCA_CONTAINER_OF(qb, Qform, qblock); }
+Qform *qform_of(Qblock *qb) { return ORCA_CONTAINER_OF(qb, Qform, qblock); }
-int qform_id(Qform const* qf) { return qf->id; }
+int qform_id(Qform const *qf) { return qf->id; }
-void qform_add_text_line(Qform* qf, int id, char const* initial) {
- FIELD* f = new_field(1, 30, 0, 0, 0, 0);
+void qform_add_text_line(Qform *qf, int id, char const *initial) {
+ FIELD *f = new_field(1, 30, 0, 0, 0, 0);
if (initial)
set_field_buffer(f, 0, initial);
- set_field_userptr(f, (void*)(intptr_t)(id));
+ set_field_userptr(f, (void *)(intptr_t)(id));
field_opts_off(f, O_WRAP | O_BLANK | O_STATIC);
qf->ncurses_fields[qf->fields_count] = f;
++qf->fields_count;
@@ -573,7 +574,7 @@
qf->ncurses_fields[qf->fields_count] = NULL;
}
-void qform_push_to_nav(Qform* qf) {
+void qform_push_to_nav(Qform *qf) {
qf->ncurses_form = new_form(qf->ncurses_fields);
int form_min_h, form_min_w;
scale_form(qf->ncurses_form, &form_min_h, &form_min_w);
@@ -586,11 +587,11 @@
form_driver(qf->ncurses_form, REQ_END_LINE);
}
-void qform_set_title(Qform* qf, char const* title) {
+void qform_set_title(Qform *qf, char const *title) {
qblock_set_title(&qf->qblock, title);
}
-void qform_free(Qform* qf) {
+void qform_free(Qform *qf) {
curs_set(0);
unpost_form(qf->ncurses_form);
free_form(qf->ncurses_form);
@@ -600,7 +601,7 @@
free(qf);
}
-bool qform_drive(Qform* qf, int key, Qform_action* out_action) {
+bool qform_drive(Qform *qf, int key, Qform_action *out_action) {
switch (key) {
case 27: {
out_action->any.type = Qform_action_type_canceled;
@@ -644,7 +645,7 @@
return false;
}
-static Usz size_without_trailing_spaces(char const* str) {
+static Usz size_without_trailing_spaces(char const *str) {
Usz size = strlen(str);
for (;;) {
if (size == 0)
@@ -656,10 +657,10 @@
return size;
}
-FIELD* qform_find_field(Qform const* qf, int id) {
+FIELD *qform_find_field(Qform const *qf, int id) {
Usz count = qf->fields_count;
for (Usz i = 0; i < count; ++i) {
- FIELD* f = qf->ncurses_fields[i];
+ FIELD *f = qf->ncurses_fields[i];
if ((int)(intptr_t)field_userptr(f) == id)
return f;
}
@@ -666,12 +667,12 @@
return NULL;
}
-bool qform_get_text_line(Qform const* qf, int id, oso** out) {
- FIELD* f = qform_find_field(qf, id);
+bool qform_get_text_line(Qform const *qf, int id, oso **out) {
+ FIELD *f = qform_find_field(qf, id);
if (!f)
return false;
form_driver(qf->ncurses_form, REQ_VALIDATION);
- char* buf = field_buffer(f, 0);
+ char *buf = field_buffer(f, 0);
if (!buf)
return false;
Usz trimmed = size_without_trailing_spaces(buf);
--- a/term_util.h
+++ b/term_util.h
@@ -34,8 +34,8 @@
A_reverse = A_REVERSE,
} Term_attr;
-static ORCA_FORCE_INLINE ORCA_OK_IF_UNUSED
-attr_t fg_bg(Color_name fg, Color_name bg) {
+static ORCA_FORCE_INLINE ORCA_OK_IF_UNUSED attr_t fg_bg(Color_name fg,
+ Color_name bg) {
return COLOR_PAIR(1 + fg * Colors_count + bg);
}
@@ -49,14 +49,14 @@
typedef struct {
Qblock_type_tag tag;
- WINDOW* outer_window;
- WINDOW* content_window;
- char const* title;
+ WINDOW *outer_window;
+ WINDOW *content_window;
+ char const *title;
int y, x;
} Qblock;
typedef struct {
- Qblock* blocks[16];
+ Qblock *blocks[16];
Usz count;
bool stack_changed;
} Qnav_stack;
@@ -99,50 +99,50 @@
void qnav_init(void);
void qnav_deinit(void);
-Qblock* qnav_top_block(void);
+Qblock *qnav_top_block(void);
void qnav_stack_pop(void);
-void qblock_print_frame(Qblock* qb, bool active);
-void qblock_set_title(Qblock* qb, char const* title);
+void qblock_print_frame(Qblock *qb, bool active);
+void qblock_set_title(Qblock *qb, char const *title);
-Qmsg* qmsg_push(int height, int width);
-WINDOW* qmsg_window(Qmsg* qm);
-void qmsg_set_title(Qmsg* qm, char const* title);
+Qmsg *qmsg_push(int height, int width);
+WINDOW *qmsg_window(Qmsg *qm);
+void qmsg_set_title(Qmsg *qm, char const *title);
#ifdef __GNUC__
__attribute__((format(printf, 2, 3)))
#endif
void qmsg_printf_push(char const* title, char const* fmt, ...);
-bool qmsg_drive(Qmsg* qm, int key);
-Qmsg* qmsg_of(Qblock* qb);
+bool qmsg_drive(Qmsg *qm, int key);
+Qmsg *qmsg_of(Qblock *qb);
-Qmenu* qmenu_create(int id);
+Qmenu *qmenu_create(int id);
// Useful if menu creation needs to be aborted part-way. Otherwise, no need to
// call -- pushing the qmenu to the qnav stack transfers ownership. (Still
// working on this design, not sure yet.)
-void qmenu_destroy(Qmenu* qm);
-int qmenu_id(Qmenu const* qm);
-void qmenu_set_title(Qmenu* qm, char const* title);
-void qmenu_add_choice(Qmenu* qm, int id, char const* text);
-void qmenu_add_submenu(Qmenu* qm, int id, char const* text);
+void qmenu_destroy(Qmenu *qm);
+int qmenu_id(Qmenu const *qm);
+void qmenu_set_title(Qmenu *qm, char const *title);
+void qmenu_add_choice(Qmenu *qm, int id, char const *text);
+void qmenu_add_submenu(Qmenu *qm, int id, char const *text);
#ifdef __GNUC__
__attribute__((format(printf, 3, 4)))
#endif
void qmenu_add_printf(Qmenu* qm, int id, char const* fmt, ...);
-void qmenu_add_spacer(Qmenu* qm);
-void qmenu_set_current_item(Qmenu* qm, int id);
-void qmenu_set_displayed_active(Qmenu* qm, bool active);
-void qmenu_push_to_nav(Qmenu* qm);
-bool qmenu_drive(Qmenu* qm, int key, Qmenu_action* out_action);
-Qmenu* qmenu_of(Qblock* qb);
+void qmenu_add_spacer(Qmenu *qm);
+void qmenu_set_current_item(Qmenu *qm, int id);
+void qmenu_set_displayed_active(Qmenu *qm, bool active);
+void qmenu_push_to_nav(Qmenu *qm);
+bool qmenu_drive(Qmenu *qm, int key, Qmenu_action *out_action);
+Qmenu *qmenu_of(Qblock *qb);
bool qmenu_top_is_menu(int id);
-Qform* qform_create(int id);
-int qform_id(Qform const* qf);
-Qform* qform_of(Qblock* qb);
-void qform_add_text_line(Qform* qf, int id, char const* initial);
-void qform_push_to_nav(Qform* qf);
-void qform_set_title(Qform* qf, char const* title);
-bool qform_drive(Qform* qf, int key, Qform_action* out_action);
-bool qform_get_text_line(Qform const* qf, int id, struct oso** out);
+Qform *qform_create(int id);
+int qform_id(Qform const *qf);
+Qform *qform_of(Qblock *qb);
+void qform_add_text_line(Qform *qf, int id, char const *initial);
+void qform_push_to_nav(Qform *qf);
+void qform_set_title(Qform *qf, char const *title);
+bool qform_drive(Qform *qf, int key, Qform_action *out_action);
+bool qform_get_text_line(Qform const *qf, int id, struct oso **out);
extern Qnav_stack qnav_stack;
--- a/tui_main.c
+++ b/tui_main.c
@@ -169,7 +169,7 @@
Usz w;
} Ged_cursor;
-void ged_cursor_init(Ged_cursor* tc) {
+void ged_cursor_init(Ged_cursor *tc) {
tc->y = 0;
tc->x = 0;
tc->h = 1;
@@ -176,7 +176,7 @@
tc->w = 1;
}
-void ged_cursor_move_relative(Ged_cursor* tc, Usz field_h, Usz field_w,
+void ged_cursor_move_relative(Ged_cursor *tc, Usz field_h, Usz field_w,
Isz delta_y, Isz delta_x) {
Isz y0 = (Isz)tc->y + delta_y;
Isz x0 = (Isz)tc->x + delta_x;
@@ -192,8 +192,8 @@
tc->x = (Usz)x0;
}
-void draw_grid_cursor(WINDOW* win, int draw_y, int draw_x, int draw_h,
- int draw_w, Glyph const* gbuffer, Usz field_h,
+void draw_grid_cursor(WINDOW *win, int draw_y, int draw_x, int draw_h,
+ int draw_w, Glyph const *gbuffer, Usz field_h,
Usz field_w, int scroll_y, int scroll_x, Usz cursor_y,
Usz cursor_x, Usz cursor_h, Usz cursor_w,
Ged_input_mode input_mode, bool is_playing) {
@@ -311,27 +311,27 @@
typedef struct Undo_node {
Field field;
Usz tick_num;
- struct Undo_node* prev;
- struct Undo_node* next;
+ struct Undo_node *prev;
+ struct Undo_node *next;
} Undo_node;
typedef struct {
- Undo_node* first;
- Undo_node* last;
+ Undo_node *first;
+ Undo_node *last;
Usz count;
Usz limit;
} Undo_history;
-void undo_history_init(Undo_history* hist, Usz limit) {
+void undo_history_init(Undo_history *hist, Usz limit) {
hist->first = NULL;
hist->last = NULL;
hist->count = 0;
hist->limit = limit;
}
-void undo_history_deinit(Undo_history* hist) {
- Undo_node* a = hist->first;
+void undo_history_deinit(Undo_history *hist) {
+ Undo_node *a = hist->first;
while (a) {
- Undo_node* b = a->next;
+ Undo_node *b = a->next;
field_deinit(&a->field);
free(a);
a = b;
@@ -338,10 +338,10 @@
}
}
-void undo_history_push(Undo_history* hist, Field* field, Usz tick_num) {
+void undo_history_push(Undo_history *hist, Field *field, Usz tick_num) {
if (hist->limit == 0)
return;
- Undo_node* new_node;
+ Undo_node *new_node;
if (hist->count == hist->limit) {
new_node = hist->first;
if (new_node == hist->last) {
@@ -370,8 +370,8 @@
hist->last = new_node;
}
-void undo_history_pop(Undo_history* hist, Field* out_field, Usz* out_tick_num) {
- Undo_node* last = hist->last;
+void undo_history_pop(Undo_history *hist, Field *out_field, Usz *out_tick_num) {
+ Undo_node *last = hist->last;
if (!last)
return;
field_copy(&last->field, out_field);
@@ -380,7 +380,7 @@
hist->first = NULL;
hist->last = NULL;
} else {
- Undo_node* new_last = last->prev;
+ Undo_node *new_last = last->prev;
new_last->next = NULL;
hist->last = new_last;
}
@@ -389,9 +389,9 @@
--hist->count;
}
-void undo_history_apply(Undo_history* hist, Field* out_field,
- Usz* out_tick_num) {
- Undo_node* last = hist->last;
+void undo_history_apply(Undo_history *hist, Field *out_field,
+ Usz *out_tick_num) {
+ Undo_node *last = hist->last;
if (!last)
return;
field_copy(&last->field, out_field);
@@ -398,9 +398,9 @@
*out_tick_num = last->tick_num;
}
-Usz undo_history_count(Undo_history* hist) { return hist->count; }
+Usz undo_history_count(Undo_history *hist) { return hist->count; }
-void print_activity_indicator(WINDOW* win, Usz activity_counter) {
+void print_activity_indicator(WINDOW *win, Usz activity_counter) {
// 7 segments that can each light up as Colors different colors.
// This gives us Colors^Segments total configurations.
enum { Segments = 7, Colors = 4 };
@@ -450,7 +450,7 @@
#endif
}
-void advance_faketab(WINDOW* win, int offset_x, int tabstop) {
+void advance_faketab(WINDOW *win, int offset_x, int tabstop) {
if (tabstop < 1)
return;
int y, x, h, w;
@@ -465,10 +465,10 @@
wmove(win, y, x);
}
-void draw_hud(WINDOW* win, int win_y, int win_x, int height, int width,
- char const* filename, Usz field_h, Usz field_w,
+void draw_hud(WINDOW *win, int win_y, int win_x, int height, int width,
+ char const *filename, Usz field_h, Usz field_w,
Usz ruler_spacing_y, Usz ruler_spacing_x, Usz tick_num, Usz bpm,
- Ged_cursor const* ged_cursor, Ged_input_mode input_mode,
+ Ged_cursor const *ged_cursor, Ged_input_mode input_mode,
Usz activity_counter) {
(void)height;
(void)width;
@@ -511,9 +511,9 @@
waddstr(win, filename);
}
-void draw_glyphs_grid(WINDOW* win, int draw_y, int draw_x, int draw_h,
- int draw_w, Glyph const* restrict gbuffer,
- Mark const* restrict mbuffer, Usz field_h, Usz field_w,
+void draw_glyphs_grid(WINDOW *win, int draw_y, int draw_x, int draw_h,
+ int draw_w, Glyph const *restrict gbuffer,
+ Mark const *restrict mbuffer, Usz field_h, Usz field_w,
Usz offset_y, Usz offset_x, Usz ruler_spacing_y,
Usz ruler_spacing_x) {
assert(draw_y >= 0 && draw_x >= 0);
@@ -557,8 +557,8 @@
}
for (Usz iy = 0; iy < rows; ++iy) {
Usz line_offset = (offset_y + iy) * field_w + offset_x;
- Glyph const* g_row = gbuffer + line_offset;
- Mark const* m_row = mbuffer + line_offset;
+ Glyph const *g_row = gbuffer + line_offset;
+ Mark const *m_row = mbuffer + line_offset;
bool use_y_ruler = use_rulers && (iy + offset_y) % ruler_spacing_y == 0;
for (Usz ix = 0; ix < cols; ++ix) {
Glyph g = g_row[ix];
@@ -586,9 +586,9 @@
}
}
-void draw_glyphs_grid_scrolled(WINDOW* win, int draw_y, int draw_x, int draw_h,
- int draw_w, Glyph const* restrict gbuffer,
- Mark const* restrict mbuffer, Usz field_h,
+void draw_glyphs_grid_scrolled(WINDOW *win, int draw_y, int draw_x, int draw_h,
+ int draw_w, Glyph const *restrict gbuffer,
+ Mark const *restrict mbuffer, Usz field_h,
Usz field_w, int scroll_y, int scroll_x,
Usz ruler_spacing_y, Usz ruler_spacing_x) {
if (scroll_y < 0) {
@@ -604,7 +604,7 @@
ruler_spacing_y, ruler_spacing_x);
}
-void ged_cursor_confine(Ged_cursor* tc, Usz height, Usz width) {
+void ged_cursor_confine(Ged_cursor *tc, Usz height, Usz width) {
if (height == 0 || width == 0)
return;
if (tc->y >= height)
@@ -613,7 +613,7 @@
tc->x = width - 1;
}
-void draw_oevent_list(WINDOW* win, Oevent_list const* oevent_list) {
+void draw_oevent_list(WINDOW *win, Oevent_list const *oevent_list) {
wmove(win, 0, 0);
int win_h = getmaxy(win);
wprintw(win, "Count: %d", (int)oevent_list->count);
@@ -622,11 +622,11 @@
if (cury + 1 >= win_h)
return;
wmove(win, cury + 1, 0);
- Oevent const* ev = oevent_list->buffer + i;
+ Oevent const *ev = oevent_list->buffer + i;
Oevent_types evt = ev->any.oevent_type;
switch (evt) {
case Oevent_type_midi: {
- Oevent_midi const* em = &ev->midi;
+ Oevent_midi const *em = &ev->midi;
wprintw(win,
"MIDI\tchannel %d\toctave %d\tnote %d\tvelocity %d\tlength %d",
(int)em->channel, (int)em->octave, (int)em->note,
@@ -633,7 +633,7 @@
(int)em->velocity, (int)em->bar_divisor);
} break;
case Oevent_type_osc_ints: {
- Oevent_osc_ints const* eo = &ev->osc_ints;
+ Oevent_osc_ints const *eo = &ev->osc_ints;
wprintw(win, "OSC\t%c\tcount: %d ", eo->glyph, eo->count, eo->count);
waddch(win, ACS_VLINE);
for (Usz j = 0; j < eo->count; ++j) {
@@ -641,7 +641,7 @@
}
} break;
case Oevent_type_udp_string: {
- Oevent_udp_string const* eo = &ev->udp_string;
+ Oevent_udp_string const *eo = &ev->udp_string;
wprintw(win, "UDP\tcount %d\t", (int)eo->count);
for (Usz j = 0; j < (Usz)eo->count; ++j) {
waddch(win, (chtype)eo->chars[j]);
@@ -651,9 +651,9 @@
}
}
-void ged_resize_grid(Field* field, Mbuf_reusable* mbr, Usz new_height,
- Usz new_width, Usz tick_num, Field* scratch_field,
- Undo_history* undo_hist, Ged_cursor* ged_cursor) {
+void ged_resize_grid(Field *field, Mbuf_reusable *mbr, Usz new_height,
+ Usz new_width, Usz tick_num, Field *scratch_field,
+ Undo_history *undo_hist, Ged_cursor *ged_cursor) {
assert(new_height > 0 && new_width > 0);
undo_history_push(undo_hist, field, tick_num);
field_copy(field, scratch_field);
@@ -688,11 +688,11 @@
// Resizes by number of ruler divisions, and snaps size to closest division in
// a way a human would expect. Adds +1 to the output, so grid resulting size is
// 1 unit longer than the actual ruler length.
-bool ged_resize_grid_snap_ruler(Field* field, Mbuf_reusable* mbr, Usz ruler_y,
+bool ged_resize_grid_snap_ruler(Field *field, Mbuf_reusable *mbr, Usz ruler_y,
Usz ruler_x, Isz delta_h, Isz delta_w,
- Usz tick_num, Field* scratch_field,
- Undo_history* undo_hist,
- Ged_cursor* ged_cursor) {
+ Usz tick_num, Field *scratch_field,
+ Undo_history *undo_hist,
+ Ged_cursor *ged_cursor) {
assert(ruler_y > 0);
assert(ruler_x > 0);
Usz field_h = field->height;
@@ -732,7 +732,7 @@
typedef struct {
Midi_mode_type type;
- char const* path;
+ char const *path;
} Midi_mode_osc_bidule;
#ifdef FEAT_PORTMIDI
@@ -739,7 +739,7 @@
typedef struct {
Midi_mode_type type;
PmDeviceID device_id;
- PortMidiStream* stream;
+ PortMidiStream *stream;
} Midi_mode_portmidi;
// Not sure whether it's OK to call Pm_Terminate() without having a successful
// call to Pm_Initialize() -- let's just treat it with tweezers.
@@ -754,8 +754,8 @@
#endif
} Midi_mode;
-void midi_mode_init_null(Midi_mode* mm) { mm->any.type = Midi_mode_type_null; }
-void midi_mode_init_osc_bidule(Midi_mode* mm, char const* path) {
+void midi_mode_init_null(Midi_mode *mm) { mm->any.type = Midi_mode_type_null; }
+void midi_mode_init_osc_bidule(Midi_mode *mm, char const *path) {
mm->osc_bidule.type = Midi_mode_type_osc_bidule;
mm->osc_bidule.path = path;
}
@@ -771,7 +771,7 @@
portmidi_is_initialized = true;
return 0;
}
-PmError midi_mode_init_portmidi(Midi_mode* mm, PmDeviceID dev_id) {
+PmError midi_mode_init_portmidi(Midi_mode *mm, PmDeviceID dev_id) {
PmError e = portmidi_init_if_necessary();
if (e)
goto fail;
@@ -787,14 +787,14 @@
return e;
}
// Returns true on success. todo currently output only
-bool portmidi_find_device_id_by_name(char const* name, Usz namelen,
- PmError* out_pmerror, PmDeviceID* out_id) {
+bool portmidi_find_device_id_by_name(char const *name, Usz namelen,
+ PmError *out_pmerror, PmDeviceID *out_id) {
*out_pmerror = portmidi_init_if_necessary();
if (*out_pmerror)
return false;
int num = Pm_CountDevices();
for (int i = 0; i < num; ++i) {
- PmDeviceInfo const* info = Pm_GetDeviceInfo(i);
+ PmDeviceInfo const *info = Pm_GetDeviceInfo(i);
if (!info || !info->output)
continue;
Usz len = strlen(info->name);
@@ -807,8 +807,8 @@
}
return false;
}
-bool portmidi_find_name_of_device_id(PmDeviceID id, PmError* out_pmerror,
- oso** out_name) {
+bool portmidi_find_name_of_device_id(PmDeviceID id, PmError *out_pmerror,
+ oso **out_name) {
*out_pmerror = portmidi_init_if_necessary();
if (*out_pmerror)
return false;
@@ -815,7 +815,7 @@
int num = Pm_CountDevices();
if (id < 0 || id >= num)
return false;
- PmDeviceInfo const* info = Pm_GetDeviceInfo(id);
+ PmDeviceInfo const *info = Pm_GetDeviceInfo(id);
if (!info || !info->output)
return false;
osoput(out_name, info->name);
@@ -822,7 +822,7 @@
return true;
}
#endif
-void midi_mode_deinit(Midi_mode* mm) {
+void midi_mode_deinit(Midi_mode *mm) {
switch (mm->any.type) {
case Midi_mode_type_null:
case Midi_mode_type_osc_bidule:
@@ -852,8 +852,8 @@
U64 clock;
double accum_secs;
double time_to_next_note_off;
- Oosc_dev* oosc_dev;
- Midi_mode const* midi_mode;
+ Oosc_dev *oosc_dev;
+ Midi_mode const *midi_mode;
Usz activity_counter;
Usz random_seed;
Usz drag_start_y, drag_start_x;
@@ -870,7 +870,7 @@
bool is_hud_visible : 1;
} Ged;
-void ged_init(Ged* a, Usz undo_limit, Usz init_bpm, Usz init_seed) {
+void ged_init(Ged *a, Usz undo_limit, Usz init_bpm, Usz init_seed) {
field_init(&a->field);
field_init(&a->scratch_field);
field_init(&a->clipboard_field);
@@ -905,7 +905,7 @@
a->is_hud_visible = false;
}
-void ged_deinit(Ged* a) {
+void ged_deinit(Ged *a) {
field_deinit(&a->field);
field_deinit(&a->scratch_field);
field_deinit(&a->clipboard_field);
@@ -919,11 +919,11 @@
}
}
-bool ged_is_draw_dirty(Ged* a) {
+bool ged_is_draw_dirty(Ged *a) {
return a->is_draw_dirty || a->needs_remarking;
}
-bool ged_set_osc_udp(Ged* a, char const* dest_addr, char const* dest_port) {
+bool ged_set_osc_udp(Ged *a, char const *dest_addr, char const *dest_port) {
if (a->oosc_dev) {
oosc_dev_destroy(a->oosc_dev);
a->oosc_dev = NULL;
@@ -938,12 +938,12 @@
return true;
}
-void ged_set_midi_mode(Ged* a, Midi_mode const* midi_mode) {
+void ged_set_midi_mode(Ged *a, Midi_mode const *midi_mode) {
a->midi_mode = midi_mode;
}
-void send_midi_note_offs(Oosc_dev* oosc_dev, Midi_mode const* midi_mode,
- Susnote const* start, Susnote const* end) {
+void send_midi_note_offs(Oosc_dev *oosc_dev, Midi_mode const *midi_mode,
+ Susnote const *start, Susnote const *end) {
Midi_mode_type midi_mode_type = midi_mode->any.type;
for (; start != end; ++start) {
#if 0
@@ -981,13 +981,13 @@
}
}
-void send_control_message(Oosc_dev* oosc_dev, char const* osc_address) {
+void send_control_message(Oosc_dev *oosc_dev, char const *osc_address) {
if (!oosc_dev)
return;
oosc_send_int32s(oosc_dev, osc_address, NULL, 0);
}
-void send_num_message(Oosc_dev* oosc_dev, char const* osc_address, I32 num) {
+void send_num_message(Oosc_dev *oosc_dev, char const *osc_address, I32 num) {
if (!oosc_dev)
return;
I32 nums[1];
@@ -995,23 +995,23 @@
oosc_send_int32s(oosc_dev, osc_address, nums, ORCA_ARRAY_COUNTOF(nums));
}
-void apply_time_to_sustained_notes(Oosc_dev* oosc_dev,
- Midi_mode const* midi_mode,
+void apply_time_to_sustained_notes(Oosc_dev *oosc_dev,
+ Midi_mode const *midi_mode,
double time_elapsed,
- Susnote_list* susnote_list,
- double* next_note_off_deadline) {
+ Susnote_list *susnote_list,
+ double *next_note_off_deadline) {
Usz start_removed, end_removed;
susnote_list_advance_time(susnote_list, time_elapsed, &start_removed,
&end_removed, next_note_off_deadline);
if (ORCA_UNLIKELY(start_removed != end_removed)) {
- Susnote const* restrict susnotes_off = susnote_list->buffer;
+ Susnote const *restrict susnotes_off = susnote_list->buffer;
send_midi_note_offs(oosc_dev, midi_mode, susnotes_off + start_removed,
susnotes_off + end_removed);
}
}
-void ged_stop_all_sustained_notes(Ged* a) {
- Susnote_list* sl = &a->susnote_list;
+void ged_stop_all_sustained_notes(Ged *a) {
+ Susnote_list *sl = &a->susnote_list;
send_midi_note_offs(a->oosc_dev, a->midi_mode, sl->buffer,
sl->buffer + sl->count);
susnote_list_clear(sl);
@@ -1018,8 +1018,8 @@
a->time_to_next_note_off = 1.0;
}
-void send_output_events(Oosc_dev* oosc_dev, Midi_mode const* midi_mode, Usz bpm,
- Susnote_list* susnote_list, Oevent const* events,
+void send_output_events(Oosc_dev *oosc_dev, Midi_mode const *midi_mode, Usz bpm,
+ Susnote_list *susnote_list, Oevent const *events,
Usz count) {
Midi_mode_type midi_mode_type = midi_mode->any.type;
double bar_secs = 60.0 / (double)bpm * 4.0;
@@ -1037,10 +1037,10 @@
for (Usz i = 0; i < count; ++i) {
if (midi_note_count == Midi_on_capacity)
break;
- Oevent const* e = events + i;
+ Oevent const *e = events + i;
switch ((Oevent_types)e->any.oevent_type) {
case Oevent_type_midi: {
- Oevent_midi const* em = &e->midi;
+ Oevent_midi const *em = &e->midi;
Usz note_number = (Usz)(12u * em->octave + em->note);
Usz channel = em->channel;
Usz bar_div = em->bar_divisor;
@@ -1062,7 +1062,7 @@
// kinda lame
if (!oosc_dev)
continue;
- Oevent_osc_ints const* eo = &e->osc_ints;
+ Oevent_osc_ints const *eo = &e->osc_ints;
char path_buff[3];
path_buff[0] = '/';
path_buff[1] = eo->glyph;
@@ -1077,7 +1077,7 @@
case Oevent_type_udp_string: {
if (!oosc_dev)
continue;
- Oevent_udp_string const* eo = &e->udp_string;
+ Oevent_udp_string const *eo = &e->udp_string;
oosc_send_datagram(oosc_dev, eo->chars, eo->count);
} break;
}
@@ -1088,7 +1088,7 @@
susnote_list_add_notes(susnote_list, new_susnotes, midi_note_count,
&start_note_offs, &end_note_offs);
if (start_note_offs != end_note_offs) {
- Susnote const* restrict susnotes_off = susnote_list->buffer;
+ Susnote const *restrict susnotes_off = susnote_list->buffer;
send_midi_note_offs(oosc_dev, midi_mode, susnotes_off + start_note_offs,
susnotes_off + end_note_offs);
}
@@ -1127,7 +1127,7 @@
static double ms_to_sec(double ms) { return ms / 1000.0; }
-double ged_secs_to_deadline(Ged const* a) {
+double ged_secs_to_deadline(Ged const *a) {
if (a->is_playing) {
double secs_span = 60.0 / (double)a->bpm / 4.0;
double rem = secs_span - (stm_sec(stm_since(a->clock)) + a->accum_secs);
@@ -1142,10 +1142,10 @@
}
}
-void ged_reset_clock(Ged* a) { a->clock = stm_now(); }
+void ged_reset_clock(Ged *a) { a->clock = stm_now(); }
-void clear_and_run_vm(Glyph* restrict gbuf, Mark* restrict mbuf, Usz height,
- Usz width, Usz tick_number, Oevent_list* oevent_list,
+void clear_and_run_vm(Glyph *restrict gbuf, Mark *restrict mbuf, Usz height,
+ Usz width, Usz tick_number, Oevent_list *oevent_list,
Usz random_seed) {
mbuffer_clear(mbuf, height, width);
oevent_list_clear(oevent_list);
@@ -1152,10 +1152,10 @@
orca_run(gbuf, mbuf, height, width, tick_number, oevent_list, random_seed);
}
-void ged_do_stuff(Ged* a) {
+void ged_do_stuff(Ged *a) {
double secs_span = 60.0 / (double)a->bpm / 4.0;
- Oosc_dev* oosc_dev = a->oosc_dev;
- Midi_mode const* midi_mode = a->midi_mode;
+ Oosc_dev *oosc_dev = a->oosc_dev;
+ Midi_mode const *midi_mode = a->midi_mode;
double secs = stm_sec(stm_since(a->clock));
(void)secs; // unused, was previously used for activity meter decay
if (!a->is_playing)
@@ -1244,7 +1244,7 @@
return isz_clamp(new_scroll, 0, cont_len - win_len);
}
-void ged_make_cursor_visible(Ged* a) {
+void ged_make_cursor_visible(Ged *a) {
int grid_h = a->grid_h;
int cur_scr_y = a->grid_scroll_y;
int cur_scr_x = a->grid_scroll_x;
@@ -1261,7 +1261,7 @@
enum { Hud_height = 2 };
-void ged_update_internal_geometry(Ged* a) {
+void ged_update_internal_geometry(Ged *a) {
int win_h = a->win_h;
int softmargin_y = a->softmargin_y;
bool show_hud = win_h > Hud_height + 1;
@@ -1275,7 +1275,7 @@
a->is_hud_visible = show_hud;
}
-void ged_set_window_size(Ged* a, int win_h, int win_w, int softmargin_y,
+void ged_set_window_size(Ged *a, int win_h, int win_w, int softmargin_y,
int softmargin_x) {
if (a->win_h == win_h && a->win_w == win_w &&
a->softmargin_y == softmargin_y && a->softmargin_x == softmargin_x)
@@ -1290,8 +1290,8 @@
bool ged_suggest_nice_grid_size(int win_h, int win_w, int softmargin_y,
int softmargin_x, int ruler_spacing_y,
- int ruler_spacing_x, Usz* out_grid_h,
- Usz* out_grid_w) {
+ int ruler_spacing_x, Usz *out_grid_h,
+ Usz *out_grid_w) {
if (win_h < 1 || win_w < 1 || softmargin_y < 0 || softmargin_x < 0 ||
ruler_spacing_y < 1 || ruler_spacing_x < 1)
return false;
@@ -1313,8 +1313,8 @@
return true;
}
bool ged_suggest_tight_grid_size(int win_h, int win_w, int softmargin_y,
- int softmargin_x, Usz* out_grid_h,
- Usz* out_grid_w) {
+ int softmargin_x, Usz *out_grid_h,
+ Usz *out_grid_w) {
if (win_h < 1 || win_w < 1 || softmargin_y < 0 || softmargin_x < 0)
return false;
@@ -1328,7 +1328,7 @@
return true;
}
-void ged_draw(Ged* a, WINDOW* win, char const* filename) {
+void ged_draw(Ged *a, WINDOW *win, char const *filename) {
// We can predictavely step the next simulation tick and then use the
// resulting mark buffer for better UI visualization. If we don't do this,
// after loading a fresh file or after the user performs some edit (or even
@@ -1375,7 +1375,7 @@
a->is_draw_dirty = false;
}
-void ged_adjust_bpm(Ged* a, Isz delta_bpm) {
+void ged_adjust_bpm(Ged *a, Isz delta_bpm) {
Isz new_bpm = (Isz)a->bpm;
if (delta_bpm < 0 || new_bpm < INT_MAX - delta_bpm)
new_bpm += delta_bpm;
@@ -1390,7 +1390,7 @@
}
}
-void ged_move_cursor_relative(Ged* a, Isz delta_y, Isz delta_x) {
+void ged_move_cursor_relative(Ged *a, Isz delta_y, Isz delta_x) {
ged_cursor_move_relative(&a->ged_cursor, a->field.height, a->field.width,
delta_y, delta_x);
ged_make_cursor_visible(a);
@@ -1408,7 +1408,7 @@
return x;
}
-void ged_modify_selection_size(Ged* a, int delta_y, int delta_x) {
+void ged_modify_selection_size(Ged *a, int delta_y, int delta_x) {
Usz cur_h = a->ged_cursor.h;
Usz cur_w = a->ged_cursor.w;
Usz new_h = guarded_selection_axis_resize(cur_h, delta_y);
@@ -1420,8 +1420,8 @@
}
}
-bool ged_try_selection_clipped_to_field(Ged const* a, Usz* out_y, Usz* out_x,
- Usz* out_h, Usz* out_w) {
+bool ged_try_selection_clipped_to_field(Ged const *a, Usz *out_y, Usz *out_x,
+ Usz *out_h, Usz *out_w) {
Usz curs_y = a->ged_cursor.y;
Usz curs_x = a->ged_cursor.x;
Usz curs_h = a->ged_cursor.h;
@@ -1441,7 +1441,7 @@
return true;
}
-bool ged_slide_selection(Ged* a, int delta_y, int delta_x) {
+bool ged_slide_selection(Ged *a, int delta_y, int delta_x) {
Usz curs_y_0, curs_x_0, curs_h_0, curs_w_0;
Usz curs_y_1, curs_x_1, curs_h_1, curs_w_1;
if (!ged_try_selection_clipped_to_field(a, &curs_y_0, &curs_x_0, &curs_h_0,
@@ -1497,7 +1497,7 @@
Ged_dir_right,
} Ged_dir;
-void ged_dir_input(Ged* a, Ged_dir dir, int step_length) {
+void ged_dir_input(Ged *a, Ged_dir dir, int step_length) {
switch (a->input_mode) {
case Ged_input_mode_normal:
case Ged_input_mode_append:
@@ -1568,7 +1568,7 @@
return visual_coord;
}
-void ged_mouse_event(Ged* a, Usz vis_y, Usz vis_x, mmask_t mouse_bstate) {
+void ged_mouse_event(Ged *a, Usz vis_y, Usz vis_x, mmask_t mouse_bstate) {
if (mouse_bstate & BUTTON1_RELEASED) {
// hard-disables tracking, but also disables further mouse stuff.
// mousemask() with our original parameters seems to work to get into the
@@ -1637,7 +1637,7 @@
#endif
}
-void ged_adjust_rulers_relative(Ged* a, Isz delta_y, Isz delta_x) {
+void ged_adjust_rulers_relative(Ged *a, Isz delta_y, Isz delta_x) {
Isz new_y = (Isz)a->ruler_spacing_y + delta_y;
Isz new_x = (Isz)a->ruler_spacing_x + delta_x;
if (new_y < 4)
@@ -1655,7 +1655,7 @@
a->is_draw_dirty = true;
}
-void ged_resize_grid_relative(Ged* a, Isz delta_y, Isz delta_x) {
+void ged_resize_grid_relative(Ged *a, Isz delta_y, Isz delta_x) {
ged_resize_grid_snap_ruler(&a->field, &a->mbuf_r, a->ruler_spacing_y,
a->ruler_spacing_x, delta_y, delta_x, a->tick_num,
&a->scratch_field, &a->undo_hist, &a->ged_cursor);
@@ -1665,7 +1665,7 @@
ged_make_cursor_visible(a);
}
-void ged_write_character(Ged* a, char c) {
+void ged_write_character(Ged *a, char c) {
undo_history_push(&a->undo_hist, &a->field, a->tick_num);
gbuffer_poke(a->field.buffer, a->field.height, a->field.width,
a->ged_cursor.y, a->ged_cursor.x, c);
@@ -1681,7 +1681,7 @@
a->is_draw_dirty = true;
}
-bool ged_fill_selection_with_char(Ged* a, Glyph c) {
+bool ged_fill_selection_with_char(Ged *a, Glyph c) {
Usz curs_y, curs_x, curs_h, curs_w;
if (!ged_try_selection_clipped_to_field(a, &curs_y, &curs_x, &curs_h,
&curs_w))
@@ -1691,7 +1691,7 @@
return true;
}
-bool ged_copy_selection_to_clipbard(Ged* a) {
+bool ged_copy_selection_to_clipbard(Ged *a) {
Usz curs_y, curs_x, curs_h, curs_w;
if (!ged_try_selection_clipped_to_field(a, &curs_y, &curs_x, &curs_h,
&curs_w))
@@ -1698,7 +1698,7 @@
return false;
Usz field_h = a->field.height;
Usz field_w = a->field.width;
- Field* cb_field = &a->clipboard_field;
+ Field *cb_field = &a->clipboard_field;
field_resize_raw_if_necessary(cb_field, curs_h, curs_w);
gbuffer_copy_subrect(a->field.buffer, cb_field->buffer, field_h, field_w,
curs_h, curs_w, curs_y, curs_x, 0, 0, curs_h, curs_w);
@@ -1705,7 +1705,7 @@
return true;
}
-void ged_input_character(Ged* a, char c) {
+void ged_input_character(Ged *a, char c) {
switch (a->input_mode) {
case Ged_input_mode_append:
ged_write_character(a, c);
@@ -1739,7 +1739,7 @@
Ged_input_cmd_escape,
} Ged_input_cmd;
-void ged_input_cmd(Ged* a, Ged_input_cmd ev) {
+void ged_input_cmd(Ged *a, Ged_input_cmd ev) {
switch (ev) {
case Ged_input_cmd_undo:
if (undo_history_count(&a->undo_hist) > 0) {
@@ -1826,7 +1826,7 @@
Usz curs_x = a->ged_cursor.x;
if (curs_y >= field_h || curs_x >= field_w)
break;
- Field* cb_field = &a->clipboard_field;
+ Field *cb_field = &a->clipboard_field;
Usz cbfield_h = cb_field->height;
Usz cbfield_w = cb_field->width;
Usz cpy_h = cbfield_h;
@@ -1859,12 +1859,12 @@
}
}
-bool hacky_try_save(Field* field, char const* filename) {
+bool hacky_try_save(Field *field, char const *filename) {
if (!filename)
return false;
if (field->height == 0 || field->width == 0)
return false;
- FILE* f = fopen(filename, "w");
+ FILE *f = fopen(filename, "w");
if (!f)
return false;
field_fput(field, f);
@@ -1926,7 +1926,7 @@
};
void push_main_menu(void) {
- Qmenu* qm = qmenu_create(Main_menu_id);
+ Qmenu *qm = qmenu_create(Main_menu_id);
qmenu_set_title(qm, "ORCA");
qmenu_add_choice(qm, Main_menu_new, "New");
qmenu_add_choice(qm, Main_menu_open, "Open...");
@@ -1950,7 +1950,7 @@
}
void pop_qnav_if_main_menu(void) {
- Qblock* qb = qnav_top_block();
+ Qblock *qb = qnav_top_block();
if (qb && qb->tag == Qblock_type_qmenu &&
qmenu_id(qmenu_of(qb)) == Main_menu_id)
qnav_stack_pop();
@@ -1957,7 +1957,7 @@
}
void push_confirm_new_file_menu(void) {
- Qmenu* qm = qmenu_create(Confirm_new_file_menu_id);
+ Qmenu *qm = qmenu_create(Confirm_new_file_menu_id);
qmenu_set_title(qm, "Are you sure?");
qmenu_add_choice(qm, Confirm_new_file_reject_id, "Cancel");
qmenu_add_choice(qm, Confirm_new_file_accept_id, "Create New File");
@@ -1965,7 +1965,7 @@
}
void push_autofit_menu(void) {
- Qmenu* qm = qmenu_create(Autofit_menu_id);
+ Qmenu *qm = qmenu_create(Autofit_menu_id);
qmenu_set_title(qm, "Auto-fit Grid");
qmenu_add_choice(qm, Autofit_nicely_id, "Nicely");
qmenu_add_choice(qm, Autofit_tightly_id, "Tightly");
@@ -1995,8 +1995,8 @@
width += hpad * 2;
int logo_left_pad = (width - cols) / 2;
int footer_left_pad = (width - footer_len) / 2;
- Qmsg* qm = qmsg_push(tpad + rows + sep + 1 + bpad, width);
- WINDOW* w = qmsg_window(qm);
+ Qmsg *qm = qmsg_push(tpad + rows + sep + 1 + bpad, width);
+ WINDOW *w = qmsg_window(qm);
for (int row = 0; row < rows; ++row) {
wmove(w, row + tpad, logo_left_pad);
wattrset(w, A_BOLD);
@@ -2019,8 +2019,8 @@
void push_controls_msg(void) {
struct Ctrl_item {
- char const* input;
- char const* desc;
+ char const *input;
+ char const *desc;
};
static struct Ctrl_item items[] = {
{"Ctrl+Q", "Quit"},
@@ -2068,9 +2068,9 @@
}
int mid_pad = 2;
int total_width = 1 + w_input + mid_pad + w_desc + 1;
- Qmsg* qm = qmsg_push(ORCA_ARRAY_COUNTOF(items), total_width);
+ Qmsg *qm = qmsg_push(ORCA_ARRAY_COUNTOF(items), total_width);
qmsg_set_title(qm, "Controls");
- WINDOW* w = qmsg_window(qm);
+ WINDOW *w = qmsg_window(qm);
for (int i = 0; i < (int)ORCA_ARRAY_COUNTOF(items); ++i) {
if (items[i].input) {
wmove(w, i, 1 + w_input - (int)strlen(items[i].input));
@@ -2086,8 +2086,8 @@
void push_opers_guide_msg(void) {
struct Guide_item {
char glyph;
- char const* name;
- char const* desc;
+ char const *name;
+ char const *desc;
};
static struct Guide_item items[] = {
{'A', "add", "Outputs sum of inputs."},
@@ -2138,9 +2138,9 @@
int mid_pad = 1;
int right_pad = 1;
int total_width = left_pad + 1 + mid_pad + w_desc + right_pad;
- Qmsg* qm = qmsg_push(ORCA_ARRAY_COUNTOF(items), total_width);
+ Qmsg *qm = qmsg_push(ORCA_ARRAY_COUNTOF(items), total_width);
qmsg_set_title(qm, "Operators");
- WINDOW* w = qmsg_window(qm);
+ WINDOW *w = qmsg_window(qm);
for (int i = 0; i < (int)ORCA_ARRAY_COUNTOF(items); ++i) {
wmove(w, i, left_pad);
waddch(w, (chtype)items[i].glyph | A_bold);
@@ -2150,14 +2150,14 @@
}
}
-void push_open_form(char const* initial) {
- Qform* qf = qform_create(Open_form_id);
+void push_open_form(char const *initial) {
+ Qform *qf = qform_create(Open_form_id);
qform_set_title(qf, "Open");
qform_add_text_line(qf, Open_name_text_line_id, initial);
qform_push_to_nav(qf);
}
-bool try_save_with_msg(Field* field, oso const* str) {
+bool try_save_with_msg(Field *field, oso const *str) {
if (!osolen(str))
return false;
bool ok = hacky_try_save(field, osoc(str));
@@ -2170,8 +2170,8 @@
return ok;
}
-void push_save_as_form(char const* initial) {
- Qform* qf = qform_create(Save_as_form_id);
+void push_save_as_form(char const *initial) {
+ Qform *qf = qform_create(Save_as_form_id);
qform_set_title(qf, "Save As");
qform_add_text_line(qf, Save_as_name_id, initial);
qform_push_to_nav(qf);
@@ -2178,10 +2178,10 @@
}
void push_set_tempo_form(Usz initial) {
- Qform* qf = qform_create(Set_tempo_form_id);
+ Qform *qf = qform_create(Set_tempo_form_id);
char buff[64];
int snres = snprintf(buff, sizeof buff, "%zu", initial);
- char const* inistr = snres > 0 && (Usz)snres < sizeof buff ? buff : "120";
+ char const *inistr = snres > 0 && (Usz)snres < sizeof buff ? buff : "120";
qform_set_title(qf, "Set BPM");
qform_add_text_line(qf, Tempo_text_line_id, inistr);
qform_push_to_nav(qf);
@@ -2188,10 +2188,10 @@
}
void push_set_grid_dims_form(Usz init_height, Usz init_width) {
- Qform* qf = qform_create(Set_grid_dims_form_id);
+ Qform *qf = qform_create(Set_grid_dims_form_id);
char buff[128];
int snres = snprintf(buff, sizeof buff, "%zux%zu", init_width, init_height);
- char const* inistr = snres > 0 && (Usz)snres < sizeof buff ? buff : "57x25";
+ char const *inistr = snres > 0 && (Usz)snres < sizeof buff ? buff : "57x25";
qform_set_title(qf, "Set Grid Size");
qform_add_text_line(qf, Dims_text_line_id, inistr);
qform_push_to_nav(qf);
@@ -2198,8 +2198,8 @@
}
#ifdef FEAT_PORTMIDI
-void push_portmidi_output_device_menu(Midi_mode const* midi_mode) {
- Qmenu* qm = qmenu_create(Portmidi_output_device_menu_id);
+void push_portmidi_output_device_menu(Midi_mode const *midi_mode) {
+ Qmenu *qm = qmenu_create(Portmidi_output_device_menu_id);
qmenu_set_title(qm, "PortMidi Device Selection");
PmError e = portmidi_init_if_necessary();
if (e) {
@@ -2218,7 +2218,7 @@
has_cur_dev_id = true;
}
for (int i = 0; i < num; ++i) {
- PmDeviceInfo const* info = Pm_GetDeviceInfo(i);
+ PmDeviceInfo const *info = Pm_GetDeviceInfo(i);
if (!info || !info->output)
continue;
bool is_cur_dev_id = has_cur_dev_id && cur_dev_id == i;
@@ -2243,7 +2243,7 @@
// Misc utils
//
-bool read_int(char const* str, int* out) {
+bool read_int(char const *str, int *out) {
int a;
int res = sscanf(str, "%d", &a);
if (res != 1)
@@ -2254,7 +2254,7 @@
// Reads something like '5x3' or '5'. Writes the same value to both outputs if
// only one is specified. Returns false on error.
-bool read_nxn_or_n(char const* str, int* out_a, int* out_b) {
+bool read_nxn_or_n(char const *str, int *out_a, int *out_b) {
int a, b;
int res = sscanf(str, "%dx%d", &a, &b);
if (res == EOF)
@@ -2278,7 +2278,7 @@
Bracketed_paste_sequence_end,
} Bracketed_paste_sequence;
-Bracketed_paste_sequence bracketed_paste_sequence_getch_ungetch(WINDOW* win) {
+Bracketed_paste_sequence bracketed_paste_sequence_getch_ungetch(WINDOW *win) {
int esc1 = wgetch(win);
if (esc1 == '[') {
int esc2 = wgetch(win);
@@ -2309,7 +2309,7 @@
return Bracketed_paste_sequence_none;
}
-void try_send_to_gui_clipboard(Ged const* a, bool* io_use_gui_clipboard) {
+void try_send_to_gui_clipboard(Ged const *a, bool *io_use_gui_clipboard) {
if (!*io_use_gui_clipboard)
return;
#if 0 // If we want to use grid directly
@@ -2339,22 +2339,22 @@
}
typedef struct {
- oso* portmidi_output_device;
+ oso *portmidi_output_device;
} Prefs;
-void prefs_init(Prefs* p) { memset(p, 0, sizeof(Prefs)); }
-void prefs_deinit(Prefs* p) { osofree(p->portmidi_output_device); }
+void prefs_init(Prefs *p) { memset(p, 0, sizeof(Prefs)); }
+void prefs_deinit(Prefs *p) { osofree(p->portmidi_output_device); }
typedef enum {
Prefs_load_ok = 0,
} Prefs_load_error;
-static char const* confkey_portmidi_output_device = "portmidi_output_device";
+static char const *confkey_portmidi_output_device = "portmidi_output_device";
ORCA_FORCE_NO_INLINE
-Prefs_load_error prefs_load_from_conf_file(Prefs* p) {
+Prefs_load_error prefs_load_from_conf_file(Prefs *p) {
(void)p;
- FILE* conffile = conf_file_open_for_reading();
+ FILE *conffile = conf_file_open_for_reading();
if (!conffile) {
return Prefs_load_ok;
}
@@ -2384,7 +2384,7 @@
return Prefs_load_ok;
}
-static void put_conf_pair(FILE* file, char const* left, char const* right) {
+static void put_conf_pair(FILE *file, char const *left, char const *right) {
fputs(left, file);
fputs(" = ", file);
fputs(right, file);
@@ -2408,7 +2408,7 @@
Prefs_save_unknown_error,
} Prefs_save_error;
-Prefs_save_error save_prefs_to_disk(Midi_mode const* midi_mode) {
+Prefs_save_error save_prefs_to_disk(Midi_mode const *midi_mode) {
Conf_save save;
Conf_save_start_error starterr = conf_save_start(&save);
switch (starterr) {
@@ -2437,7 +2437,7 @@
#endif
} midi_output_pref = Midi_output_pref_none;
Prefs_save_error error;
- oso* midi_output_device_name = NULL;
+ oso *midi_output_device_name = NULL;
switch (midi_mode->any.type) {
case Midi_mode_type_null:
break;
@@ -2531,9 +2531,9 @@
return error;
}
-void save_prefs_with_error_message(Midi_mode const* midi_mode) {
+void save_prefs_with_error_message(Midi_mode const *midi_mode) {
Prefs_save_error err = save_prefs_to_disk(midi_mode);
- char const* msg = "Unknown";
+ char const *msg = "Unknown";
switch (err) {
case Prefs_save_ok:
return;
@@ -2580,7 +2580,7 @@
qmsg_printf_push("Save Error", "Error when saving:\n%s", msg);
}
-void print_loading_message(char const* s) {
+void print_loading_message(char const *s) {
Usz len = strlen(s);
if (len > INT_MAX)
return;
@@ -2612,7 +2612,7 @@
Argopt_portmidi_deprecated,
};
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
static struct option tui_options[] = {
{"margins", required_argument, 0, Argopt_margins},
{"hard-margins", required_argument, 0, Argopt_hardmargins},
@@ -2629,10 +2629,10 @@
{"portmidi-output-device", required_argument, 0,
Argopt_portmidi_deprecated},
{NULL, 0, NULL, 0}};
- oso* file_name = NULL;
+ oso *file_name = NULL;
int undo_history_limit = 100;
- char const* osc_hostname = NULL;
- char const* osc_port = NULL;
+ char const *osc_hostname = NULL;
+ char const *osc_port = NULL;
bool strict_timing = false;
int init_bpm = 120;
int init_seed = 1;
@@ -2797,7 +2797,7 @@
if (osolen(file_name)) {
Field_load_error fle = field_load_file(osoc(file_name), &ged_state.field);
if (fle != Field_load_error_ok) {
- char const* errstr = field_load_error_string(fle);
+ char const *errstr = field_load_error_string(fle);
fprintf(stderr, "File load error: %s.\n", errstr);
ged_deinit(&ged_state);
qnav_deinit();
@@ -2895,7 +2895,7 @@
}
prefs_deinit(&prefs);
- WINDOW* cont_window = NULL;
+ WINDOW *cont_window = NULL;
int key = KEY_RESIZE;
wtimeout(stdscr, 0);
@@ -2917,7 +2917,7 @@
drew_any = true;
if (ged_is_draw_dirty(&ged_state) || drew_any) {
werase(cont_window);
- ged_draw(&ged_state, cont_window, (char const*)file_name);
+ ged_draw(&ged_state, cont_window, (char const *)file_name);
wnoutrefresh(cont_window);
drew_any = true;
}
@@ -2925,7 +2925,7 @@
if (qnav_stack.count > 0) // todo lame, move this
getmaxyx(stdscr, term_h, term_w);
for (Usz i = 0; i < qnav_stack.count; ++i) {
- Qblock* qb = qnav_stack.blocks[i];
+ Qblock *qb = qnav_stack.blocks[i];
if (qnav_stack.stack_changed) {
bool is_frontmost = i == qnav_stack.count - 1;
qblock_print_frame(qb, is_frontmost);
@@ -2933,7 +2933,7 @@
case Qblock_type_qmsg:
break;
case Qblock_type_qmenu: {
- Qmenu* qm = qmenu_of(qb);
+ Qmenu *qm = qmenu_of(qb);
qmenu_set_displayed_active(qm, is_frontmost);
} break;
case Qblock_type_qform:
@@ -3111,18 +3111,18 @@
#endif
}
- Qblock* qb = qnav_top_block();
+ Qblock *qb = qnav_top_block();
if (qb) {
if (key == CTRL_PLUS('q'))
goto quit;
switch (qb->tag) {
case Qblock_type_qmsg: {
- Qmsg* qm = qmsg_of(qb);
+ Qmsg *qm = qmsg_of(qb);
if (qmsg_drive(qm, key))
qnav_stack_pop();
} break;
case Qblock_type_qmenu: {
- Qmenu* qm = qmenu_of(qb);
+ Qmenu *qm = qmenu_of(qb);
Qmenu_action act;
// special case for main menu: pressing the key to open it will close
// it again.
@@ -3267,7 +3267,7 @@
}
} break;
case Qblock_type_qform: {
- Qform* qf = qform_of(qb);
+ Qform *qf = qform_of(qb);
Qform_action act;
if (qform_drive(qf, key, &act)) {
switch (act.any.type) {
@@ -3277,7 +3277,7 @@
case Qform_action_type_submitted: {
switch (qform_id(qf)) {
case Open_form_id: {
- oso* temp_name = NULL;
+ oso *temp_name = NULL;
if (qform_get_text_line(qf, Open_name_text_line_id, &temp_name) &&
osolen(temp_name) > 0) {
undo_history_push(&ged_state.undo_hist, &ged_state.field,
@@ -3309,7 +3309,7 @@
osofree(temp_name);
} break;
case Save_as_form_id: {
- oso* temp_name = NULL;
+ oso *temp_name = NULL;
if (qform_get_text_line(qf, Save_as_name_id, &temp_name) &&
osolen(temp_name) > 0) {
qnav_stack_pop();
@@ -3321,7 +3321,7 @@
osofree(temp_name);
} break;
case Set_tempo_form_id: {
- oso* tmpstr = NULL;
+ oso *tmpstr = NULL;
if (qform_get_text_line(qf, Tempo_text_line_id, &tmpstr) &&
osolen(tmpstr) > 0) {
int newbpm = atoi(osoc(tmpstr));
@@ -3333,7 +3333,7 @@
osofree(tmpstr);
} break;
case Set_grid_dims_form_id: {
- oso* tmpstr = NULL;
+ oso *tmpstr = NULL;
if (qform_get_text_line(qf, Tempo_text_line_id, &tmpstr) &&
osolen(tmpstr) > 0) {
int newheight, newwidth;