From 3dd843b919cc84f1c0260ca3a5d420923592165b Mon Sep 17 00:00:00 2001 From: mathfigure Date: Mon, 20 Feb 2017 21:10:28 +0000 Subject: [PATCH 1/3] added auto-refresh --- hexedit.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/hexedit.c b/hexedit.c index 4fa670f..be77e7e 100644 --- a/hexedit.c +++ b/hexedit.c @@ -1,5 +1,6 @@ /* hexedit -- Hexadecimal Editor for Binary Files Copyright (C) 1998 Pixel (Pascal Rigaux) + - auto-refresh mod by mathfigure This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/ #include "hexedit.h" - +#include /*******************************************************************************/ /* Global variables */ @@ -48,6 +49,28 @@ char * usage = "usage: %s [-s | --sector] [-m | --maximize] [-l | --linelengt " [-h | --help] filename\n"; +int kbhit(void) +{ + nodelay(stdscr, TRUE); + int c = getch(); + if (c != ERR) { + ungetch(c); + c = 1; + } else { + c = 0; + } + nodelay(stdscr, FALSE); + return c; +} + +void nanowait(long nsec) +{ + struct timespec req; + req.tv_sec = 0; + req.tv_nsec = nsec; + nanosleep(&req, 0); +} + /*******************************************************************************/ /* main */ /*******************************************************************************/ @@ -98,9 +121,15 @@ int main(int argc, char **argv) } openFile(); } - readFile(); - do display(); - while (key_to_function(getch())); + do { + readFile(); + display(); + if(kbhit()) { + if(!key_to_function(getch())) break; + } else { + nanowait(1000000000/50); + } + } while (1); quit(); return 0; /* for no warning */ } From 3280718fe00a2181f3f50d443b37a712b33e9eda Mon Sep 17 00:00:00 2001 From: mathfigure Date: Mon, 20 Feb 2017 18:35:23 +0000 Subject: [PATCH 2/3] added README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..28e9ffa --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +## hexedit with auto-refresh +A fork of https://github.com/pixel/hexedit +Added auto-refresh which is useful with frequently updated files. + +### download & build +git clone https://github.com/mathfigure/hexedit +cd hexedit +autoconf +autoheader +./configure +make + +### test +./hexedit /dev/shm/some-highly-dynamic-file From 5d5184c3afc72bd3fc2cd7167db9c490d0ef054b Mon Sep 17 00:00:00 2001 From: mathfigure Date: Tue, 7 Mar 2017 12:33:50 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 28e9ffa..53311c9 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,23 @@ A fork of https://github.com/pixel/hexedit Added auto-refresh which is useful with frequently updated files. -### download & build -git clone https://github.com/mathfigure/hexedit -cd hexedit -autoconf -autoheader -./configure +### Download +```bash +git clone https://github.com/mathfigure/hexedit +``` +### Build +```bash +cd hexedit +autoreconf -fi +./configure make - -### test -./hexedit /dev/shm/some-highly-dynamic-file +``` +### Install +```bash +sudo make install +``` +### Test +```bash +hexedit /dev/urandom +hexedit /dev/shm/some-highly-dynamic-file +```