/*{{{ clean*/ void clean(int n) { m_setcursor(CS_BLOCK); m_pop(); m_flush(); m_ttyreset(); exit(n); }
/*{{{ clean*/ void clean(int n) { m_bitdestroy(EYE_BITMAP); m_setcursor(CS_BLOCK); m_pop(); m_flush(); m_ttyreset(); exit(n); }
static void cleanup() { /* be a nice program and clean up */ int i; m_ttyreset(); /* reset echo */ for (i = 1; i <= bitcount; i++) /* free up bitmaps */ m_bitdestroy(i); m_pop(); /* pop environment */ exit(0); }
int main(int argc, char *argv[]) { register int i; int xpos = XPOS; int ypos = YPOS; int font = -1; int shape = 1; char *getenv(); char *home = getenv("HOME"); int clean(), update(); /* make sure we have a valid environment to run in */ ckmgrterm( *argv ); if (home==NULL || *home=='\0') { fprintf(stderr,"%s: Can't find your home directory\n",argv[0]); exit(1); } if ((bounds = fopen(BOUNDS,"r")) == NULL) { fprintf(stderr,"%s: Can't find a bounds file\n",argv[0]); exit(2); } sprintf(line,"%s/%s",home,RC); if ((rc = fopen(line,"r")) == NULL) { fprintf(stderr,"%s: Can't find %s\n",argv[0],line); exit(3); } /* process arguments */ for(i=1;i<argc;i++) { if (Isflag(argv[i],"-s")) shape = 0; else if (Isflag(argv[i],"-x")) xpos = atoi(argv[i]+2); else if (Isflag(argv[i],"-y")) ypos = atoi(argv[i]+2); else if (Isflag(argv[i],"-f")) font = atoi(argv[i]+2); else if (Isflag(argv[i],"-p")) poll = Max(atoi(argv[i]+2),10); else usage(argv[0],argv[i]); } /* setup mgr stuff */ m_setup(M_FLUSH); m_push(P_MENU|P_EVENT|P_FLAGS); m_setmode(M_NOWRAP); m_ttyset(); signal(SIGTERM,clean); signal(SIGINT,clean); signal(SIGALRM,update); menu_load(1,MENU_COUNT,menu); m_selectmenu(1); old_msg_cnt = MSGS(); get_msg(line,old_msg_cnt); if (shape) { m_setmode(M_ACTIVATE); m_size(strlen(line)+2,1); } m_printstr(line); m_setevent(REDRAW,"R\n"); m_setevent(ACTIVATED,"A\n"); m_clearmode(M_ACTIVATE); alarm(poll); while(1) { char buff[80]; m_gets(buff); alarm(0); /* read msgs */ old_msg_cnt = msg_cnt; msg_cnt = MSGS(); if (msg_cnt > 0 && *buff == 'A') { m_push(P_POSITION|P_EVENT|P_FLAGS|P_FONT); if (font != -1) m_font(font); m_sizeall(xpos,ypos,80,24); m_printstr("\freading msgs...\r"); m_ttyreset(); system(MSGSCMD); m_gets(buff); m_ttyset(); m_pop(); } /* wait for window to deactivate */ else if (*buff == 'A') { m_setevent(DEACTIVATED,RESUME); do { m_printstr("\f Your msgs system here "); m_gets(buff); } while(!SCMP(buff,RESUME)); m_clearevent(DEACTIVATED); } old_msg_cnt = msg_cnt; msg_cnt = MSGS(); get_msg(line,msg_cnt); m_printstr(line); m_clearmode(M_ACTIVATE); alarm(poll); } return 0; }