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
 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
-Public License instead of this License.
+Public License instead of this License.

+ 0 - 1
Makefile

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

+ 0 - 1
events.h

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

+ 0 - 1
parser.h

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

+ 16 - 16
printer.c

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

+ 1 - 2
printer.h

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