File: input_callback.C

package info (click to toggle)
peruser 4b33-6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,952 kB
  • ctags: 1,064
  • sloc: cpp: 22,367; perl: 2,733; makefile: 345; sh: 335
file content (31 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <unistd.h>

#include "nptext.h"

void input_callback( gpointer data, gint fd, GdkInputCondition condition )
{
   NP_Text *text = ( NP_Text *)data;

   if ( text->input == NULL )
   {
      text->input = fdopen( STDIN_FILENO, "r" );
      if ( text->input == NULL )
      {
         perror( "fdopen" );
         exit( 1 );
      }

      text->input_id =
         gdk_input_add( STDIN_FILENO, GDK_INPUT_READ, input_callback, text );
   }
   
   if ( text->update() )
   {
      fclose( text->input );
      text->input = NULL;
      gdk_input_remove( text->input_id );
      text->input_id = -1;
   }
   
   return;
}