For example using a config file like the one atached with astyle (http://astyle.sourceforge.net/) that comes installed on codeblocks.

We can easily ensure a style, an excerpt from Fl.cxx,
>>>
note that even on the svn repository actually the requested style isn't respected.
<<<

before astyle:
--------------
...
void Fl::repeat_timeout(double time, Fl_Timeout_Handler cb, void *argp) {
  time += missed_timeout_by; if (time < -.05) time = 0;
  Timeout* t = free_timeout;
  if (t) {
      free_timeout = t->next;
      --free_timeout_count;
  } else {
      t = new Timeout;
  }
  t->time = time;
  t->cb = cb;
  t->arg = argp;
  // insert-sort the new timeout:
  Timeout** p = &first_timeout;
  while (*p && (*p)->time <= time) p = &((*p)->next);
  t->next = *p;
  *p = t;
}
....
/**
  Causes all the windows that need it to be redrawn and graphics forced
  out through the pipes.

  This is what wait() does before looking for events.

  Note: in multi-threaded applications you should only call Fl::flush()
  from the main thread. If a child thread needs to trigger a redraw event,
  it should instead call Fl::awake() to get the main thread to process the
  event queue.
*/
void Fl::flush() {
  if (damage()) {
    damage_ = 0;
    for (Fl_X* i = Fl_X::first; i; i = i->next) {
      if (i->wait_for_expose) {damage_ = 1; continue;}
      Fl_Window* wi = i->w;
      if (!wi->visible_r()) continue;
      if (wi->damage()) {i->flush(); wi->clear_damage();}
      // destroy damage regions for windows that don't use them:
      if (i->region) {XDestroyRegion(i->region); i->region = 0;}
    }
  }
#if defined(USE_X11)
  if (fl_display) XFlush(fl_display);
#elif defined(WIN32)
  GdiFlush();
#elif defined (__APPLE_QUARTZ__)
  if (fl_gc)
    CGContextFlush(fl_gc);
#else
# error unsupported platform
#endif
}
-------------

after astyle:
-------------
...
void Fl::repeat_timeout( double time, Fl_Timeout_Handler cb, void *argp ) {
        time += missed_timeout_by;

        if ( time < -.05 ) {
                time = 0;
        }

        Timeout* t = free_timeout;

        if ( t ) {
                free_timeout = t->next;
                --free_timeout_count;
        } else {
                t = new Timeout;
        }

        t->time = time;
        t->cb = cb;
        t->arg = argp;
        // insert-sort the new timeout:
        Timeout** p = &first_timeout;

        while ( *p && ( *p )->time <= time ) {
                p = &( ( *p )->next );
        }

        t->next = *p;
        *p = t;
}
...
/**
  Causes all the windows that need it to be redrawn and graphics forced
  out through the pipes.

  This is what wait() does before looking for events.

  Note: in multi-threaded applications you should only call Fl::flush()
  from the main thread. If a child thread needs to trigger a redraw event,
  it should instead call Fl::awake() to get the main thread to process the
  event queue.
*/
void Fl::flush() {
        if ( damage() ) {
                damage_ = 0;

                for ( Fl_X* i = Fl_X::first; i; i = i->next ) {
                        if ( i->wait_for_expose ) {
                                damage_ = 1;
                                continue;
                        }

                        Fl_Window* wi = i->w;

                        if ( !wi->visible_r() ) {
                                continue;
                        }

                        if ( wi->damage() ) {
                                i->flush();
                                wi->clear_damage();
                        }

                        // destroy damage regions for windows that don't use 
them:
                        if ( i->region ) {
                                XDestroyRegion( i->region );
                                i->region = 0;
                        }
                }
        }

#if defined(USE_X11)

        if ( fl_display ) {
                XFlush( fl_display );
        }

#elif defined(WIN32)
        GdiFlush();
#elif defined (__APPLE_QUARTZ__)

        if ( fl_gc ) {
                CGContextFlush( fl_gc );
        }

#else
# error unsupported platform
#endif
}
--mode=c

#uses tab every 4 spaces
-T

#Attach brackets to their pre-block statements
-a

#Indent 'switch' blocks so that the 'case X:' statements are indented in the 
switch block. 
#The entire case block is indented.
-S

#Indent multi-line preprocessor definitions ending with a backslash. 
#Should be used with --convert-tabs for proper results. 
#Does a pretty good job, but can not perform miracles in obfuscated 
preprocessor definitions. 
#Without this option the preprocessor statements remain unchanged.
-w

#Indent a maximum of # spaces in a continuous statement, 
#relative to the previous line (e.g. --max-instatement-indent=40). 
# # must be less than  80. If no # is set, the default value of 40 will be 
used. 
#A maximum of less than two indent lengths will be ignored.
-M

#Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...).
-f

#Insert space padding around operators. 
#Operators inside block parens [] are not padded. 
#Any end of line comments will remain in the original column, if possible. 
#Note that there is no option to unpad. Once padded, they stay padded.
-p

#Insert space padding around parenthesis on the inside  only. 
#Any end of line comments will remain in the original column, if possible. 
#This can be used with unpad-paren  below to remove unwanted spaces.
-D

#Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...). 
#Any end of line comments will remain in the original column, if possible. 
#This can be used with unpad-paren to remove unwanted spaces.
-H

#Add brackets to unbracketed one line conditional statements  (e.g. 'if', 
'for', 'while'...). 
#The statement must be on a single line. 
#The brackets will be added according to the currently requested predefined 
style or bracket type. 
#If no style or bracket type is requested the brackets will be attached. 
#If --add-one-line-brackets is also used the result will be one line brackets.
-j

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to