Skip to content

Commit

Permalink
Implement PGUP and PGDOWN support for skipping full screens
Browse files Browse the repository at this point in the history
Implements part of dwbuiten#2.

Signed-off-by: Derek Buitenhuis <[email protected]>
  • Loading branch information
dwbuiten committed Jan 6, 2019
1 parent 1c6d5b1 commit 8dba464
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ISC License (ISC)

Copyright (c) 2016, Derek Buitenhuis <derek.buitenhuis at gmail dot com>
Copyright (c) 2016-2019, Derek Buitenhuis <derek.buitenhuis at gmail dot com>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BXD: Binary Hex Diff
====================

Copyright (c) 2016 Derek Buitenhuis <derek.buitenhuis at gmail dot com>
Copyright (c) 2016-2019 Derek Buitenhuis <derek.buitenhuis at gmail dot com>

![BXD](http://chromashift.org/bxd.png)

Expand All @@ -28,7 +28,7 @@ Usage
Currently, the command like arguments are very simple:

Binary Hex Diff
Copyright (c) 2016 Derek Buitenhuis.
Copyright (c) 2016-2019 Derek Buitenhuis.

A tool to compare two arbitrarily sized binary files.

Expand All @@ -39,6 +39,7 @@ Keys are:
* `q` to quit.
* `space` to seek to next diff.
* `up`/`down` to scroll up and down.
* `pgup` / `pgdn` to scroll up and down by one full screen.

Current Limitations
-------------------
Expand Down
38 changes: 37 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main(int argc, char *argv[])

if (argc < 3) {
fprintf(stderr, "Binary Hex Diff\n"
"Copyright (c) 2016 Derek Buitenhuis.\n\n"
"Copyright (c) 2016-2019 Derek Buitenhuis.\n\n"
"A tool to compare two arbitrarily sized binary files.\n\n"
"Usage: %s file1 file2\n\n", argv[0]);
return 0;
Expand Down Expand Up @@ -124,6 +124,42 @@ int main(int argc, char *argv[])

break;
}
case TB_KEY_PGUP: {
unsigned int lpu = get_line_per_side();

for (unsigned int i = 0; i < lpu; i++) {
if (ctx.offset == 0) {
if (ctx.nf_offset != 0 && ctx.of_offset != 0)
load_previous(&ctx, &lbuf[0], scratch);
} else {
ctx.offset -= 2;
}
}
break;
}
case TB_KEY_PGDN: {
unsigned int cpl = get_char_per_line();
unsigned int lpu = get_line_per_side();

if (ctx.done)
continue;

for (unsigned int i = 0; i < lpu && !ctx.done; i++) {
ctx.offset += 2;

if (((size_t) ctx.offset / 2) * cpl + cpl * lpu >= ctx.blocksize) {
bool err;

calc_next_mask(&ctx, &lbuf[0], scratch, &err);

if (err)
goto end;
}

draw_ui_dummy(&ctx);
}
break;
}
case TB_KEY_SPACE: {
unsigned int cpl = get_char_per_line();
unsigned int lpu = get_line_per_side();
Expand Down

0 comments on commit 8dba464

Please sign in to comment.