"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/showlist.cpp" between
bed-3.0.2.src.tar.xz and bed-3.0.3.src.tar.xz

About: bed is an adjustable data format binary editor.

showlist.cpp  (bed-3.0.2.src.tar.xz):showlist.cpp  (bed-3.0.3.src.tar.xz)
skipping to change at line 40 skipping to change at line 40
#include <alloca.h> #include <alloca.h>
#undef isprint #undef isprint
#define isprint(x) ((x)>31&&(x)<127) #define isprint(x) ((x)>31&&(x)<127)
#include <unistd.h> #include <unistd.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
#include <sys/types.h> #include <sys/types.h>
#include <assert.h>
#include "dialog.h" #include "dialog.h"
#include "screen.h" #include "screen.h"
#include "system.h" #include "system.h"
#include "readconfig.h" #include "readconfig.h"
#include "onlykey.h" #include "onlykey.h"
#include "keyinput.h" #include "keyinput.h"
#include "myalloc.h" #include "myalloc.h"
#define trefresh(x) #define trefresh(x)
extern WINDOW *rightwin(int l,int c,int by,int bx) ; extern WINDOW *rightwin(int l,int c,int by,int bx) ;
skipping to change at line 188 skipping to change at line 189
showsel(); showsel();
return; return;
} }
if(possel!=endscreen) { if(possel!=endscreen) {
possel=next(possel); possel=next(possel);
sel++; sel++;
showsel(); showsel();
return ; return ;
} }
else { else {
startscreen=next(startscreen); if(startscreen!=endpos) {
rewrite(); startscreen=next(startscreen);
rewrite();
}
else
beep();
} }
}; };
template <typename I,typename B> template <typename I,typename B>
void showlist<I,B>::up(void) { void showlist<I,B>::up(void) {
if(possel==startpos) { if(possel==startpos) {
beep(); beep();
showsel(); showsel();
return; return;
} }
if(possel!=startscreen) { if(possel!=startscreen) {
skipping to change at line 305 skipping to change at line 310
} }
}; };
#include "marks.h" #include "marks.h"
#include "screenpart.h" #include "screenpart.h"
struct marklister { struct marklister {
ScreenPart *part; ScreenPart *part;
keylookup *look; keylookup *look;
char *numstr; char *numstr;
int maxnumstr; int maxnumstr;
}; };
/*
class showmark { class showmark {
ScreenPart *part; ScreenPart *part;
char *numstr; char *numstr;
const int bymax; const int bymax;
protected: protected:
using Pos = keylookup::mark; using Pos = keylookup::mark;
char *data(Pos *m) { char *data(Pos *m) {
static constexpr int maxbuf=256; static constexpr int maxbuf=256;
static char buf[maxbuf]; static char buf[maxbuf];
skipping to change at line 331 skipping to change at line 337
Pos *next(Pos *m) { Pos *next(Pos *m) {
return m->next; return m->next;
}; };
Pos *prev(Pos *m) { Pos *prev(Pos *m) {
return m->prev; return m->prev;
}; };
Pos *startpos,*endpos,*startscreen,*endscreen; Pos *startpos,*endpos,*startscreen,*endscreen;
showmark(marklister gegs): part(gegs.part), numstr(gegs.numstr),bymax(MAX MARKALL-3-gegs.maxnumstr), showmark(marklister gegs): part(gegs.part), numstr(gegs.numstr),bymax(MAX MARKALL-3-gegs.maxnumstr),
startpos(gegs.look->begin.next), endpos(gegs.look->head),startscreen(gegs .look->iter->next) {}; startpos(gegs.look->begin.next), endpos(gegs.look->head),startscreen(gegs .look->iter->next) {};
}; };
*/
#include "editor.h" class showmark {
ScreenPart *part;
#define marx (*marksptr) //keylookup *look;
#if 0 char *numstr;
int Editor::showmarks(void) { const int bymax;
auto total=marx.gettotal();
if(total<=0) {
output("0 marks, nothing to show");
return -1;
}
extern unsigned long long startuptime;
if(backgroundsearch&& (startuptime/total)>30)
return showmarkswhole();
return showmarksincr();
}
int Editor::showmarksincr(void) {
auto total=marx.gettotal();
if(total<=0) {
output("0 marks, nothing to show");
return -1;
}
const int bufsize=30;
char buf[bufsize];
if(backgroundsearch)
output("Background search waits before adding marks during marks viewing"
);
#ifdef USETHREADS
sem_wait(&sema);
#endif
ScreenPart *activepart=parts[mode]->getsubpart();
showlist<marklister,showmark> shower(total>1?(snprintf(buf,bufsize,"%d ma
rks made",total),buf):"1 mark made",{activepart,marksptr,numstr,maxnumstr});
struct keylookup::mark *mark; protected:
while((mark=shower.selectloop()) == reinterpret_cast<struct keylookup::ma using Pos = keylookup::mark;
rk *>(UINTPTR_MAX)) { char *data(Pos *m) {
menuresized(); static constexpr int maxbuf=256;
wrefresh(editscreen); static char buf[maxbuf];
} int slen=part->bin2search((unsigned char *)m->des, buf, bymax) ;
if(mark) { for(int s=minnum(slen,bymax);s<bymax+3;s++)
mkstandout( mark->pos, mark->len); buf[s]=' ';
marx.select(mark); snprintf(buf+bymax+3,maxbuf-bymax-3,numstr ,m->pos);
marx.prev(); return buf;
} };
#ifdef USETHREADS Pos *next(Pos *m) {
sem_post(&sema); // assert(m!=look->head);
#endif return m->next;
editup(); };
return 0; Pos *prev(Pos *m) {
} // assert(m->prev!=look->head);
#endif return m->prev;
//total>1?(snprintf(buf,bufsize,"%d marks made",total),buf):"1 mark made" };
Pos *startpos,*endpos,*startscreen,*endscreen;
// showmark(marklister gegs): part(gegs.part), look(gegs.look),numstr(gegs.n
umstr),bymax(MAXMARKALL-3-gegs.maxnumstr),
showmark(marklister gegs): part(gegs.part),numstr(gegs.numstr),bymax(MAXM
ARKALL-3-gegs.maxnumstr),
startpos(gegs.look->begin.next), endpos(gegs.look->head),startscreen(gegs
.look->iter==endpos?endpos:gegs.look->iter->next) {};
};
//int Editor::showmarksincr(void) { #include "editor.h"
template <> struct keylookup::mark *Editor::markselect<2>(const char *prompt) { template <> struct keylookup::mark *Editor::markselect<2>(const char *prompt) {
if(backgroundsearch) if(backgroundsearch)
output("Background search waits before adding marks during marks viewing" ); output("Background search waits before adding marks during marks viewing" );
#ifdef USETHREADS #ifdef USETHREADS
sem_wait(&sema); sem_wait(&sema);
#endif #endif
ScreenPart *activepart=parts[mode]->getsubpart(); ScreenPart *activepart=parts[mode]->getsubpart();
skipping to change at line 417 skipping to change at line 400
#endif #endif
editup(); editup();
return mark; return mark;
} }
//template struct keylookup::mark *Editor::markselect<1>(const char *prompt) ; //template struct keylookup::mark *Editor::markselect<1>(const char *prompt) ;
// //
template <> struct keylookup::mark * Editor::markselect<0>(const char *prompt) { template <> struct keylookup::mark * Editor::markselect<0>(const char *prompt) {
#ifdef USETHREADS #ifdef USETHREADS
sem_wait(&sema); sem_wait(&sema);
#endif #endif
unsigned int total= marx.gettotal(); unsigned int total= marksptr->gettotal();
#ifdef USETHREADS #ifdef USETHREADS
sem_post(&sema); sem_post(&sema);
#endif #endif
if(total<=0) { if(total<=0) {
output("0 marks, nothing to show"); output("0 marks, nothing to show");
return nullptr; return nullptr;
} }
extern unsigned long long showmarkswhole; extern unsigned long long showmarkswhole;
if(backgroundsearch&& (total<showmarkswhole)) if(backgroundsearch&& (total<showmarkswhole))
return markselect<1>(prompt); return markselect<1>(prompt);
else else
return markselect<2>(prompt) ; return markselect<2>(prompt) ;
} }
/*
int Editor::showmarkswhole(void) {
static int size=STARTSHOW;
static char **names=myallocarpr(char **,char*,STARTSHOW);
struct keylookup::mark *mark,*first;
int i,take=0,ant,tot,ret=-1;
ScreenPart *activepart=parts[mode]->getsubpart();
#ifdef USETHREADS
sem_wait(&sema);
#endif
first=marx.next();
marx.tobegin();
int aloc=maxnum(((MAXMARKDAT/activepart->bytes)+1)*(activepart->maxres+act
ivepart->apart+1),MAXFILES)+1+sizeof(mark);
for(i=0;(mark=marx.next());i++) {
if(first==mark)
take=i;
if(i>=size) {
const int oldsize __attribute__ ((unused)) =size;
size*=2;
names=myrealloc(char **,names,char*,size,oldsize);
}
names[i]=myallocar(char,aloc);
int slen=activepart->fromascii((unsigned char*)names[i], (unsigne
d char *)mark->des,MAXMARKDAT);
if(slen<MAXMARKDAT)
for(int s=slen;s<MAXMARKDAT;s++)
names[i][s]=' ';
for(int s=MAXMARKDAT;s<(MAXMARKDAT+3);s++)
names[i][s]=' ';
snprintf(names[i]+MAXMARKDAT+3,MAXFILES,numstr ,mark->pos);
memcpy(names[i]+MAXFILES+1,((char *)&mark),sizeof(mark));
}
#ifdef USETHREADS
sem_post(&sema);
#endif
tot=i;
int bufsize=30;
char buf[bufsize];
snprintf(buf,bufsize,"%d marks made",marx.gettotal());
while((ant=selectitemindex(buf,names,i,take))!=INT_MAX) {
if(ant==(INT_MAX-1)) {
menuresized();
wrefresh(editscreen);
}
else {
memcpy((char *)&first ,names[ant]+MAXFILES+1,si
zeof(first));
ret=mkstandout( first->pos, first->len);
goto end;
break;
}
}
end:
marx.select(first);
marx.prev();
for(i=0;i<tot;i++)
myrefree(names[i]);
editup();
return ret;
}
*/
 End of changes. 9 change blocks. 
60 lines changed or deleted 43 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)