[lwatch-cvs] files/src control.c,1.17,1.18 settings.c,1.24,1.25 strpcre.c,1.18,1.19
Brought to you by:
arturcz
|
From: <os...@us...> - 2004-01-12 18:42:39
|
Update of /cvsroot/lwatch/files/src
In directory sc8-pr-cvs1:/tmp/cvs-serv11804/src
Modified Files:
control.c settings.c strpcre.c
Log Message:
Fixed SIGWINCH handling.
Now parse -t option.
First attempt to actual cutting (not working, yet).
Index: control.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/control.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** control.c 12 Jan 2004 11:17:55 -0000 1.17
--- control.c 12 Jan 2004 18:42:36 -0000 1.18
***************
*** 84,88 ****
#ifdef RESIZE
case SIGWINCH: /* Window resize */
! printf("aaa\n");
win_width=get_term_width();
break;
--- 84,88 ----
#ifdef RESIZE
case SIGWINCH: /* Window resize */
! loop=1;
win_width=get_term_width();
break;
Index: settings.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/settings.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** settings.c 12 Jan 2004 12:46:22 -0000 1.24
--- settings.c 12 Jan 2004 18:42:36 -0000 1.25
***************
*** 147,151 ****
#endif
memset(&lw_conf,0,sizeof(lw_conf));
! while((c=getopt_long(argc,argv,"vC:f:i:co:Osh",opt,&idx))!=EOF) {
switch(c) {
case 'C':
--- 147,151 ----
#endif
memset(&lw_conf,0,sizeof(lw_conf));
! while((c=getopt_long(argc,argv,"vC:f:i:co:Osht",opt,&idx))!=EOF) {
switch(c) {
case 'C':
Index: strpcre.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/strpcre.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** strpcre.c 11 Jan 2004 21:23:48 -0000 1.18
--- strpcre.c 12 Jan 2004 18:42:36 -0000 1.19
***************
*** 163,168 ****
}
void showline(char *input) {
! int i,n,ignore;
const char **re_str;
char *match;
--- 163,181 ----
}
+ char* cut_line(char *output, char *input,int real_len)
+ {
+ int to_cut=real_len-win_width;
+ printf("%d - %d = %d\n",real_len,win_width,to_cut);
+ if (to_cut<1) {output=input; return output;}
+ strncpy(output,input,strlen(input));
+ output[strlen(input)-to_cut+1]=0;
+ while (to_cut) {
+ to_cut--;
+ }
+ return output;
+ }
+
void showline(char *input) {
! int i,n,ignore,hl_num;
const char **re_str;
char *match;
***************
*** 176,179 ****
--- 189,193 ----
hl_c=0;
ignore=0;
+ hl_num=0;
n=pcre_exec(parser.pre,parser.prh,input,strlen(input),0,0,
(int*)&re_matches,RE_NMATCHES);
***************
*** 206,209 ****
--- 220,224 ----
if(lw_actions[i].mesg_color) mesg_c=lw_actions[i].mesg_color;
if(lw_actions[i].highlight_color) {
+ hl_num++;
hl_c=lw_actions[i].highlight_color;
match=hl_str(&lw_actions[i],mesg_s);
***************
*** 220,225 ****
if(!ignore) {
char *cstr;
! cstr=(char*)malloc(strlen(date_s)+strlen(host_s)+
! strlen(serv_s)+strlen(mesg_s)+17);
sprintf(cstr,"^%02i%s^%02i%s^%02i%s^%02i%s^01\n",
DATE_COLOR,date_s,
--- 235,246 ----
if(!ignore) {
char *cstr;
! #ifdef RESIZE
! char *cutstr;
! #endif
! int len=strlen(date_s)+strlen(host_s)+strlen(serv_s)+strlen(mesg_s)+17;
! cstr=(char*)malloc(len);
! #ifdef RESIZE
! cutstr=(char*)malloc(len);
! #endif
sprintf(cstr,"^%02i%s^%02i%s^%02i%s^%02i%s^01\n",
DATE_COLOR,date_s,
***************
*** 227,231 ****
--- 248,258 ----
SERV_COLOR,serv_s,
MESG_COLOR,mesg_s);
+ #ifdef RESIZE
+ if (lw_conf.term_cut) cutstr=cut_line(cutstr,cstr,len-hl_num*6-5*3);
+ cprintf(cutstr);
+ free((void*)cutstr);
+ #else
cprintf(cstr);
+ #endif
free((void*)cstr);
}
|