Browse Source

shrink space at end of lines

Olivier Marty 8 years ago
parent
commit
a359d67686
7 changed files with 28 additions and 32 deletions
  1. 1 1
      LICENSE
  2. 0 1
      Makefile
  3. 0 1
      events.h
  4. 10 10
      main.c
  5. 0 1
      parser.h
  6. 16 16
      printer.c
  7. 1 2
      printer.h

+ 1 - 1
LICENSE

@@ -336,4 +336,4 @@ This General Public License does not permit incorporating your program into
 proprietary programs.  If your program is a subroutine library, you may
 proprietary programs.  If your program is a subroutine library, you may
 consider it more useful to permit linking proprietary applications with the
 consider it more useful to permit linking proprietary applications with the
 library.  If this is what you want to do, use the GNU Lesser General
 library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
+Public License instead of this License.

+ 0 - 1
Makefile

@@ -40,4 +40,3 @@ install: subtitlesPrinter
 
 
 clean:
 clean:
 	rm -f *.o subtitlesPrinter
 	rm -f *.o subtitlesPrinter
-

+ 0 - 1
events.h

@@ -77,4 +77,3 @@ t_events eventsInit(int initSize);
 int eventsEmpty(t_events events);
 int eventsEmpty(t_events events);
 
 
 #endif
 #endif
-

+ 10 - 10
main.c

@@ -71,7 +71,7 @@ int main(int argc, char **argv)
   char *font = NULL, *font_i = NULL, *font_b = NULL, *font_bi = NULL;
   char *font = NULL, *font_i = NULL, *font_b = NULL, *font_bi = NULL;
   FILE *f = NULL;
   FILE *f = NULL;
   t_state state = S_RUNNING;
   t_state state = S_RUNNING;
-  
+
   // parse arguments
   // parse arguments
   int c;
   int c;
   while((c = getopt (argc, argv, "s:d:t:m:p:g:k:f:i:b:j:h")) != -1)
   while((c = getopt (argc, argv, "s:d:t:m:p:g:k:f:i:b:j:h")) != -1)
@@ -122,30 +122,30 @@ int main(int argc, char **argv)
       default:
       default:
         return 1;
         return 1;
     }
     }
-  
+
   if(optind >= argc)
   if(optind >= argc)
   {
   {
     fprintf(stderr, "Missing filename.\n");
     fprintf(stderr, "Missing filename.\n");
     displayUsage(argv[0]);
     displayUsage(argv[0]);
     return 1;
     return 1;
   }
   }
-  
+
   f = fopen(argv[optind], "r");
   f = fopen(argv[optind], "r");
   if(f == NULL)
   if(f == NULL)
   {
   {
     perror("fopen()");
     perror("fopen()");
     exit(1);
     exit(1);
   }
   }
-  
+
   // open the window
   // open the window
   struct printerEnv penv = printerOpenWindow(font, font_i, font_b, font_bi);
   struct printerEnv penv = printerOpenWindow(font, font_i, font_b, font_bi);
-  
+
   // set attributes
   // set attributes
   penv.margin_bottom = margin_bottom;
   penv.margin_bottom = margin_bottom;
   penv.padding = padding;
   penv.padding = padding;
   penv.gap = gap;
   penv.gap = gap;
   penv.gap2 = gap2;
   penv.gap2 = gap2;
-  
+
   // show a counter before start the clock
   // show a counter before start the clock
   for(i = delay; i > 0; i--)
   for(i = delay; i > 0; i--)
   {
   {
@@ -163,7 +163,7 @@ int main(int argc, char **argv)
   printf("0 !\n");
   printf("0 !\n");
   timeInitialize();
   timeInitialize();
   timeShift(-factor*shift);
   timeShift(-factor*shift);
-  
+
   int id = 0;
   int id = 0;
   struct richText *pausert = richTextParse("<i>paused...</i>\n");
   struct richText *pausert = richTextParse("<i>paused...</i>\n");
   t_events events = eventsInit(8);
   t_events events = eventsInit(8);
@@ -281,12 +281,12 @@ int main(int argc, char **argv)
         }
         }
         break;
         break;
     }
     }
-    
+
     if(eventsEmpty(events))
     if(eventsEmpty(events))
       state = S_STOP;
       state = S_STOP;
     if(state == S_STOP)
     if(state == S_STOP)
       break;
       break;
-    
+
     // sleep until next event
     // sleep until next event
     mytime next_event = eventsNextTime(events);
     mytime next_event = eventsNextTime(events);
     while(1)
     while(1)
@@ -334,7 +334,7 @@ int main(int argc, char **argv)
       }
       }
     }
     }
   }
   }
-  
+
   richTextFree(pausert);
   richTextFree(pausert);
   printerCloseWindow(penv);
   printerCloseWindow(penv);
   fclose(f);
   fclose(f);

+ 0 - 1
parser.h

@@ -35,4 +35,3 @@ struct SubtitleLine
 int next(FILE *f, int expected, struct SubtitleLine *r);
 int next(FILE *f, int expected, struct SubtitleLine *r);
 
 
 #endif
 #endif
-

+ 16 - 16
printer.c

@@ -58,13 +58,13 @@ struct printerEnv printerOpenWindow(char *font, char *font_i, char *font_b,
 
 
   XVisualInfo vinfo;
   XVisualInfo vinfo;
   XMatchVisualInfo(env.d, env.s, 32, TrueColor, &vinfo);
   XMatchVisualInfo(env.d, env.s, 32, TrueColor, &vinfo);
-  
+
   // size of the screen
   // size of the screen
   XWindowAttributes RootAttr;
   XWindowAttributes RootAttr;
   XGetWindowAttributes(env.d, RootWindow(env.d, env.s), &RootAttr);
   XGetWindowAttributes(env.d, RootWindow(env.d, env.s), &RootAttr);
   env.root_width = RootAttr.width;
   env.root_width = RootAttr.width;
   env.root_height = RootAttr.height;
   env.root_height = RootAttr.height;
-  
+
   // set window attributes
   // set window attributes
   XSetWindowAttributes attr;
   XSetWindowAttributes attr;
   attr.colormap = XCreateColormap(env.d, RootWindow(env.d, env.s),
   attr.colormap = XCreateColormap(env.d, RootWindow(env.d, env.s),
@@ -72,7 +72,7 @@ struct printerEnv printerOpenWindow(char *font, char *font_i, char *font_b,
   attr.border_pixel = 0;
   attr.border_pixel = 0;
   attr.background_pixel = 0;
   attr.background_pixel = 0;
   attr.override_redirect = 1; // no window manager border
   attr.override_redirect = 1; // no window manager border
-  
+
   // set colors
   // set colors
   env.color_text = XWhitePixel(env.d, env.s);
   env.color_text = XWhitePixel(env.d, env.s);
   XColor tmp;
   XColor tmp;
@@ -81,11 +81,11 @@ struct printerEnv printerOpenWindow(char *font, char *font_i, char *font_b,
   env.color_background = tmp.pixel;
   env.color_background = tmp.pixel;
   //unsigned short r = 34, g = 34, b = 34, a = 192; // TODO where is the doc ?
   //unsigned short r = 34, g = 34, b = 34, a = 192; // TODO where is the doc ?
   //env.color_background = a*256*256*256 + r*256*256 + g*256 + b;
   //env.color_background = a*256*256*256 + r*256*256 + g*256 + b;
-  
+
   // create the window
   // create the window
   env.w = XCreateWindow(env.d, RootWindow(env.d, env.s), 0, 0, 1, 1, 0, vinfo.depth, InputOutput, vinfo.visual,
   env.w = XCreateWindow(env.d, RootWindow(env.d, env.s), 0, 0, 1, 1, 0, vinfo.depth, InputOutput, vinfo.visual,
     CWColormap | CWBorderPixel | CWBackPixel | CWOverrideRedirect, &attr);
     CWColormap | CWBorderPixel | CWBackPixel | CWOverrideRedirect, &attr);
-  
+
   // setting fonts
   // setting fonts
   char *fontname = (font == NULL) ?
   char *fontname = (font == NULL) ?
     "-bitstream-bitstream charter-medium-r-normal--*-280-100-100-p-*-iso8859-1"
     "-bitstream-bitstream charter-medium-r-normal--*-280-100-100-p-*-iso8859-1"
@@ -107,21 +107,21 @@ struct printerEnv printerOpenWindow(char *font, char *font_i, char *font_b,
   loadFont(&env, &env.fontinfo_bi, (font_bi == NULL) ?
   loadFont(&env, &env.fontinfo_bi, (font_bi == NULL) ?
     "-bitstream-bitstream charter-bold-i-normal--*-280-100-100-p-*-iso8859-1"
     "-bitstream-bitstream charter-bold-i-normal--*-280-100-100-p-*-iso8859-1"
     : font_bi);
     : font_bi);
-  
+
   // create GC
   // create GC
   XGCValues gr_values;
   XGCValues gr_values;
   gr_values.font = env.fontinfo->fid;
   gr_values.font = env.fontinfo->fid;
   gr_values.foreground = XWhitePixel(env.d, env.s);
   gr_values.foreground = XWhitePixel(env.d, env.s);
   gr_values.background = XBlackPixel(env.d, env.s);
   gr_values.background = XBlackPixel(env.d, env.s);
   env.gc = XCreateGC(env.d, env.w, GCFont | GCForeground, &gr_values);
   env.gc = XCreateGC(env.d, env.w, GCFont | GCForeground, &gr_values);
-  
+
   // focused window (for keyboard)
   // focused window (for keyboard)
   int revert;
   int revert;
   XGetInputFocus(env.d, &env.w_focused, &revert);
   XGetInputFocus(env.d, &env.w_focused, &revert);
-  
+
   // event to be listened
   // event to be listened
   XSelectInput(env.d, env.w_focused, KeyPressMask | FocusChangeMask | ExposureMask);
   XSelectInput(env.d, env.w_focused, KeyPressMask | FocusChangeMask | ExposureMask);
-  
+
   // empty message set
   // empty message set
   env.maxsize = 0;
   env.maxsize = 0;
   env.size = 0;
   env.size = 0;
@@ -209,7 +209,7 @@ void printerRender(struct printerEnv *env)
     // remap the window
     // remap the window
     XMapWindow(env->d, env->w);
     XMapWindow(env->d, env->w);
     XClearWindow(env->d, env->w);
     XClearWindow(env->d, env->w);
-    
+
     // resize the window
     // resize the window
     for(i = 0; i < env->size; i++)
     for(i = 0; i < env->size; i++)
     {
     {
@@ -222,7 +222,7 @@ void printerRender(struct printerEnv *env)
     h += 2*env->padding;
     h += 2*env->padding;
     XMoveResizeWindow(env->d, env->w, (env->root_width - w)/2,
     XMoveResizeWindow(env->d, env->w, (env->root_width - w)/2,
       env->root_height - env->margin_bottom - h, w, h);
       env->root_height - env->margin_bottom - h, w, h);
-    
+
     // draw texts
     // draw texts
     for(i = 0; i < env->size; i++)
     for(i = 0; i < env->size; i++)
     {
     {
@@ -303,10 +303,10 @@ void printerShow(struct printerEnv *env, struct richText *rt, int id)
   }
   }
   env->texts[env->size].t = rt;
   env->texts[env->size].t = rt;
   env->texts[env->size].id = id;
   env->texts[env->size].id = id;
-  
+
   // compute w and h
   // compute w and h
   drawText(*env, rt, 0, &x, &h, &w, 0);
   drawText(*env, rt, 0, &x, &h, &w, 0);
-  
+
   // 0 is the bottom
   // 0 is the bottom
   env->texts[env->size].posy = getPos(env, h);
   env->texts[env->size].posy = getPos(env, h);
   env->texts[env->size].height = h;
   env->texts[env->size].height = h;
@@ -329,7 +329,7 @@ t_event manageEvent(struct printerEnv *env)
       if(event.xexpose.count == 0) // last expose event
       if(event.xexpose.count == 0) // last expose event
         printerRender(env);
         printerRender(env);
       break;
       break;
-    
+
     case FocusOut:
     case FocusOut:
       XGetInputFocus(env->d, &env->w_focused, &r);
       XGetInputFocus(env->d, &env->w_focused, &r);
       if(env->w_focused == PointerRoot)
       if(env->w_focused == PointerRoot)
@@ -337,14 +337,14 @@ t_event manageEvent(struct printerEnv *env)
       XSelectInput(env->d, env->w_focused, KeyPressMask|FocusChangeMask);
       XSelectInput(env->d, env->w_focused, KeyPressMask|FocusChangeMask);
       event.type = T_NONE;
       event.type = T_NONE;
       break;
       break;
-    
+
     case KeyPress:
     case KeyPress:
       e.type = T_KEYPRESSED;
       e.type = T_KEYPRESSED;
       e.keyPressed.key = (int)XkbKeycodeToKeysym(env->d, event.xkey.keycode, 0,
       e.keyPressed.key = (int)XkbKeycodeToKeysym(env->d, event.xkey.keycode, 0,
         event.xkey.state & ShiftMask ? 1 : 0);
         event.xkey.state & ShiftMask ? 1 : 0);
       // e.keyPress.time = TODO (event.xkey.time is the number of milliseconds (from uptime ?)
       // e.keyPress.time = TODO (event.xkey.time is the number of milliseconds (from uptime ?)
       break;
       break;
-    
+
     default:
     default:
       e.type = T_NONE;
       e.type = T_NONE;
       break;
       break;

+ 1 - 2
printer.h

@@ -49,7 +49,7 @@ struct printerEnv
   int root_width, root_height;
   int root_width, root_height;
   int margin_bottom;
   int margin_bottom;
   unsigned long color_background, color_text;
   unsigned long color_background, color_text;
-  
+
   struct message *texts;
   struct message *texts;
   int size;
   int size;
   int maxsize;
   int maxsize;
@@ -70,4 +70,3 @@ void printerRender(struct printerEnv *env);
 t_event manageEvent(struct printerEnv *env);
 t_event manageEvent(struct printerEnv *env);
 
 
 #endif
 #endif
-