freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 0f25f3e: Prepare for scripting.


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master 0f25f3e: Prepare for scripting.
Date: Tue, 21 May 2019 23:02:57 -0400 (EDT)

branch: master
commit 0f25f3ec6742228561d14f1c321606d8fbf20acd
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    Prepare for scripting.
    
    * src/{ftview.c,ftstring.c,ftgrid.c,ftmulti.c,ftgamma.c}
    (main, Process_Event): Consolidate event handling.
---
 ChangeLog      |  7 +++++++
 src/ftgamma.c  | 18 ++++++++++--------
 src/ftgrid.c   | 17 ++++++++---------
 src/ftmulti.c  | 14 +++++++-------
 src/ftstring.c | 17 ++++++++---------
 src/ftview.c   | 31 +++++++++++++++----------------
 6 files changed, 55 insertions(+), 49 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2c7ee75..5dc7bd0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-05-21  Alexei Podtelezhnikov  <address@hidden>
+
+       Prepare for scripting.
+
+       * src/{ftview.c,ftstring.c,ftgrid.c,ftmulti.c,ftgamma.c} 
+       (main, Process_Event): Consolidate event handling.
+
 2019-04-28  Werner Lemberg  <address@hidden>
 
        [ftmulti] Add axis grouping.
diff --git a/src/ftgamma.c b/src/ftgamma.c
index 2d18f6a..54345ac 100644
--- a/src/ftgamma.c
+++ b/src/ftgamma.c
@@ -321,11 +321,15 @@
 
 
   static int
-  Process_Event( grEvent*  event )
+  Process_Event( void )
   {
-    int  ret = 0;
+    grEvent  event;
+    int      ret = 0;
 
-    switch ( event->key )
+
+    grListenSurface( display->surface, 0, &event );
+
+    switch ( event.key )
     {
     case grKeyEsc:
     case grKEY( 'q' ):
@@ -362,9 +366,8 @@
   int
   main( void )
   {
-    grEvent          event;
-    char             buf[4];
-    int              i;
+    char  buf[4];
+    int   i;
 
     display = FTDemo_Display_New( DIM );
     if ( !display )
@@ -417,8 +420,7 @@
                          "Gamma", display->fore_color );
 
       grRefreshSurface( display->surface );
-      grListenSurface( display->surface, 0, &event );
-    } while ( Process_Event( &event ) == 0 );
+    } while ( Process_Event() == 0 );
 
     FTDemo_Display_Done( display );
 
diff --git a/src/ftgrid.c b/src/ftgrid.c
index a94e9d9..e472448 100644
--- a/src/ftgrid.c
+++ b/src/ftgrid.c
@@ -1374,14 +1374,17 @@
 
 
   static int
-  Process_Event( grEvent*  event )
+  Process_Event( void )
   {
-    int  ret = 0;
+    grEvent  event;
+    int      ret = 0;
 
 
+    grListenSurface( display->surface, 0, &event );
+
     status.header = NULL;
 
-    switch ( event->key )
+    switch ( event.key )
     {
     case grKeyEsc:
     case grKEY( 'q' ):
@@ -1851,7 +1854,6 @@
   main( int    argc,
         char*  argv[] )
   {
-    grEvent       event;
     int           n;
     unsigned int  dflt_tt_interpreter_version;
     unsigned int  versions[3] = { TT_INTERPRETER_VERSION_35,
@@ -1929,7 +1931,7 @@
 
     grid_status_rescale_initial( &status, handle );
 
-    for ( ;; )
+    do
     {
       FTDemo_Display_Clear( display );
 
@@ -1941,10 +1943,7 @@
 
       write_header( 0 );
 
-      grListenSurface( display->surface, 0, &event );
-      if ( Process_Event( &event ) )
-        break;
-    }
+    } while ( !Process_Event() );
 
     printf( "Execution completed successfully.\n" );
 
diff --git a/src/ftmulti.c b/src/ftmulti.c
index cc8773e..6d3d790 100644
--- a/src/ftmulti.c
+++ b/src/ftmulti.c
@@ -595,13 +595,16 @@
 
 
   static int
-  Process_Event( grEvent*  event )
+  Process_Event( void )
   {
+    grEvent       event;
     int           i;
     unsigned int  axis;
 
 
-    switch ( event->key )
+    grListenSurface( surface, 0, &event );
+
+    switch ( event.key )
     {
     case grKeyEsc:            /* ESC or q */
     case grKEY( 'q' ):
@@ -635,7 +638,7 @@
 
     case grKEY( 'n' ):
     case grKEY( 'p' ):
-      return (int)event->key;
+      return (int)event.key;
 
     case grKEY( 'h' ):
       hinted     = !hinted;
@@ -916,8 +919,6 @@
 
     unsigned int  n;
 
-    grEvent  event;
-
     unsigned int  dflt_tt_interpreter_version;
     unsigned int  versions[3] = { TT_INTERPRETER_VERSION_35,
                                   TT_INTERPRETER_VERSION_38,
@@ -1260,8 +1261,7 @@
       grWriteCellString( &bit, 0, 8, Header, fore_color );
       grRefreshSurface( surface );
 
-      grListenSurface( surface, 0, &event );
-      if ( !( key = Process_Event( &event ) ) )
+      if ( !( key = Process_Event() ) )
         goto End;
 
       if ( key == 'n' )
diff --git a/src/ftstring.c b/src/ftstring.c
index 06d8f46..8933227 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -437,21 +437,24 @@
 
 
   static int
-  Process_Event( grEvent*  event )
+  Process_Event( void )
   {
+    grEvent                 event;
     FTDemo_String_Context*  sc  = &status.sc;
     int                     ret = 0;
 
 
-    if ( event->key >= '1' && event->key < '1' + N_RENDER_MODES )
+    grListenSurface( display->surface, 0, &event );
+
+    if ( event.key >= '1' && event.key < '1' + N_RENDER_MODES )
     {
-      status.render_mode = (int)( event->key - '1' );
+      status.render_mode = (int)( event.key - '1' );
       event_render_mode_change( 0 );
 
       return ret;
     }
 
-    switch ( event->key )
+    switch ( event.key )
     {
     case grKeyEsc:
     case grKEY( 'q' ):
@@ -863,9 +866,6 @@
   main( int     argc,
         char**  argv )
   {
-    grEvent  event;
-
-
     /* Initialize engine */
     handle = FTDemo_New();
 
@@ -943,8 +943,7 @@
       write_header( error );
 
       status.header = 0;
-      grListenSurface( display->surface, 0, &event );
-    } while ( !Process_Event( &event ) );
+    } while ( !Process_Event() );
 
     printf( "Execution completed successfully.\n" );
 
diff --git a/src/ftview.c b/src/ftview.c
index b8e8a53..cee95ce 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -1117,27 +1117,29 @@
 
 
   static int
-  Process_Event( grEvent*  event )
+  Process_Event( void )
   {
-    int  ret = 0;
+    grEvent  event;
+    int      ret = 0;
 
 
+    grListenSurface( display->surface, 0, &event );
     status.update = 0;
 
-    if ( status.render_mode == (int)( event->key - '1' ) )
+    if ( status.render_mode == (int)( event.key - '1' ) )
       return ret;
-    if ( event->key >= '1' && event->key < '1' + N_RENDER_MODES )
+    if ( event.key >= '1' && event.key < '1' + N_RENDER_MODES )
     {
-      status.render_mode = (int)( event->key - '1' );
+      status.render_mode = (int)( event.key - '1' );
       event_render_mode_change( 0 );
       status.update = 1;
       return ret;
     }
 
-    if ( event->key >= 'A'             &&
-         event->key < 'A' + N_LCD_IDXS )
+    if ( event.key >= 'A'             &&
+         event.key < 'A' + N_LCD_IDXS )
     {
-      int  lcd_idx = (int)( event->key - 'A' );
+      int  lcd_idx = (int)( event.key - 'A' );
 
 
       if ( status.lcd_idx == lcd_idx )
@@ -1150,7 +1152,7 @@
       return ret;
     }
 
-    switch ( event->key )
+    switch ( event.key )
     {
     case grKeyEsc:
     case grKEY( 'q' ):
@@ -1256,7 +1258,7 @@
     case grKEY( 'k' ):
       status.lcd_idx =
         ( status.lcd_idx                          +
-          ( event->key == grKEY( 'l' ) ? 1 : -1 ) +
+          ( event.key == grKEY( 'l' ) ? 1 : -1 ) +
           N_LCD_IDXS                              ) % N_LCD_IDXS;
 
       handle->lcd_mode = lcd_modes[status.lcd_idx];
@@ -1387,7 +1389,7 @@
          handle->lcd_mode < LCD_MODE_RGB                 )
       return ret;
 
-    switch ( event->key )
+    switch ( event.key )
     {
     case grKEY( 'L' ):
       FTC_Manager_RemoveFaceID( handle->cache_manager,
@@ -1935,7 +1937,6 @@
   main( int    argc,
         char*  argv[] )
   {
-    grEvent  event;
     unsigned int  dflt_tt_interpreter_version;
     int           i;
     unsigned int  versions[3] = { TT_INTERPRETER_VERSION_35,
@@ -2009,7 +2010,7 @@
     do
     {
       if ( !status.update )
-        goto Listen;
+        continue;
 
       FTDemo_Display_Clear( display );
 
@@ -2041,9 +2042,7 @@
 
       write_header( error );
 
-    Listen:
-      grListenSurface( display->surface, 0, &event );
-    } while ( Process_Event( &event ) == 0 );
+    } while ( Process_Event() == 0 );
 
     printf( "Execution completed successfully.\n" );
     printf( "Fails = %d\n", status.num_fails );



reply via email to

[Prev in Thread] Current Thread [Next in Thread]