Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmatrix.1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Use old-style scrolling
Only print the shadows of letters
.TP
.I "\-L"
Locks cmatrix, Unable to quit
Locks cmatrix making the program non-exitable. Unlock again by pressing L thrice.
.TP
.I "\-h, \-?"
Print usage and exit
Expand Down
10 changes: 9 additions & 1 deletion cmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ typedef struct cmatrix {
int console = 0;
int xwindow = 0;
int lock = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change type to bool from stdbool.h ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

int lock_count = 0;
Copy link

@PaulCoral PaulCoral Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be unsigned, maybe uint8_t from stdint.h.

cmatrix **matrix = (cmatrix **) NULL;
int *length = NULL; /* Length of cols in each line */
int *spaces = NULL; /* Spaces left to fill */
Expand Down Expand Up @@ -154,7 +155,7 @@ void usage(void) {
printf(" -c: Use Japanese characters as seen in the original matrix. Requires appropriate fonts\n");
printf(" -f: Force the linux $TERM type to be on\n");
printf(" -l: Linux mode (uses matrix console font)\n");
printf(" -L: Lock mode (can be closed from another terminal)\n");
printf(" -L: Lock mode (Press L three times to unlock)\n");
printf(" -o: Use old-style scrolling\n");
printf(" -h: Print usage and exit\n");
printf(" -n: No bold characters (overrides -b and -B, default)\n");
Expand Down Expand Up @@ -598,7 +599,14 @@ if (console) {
bold = 2;
break;
case 'L':
if (lock == 1) {
lock_count++;
}
Comment on lines +602 to +604

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add :

} else {
    lock_count = 0;
    lock = 1;
}

lock = 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ? This causes the bug where you press four times L and it breaks. See previous comment.

if (lock_count == 3) {
lock = 0;
lock_count = 0;
}
break;
case 'n':
bold = 0;
Expand Down