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
27 changes: 19 additions & 8 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void helpscreen(char* argv0,int exitval)
fprintf(stderr," -g, -G show the license\n");
fprintf(stderr," -f, -F [configfile] read the config from [configfile]\n");
fprintf(stderr," -m, -M [markerfile] read the bookmarks from [markerfile]\n");
fprintf(stderr," -b, -B [bytes] output [bytes] bytes per output line\n");
fprintf(stderr,"\n");
fprintf(stderr,"%s [Parameters] [Filename]: Edit a single file\n",argv0);
fprintf(stderr," -ab, -AB [x] set the base address to [x] (binary)\n");
Expand Down Expand Up @@ -130,7 +131,7 @@ int parsecursorpos(tInt64* cursorpos1,tInt64* cursorpos2,char* lastopt,char* arg
return RETOK;

}
int parsecommandlineoptions(int argc,char** argv,tInt64* baseaddr1,tInt64* baseaddr2,tInt64* cursorpos1,tInt64* cursorpos2,tBool* diffmode,int* filename1,int* filename2,tBool* keyboardsetupreq,char* markerfilename,char* configfile,tSearch* search1,tBool* gosearch1,tSearch* search2,tBool* gosearch2,tCorrelation* correlation,tBool* gocorr)
int parsecommandlineoptions(int argc,char** argv,tInt64* baseaddr1,tInt64* baseaddr2,tInt64* cursorpos1,tInt64* cursorpos2,tBool* diffmode,int* filename1,int* filename2,tBool* keyboardsetupreq,char* markerfilename,char* configfile,tSearch* search1,tBool* gosearch1,tSearch* search2,tBool* gosearch2,tCorrelation* correlation,tBool* gocorr,int* dispWidth)
{
int filenamecnt=0;
int i;
Expand Down Expand Up @@ -341,6 +342,15 @@ int parsecommandlineoptions(int argc,char** argv,tInt64* baseaddr1,tInt64* basea
case 'M':
if (markerfilename) memcpy(markerfilename,argv[i],64);
break;
case 'b':
case 'B':
*dispWidth = atoi(argv[i]);
if (*dispWidth < 1)
{
fprintf(stderr,"invalid bytes per output line\n");
retval=RETNOK;
}
break;
default:
retval=RETNOK;
break;
Expand Down Expand Up @@ -374,6 +384,7 @@ int main(int argc,char** argv)
tOutput* output=NULL;
tInt64 baseaddr1=0;
tInt64 cursorpos1;
int dispWidth=0;
tInt64 firstpos1;
tInt64 baseaddr2=0;
tInt64 cursorpos2;
Expand Down Expand Up @@ -416,7 +427,7 @@ int main(int argc,char** argv)
clearsearch(&search1);
clearsearch(&search2);
clear_correlation(&correlation);
if (parsecommandlineoptions(argc,argv,&baseaddr1,&baseaddr2,&cursorpos1,&cursorpos2,&diffmode,&filename1,&filename2,&keyboardsetupreq,markerfilename,configfile,&search1,&gosearch1,&search2,&gosearch2,&correlation,&gocorr)!=RETOK)
if (parsecommandlineoptions(argc,argv,&baseaddr1,&baseaddr2,&cursorpos1,&cursorpos2,&diffmode,&filename1,&filename2,&keyboardsetupreq,markerfilename,configfile,&search1,&gosearch1,&search2,&gosearch2,&correlation,&gocorr,&dispWidth)!=RETOK)
{
if (output)
{
Expand Down Expand Up @@ -535,9 +546,9 @@ int main(int argc,char** argv)
{
printmainmenu(output,diffmode);
if (diffmode)
printbufferdiff(output,buf1,buf2,cursorpos1,cursorpos2);
printbufferdiff(output,buf1,buf2,cursorpos1,cursorpos2,dispWidth);
else
printbuffersingle(output,buf1,cursorpos1,firstpos1,windowfield);
printbuffersingle(output,buf1,cursorpos1,firstpos1,windowfield,dispWidth);
ch=getkey((tKeyTab*)output->pKeyTab,1);

#define MOVEMENTDEFINE(KEY,VIKEY,mvchar,mvline,mvpage) \
Expand All @@ -549,11 +560,11 @@ int main(int argc,char** argv)
oldfirstpos2=firstpos2; \
oldcursorpos2=cursorpos2; \
\
err=movepositions(&cursorpos1,&firstpos1,buf1->bufsize,mvchar,mvline,mvpage,diffmode); \
err=movepositions(&cursorpos1,&firstpos1,buf1->bufsize,mvchar,mvline,mvpage,diffmode,dispWidth); \
\
if (diffmode) \
{ \
movepositions(&cursorpos2,&firstpos2,buf2->bufsize,mvchar,mvline,mvpage,diffmode); \
movepositions(&cursorpos2,&firstpos2,buf2->bufsize,mvchar,mvline,mvpage,diffmode,dispWidth); \
err=((cursorpos1<0 && cursorpos2<0) || (cursorpos1>buf1->bufsize && cursorpos2>buf2->bufsize)); \
} \
if (err) \
Expand Down Expand Up @@ -718,7 +729,7 @@ int main(int argc,char** argv)
buf1->changes[buf1->changesnum].pos=cursorpos1;
buf1->changes[buf1->changesnum].after=buf1->nexthex;
buf1->changesnum++;
movepositions(&cursorpos1,&firstpos1,buf1->bufsize,1,0,0,diffmode);
movepositions(&cursorpos1,&firstpos1,buf1->bufsize,1,0,0,diffmode,dispWidth);
}
buf1->nibble=!buf1->nibble;
buf1->changepos=cursorpos1;
Expand All @@ -729,7 +740,7 @@ int main(int argc,char** argv)
buf1->changes[buf1->changesnum].pos=cursorpos1;
buf1->changes[buf1->changesnum].after=ch;
buf1->changesnum++;
movepositions(&cursorpos1,&firstpos1,buf1->bufsize,1,0,0,diffmode);
movepositions(&cursorpos1,&firstpos1,buf1->bufsize,1,0,0,diffmode,dispWidth);
}
}
if (ch==KEYF10)
Expand Down
12 changes: 6 additions & 6 deletions output.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void drawcenterframe(tOutput* output,tInt8 h,tInt8 w,char* header)
{
drawframe(output,LINES/2-h/2,COLS/2-w/2,h,w,header);
}
void printbuffersingle(tOutput* output,tBuffer* hBuf1,tInt64 cursorpos1,tUInt64 firstpos1,tUInt8 windowfield)
void printbuffersingle(tOutput* output,tBuffer* hBuf1,tInt64 cursorpos1,tUInt64 firstpos1,tUInt8 windowfield,int dispWidth)
{
int i;
int j;
Expand All @@ -92,7 +92,7 @@ void printbuffersingle(tOutput* output,tBuffer* hBuf1,tInt64 cursorpos1,tUInt64


addrwidth=((hBuf1->bufsize+hBuf1->baseaddr)>0xffffffffull)?16:8;
bytesperline=(COLS-(addrwidth+3+3))*8/(8*3+8+1); // this many bytes can be printed in one line. every 8 bytes there is an extra space in the hex field.
bytesperline=dispWidth?dispWidth:(COLS-(addrwidth+3+3))*8/(8*3+8+1); // this many bytes can be printed in one line. every 8 bytes there is an extra space in the hex field.

setcolor(output,COLOR_HEADLINE);
wmove(output->win,0,0);
Expand Down Expand Up @@ -196,7 +196,7 @@ void printbuffersingle(tOutput* output,tBuffer* hBuf1,tInt64 cursorpos1,tUInt64
}
}
}
void printbufferdiff(tOutput* output,tBuffer* hBuf1,tBuffer* hBuf2,tInt64 cursorpos1,tInt64 cursorpos2)
void printbufferdiff(tOutput* output,tBuffer* hBuf1,tBuffer* hBuf2,tInt64 cursorpos1,tInt64 cursorpos2,int dispWidth)
{
int i;
int j;
Expand All @@ -211,7 +211,7 @@ void printbufferdiff(tOutput* output,tBuffer* hBuf1,tBuffer* hBuf2,tInt64 cursor


addrwidth=((hBuf1->bufsize+hBuf1->baseaddr)>0xffffffffull || (hBuf2->bufsize+hBuf2->baseaddr)>0xffffffffull)?16:8;
bytesperline=(COLS-(addrwidth+3+3))*8/(8*3+8+1); // this many bytes can be printed in one line. every 8 bytes there is an extra space in the hex field.
bytesperline=dispWidth?dispWidth:(COLS-(addrwidth+3+3))*8/(8*3+8+1); // this many bytes can be printed in one line. every 8 bytes there is an extra space in the hex field.

setcolor(output,COLOR_HEADLINE);
wmove(output->win,0,0);
Expand Down Expand Up @@ -452,7 +452,7 @@ void printmainmenu(tOutput* output,tBool diffmode)
}

}
tInt32 movepositions(tInt64* cursorpos,tInt64* firstpos,tInt64 maxbufsize,tInt32 chars,tInt32 lines,tInt32 pages,tBool diffmode)
tInt32 movepositions(tInt64* cursorpos,tInt64* firstpos,tInt64 maxbufsize,tInt32 chars,tInt32 lines,tInt32 pages,tBool diffmode,int dispWidth)
{
tInt32 bytesperline;
tInt32 bytesperhalfpage;
Expand All @@ -464,7 +464,7 @@ tInt32 movepositions(tInt64* cursorpos,tInt64* firstpos,tInt64 maxbufsize,tInt32


addrwidth=(maxbufsize>0xffffffffull)?16:8;
bytesperline=(COLS-(addrwidth+3+3))*8/(8*3+8+1); // this many bytes can be printed in one line. every 8 bytes there is an extra space in the hex field.
bytesperline=dispWidth?dispWidth:(COLS-(addrwidth+3+3))*8/(8*3+8+1); // this many bytes can be printed in one line. every 8 bytes there is an extra space in the hex field.
bytesperhalfpage=bytesperline*(LINES/2-2);
bytesperpage=bytesperline*(LINES-2);

Expand Down
6 changes: 3 additions & 3 deletions output.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ void initcolors();
void colorpair(tOutput* output,uicolors uicol,short fg,short bg,int attr);
void pairsinit(tOutput* output);
void setcolor(tOutput* output,uicolors col);
void printbuffersingle(tOutput* output,tBuffer* hBuf1,tInt64 cursorpos1,tUInt64 firstpos1,tUInt8 windowfield);
void printbufferdiff(tOutput* output,tBuffer* hBuf1,tBuffer* hBuf2,tInt64 cursorpos1,tInt64 cursorpos2);
void printbuffersingle(tOutput* output,tBuffer* hBuf1,tInt64 cursorpos1,tUInt64 firstpos1,tUInt8 windowfield,int dispWidth);
void printbufferdiff(tOutput* output,tBuffer* hBuf1,tBuffer* hBuf2,tInt64 cursorpos1,tInt64 cursorpos2,int dispWidth);
void printmainmenu(tOutput* output,tBool diffmode);
void drawframe(tOutput* output,tInt16 y,tInt16 x,tInt8 h,tInt8 w,char* header);
void drawcenterframe(tOutput* output,tInt8 h,tInt8 w,char* header);
tInt32 movepositions(tInt64* cursorpos,tInt64* firstpos,tInt64 maxbufsize,tInt32 chars,tInt32 lines,tInt32 pages,tBool diffmode);
tInt32 movepositions(tInt64* cursorpos,tInt64* firstpos,tInt64 maxbufsize,tInt32 chars,tInt32 lines,tInt32 pages,tBool diffmode,int dispWidth);

#endif