Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
synctex_parser.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct _synctex_nodesynctex_node_t
 
typedef struct __synctex_scanner_t _synctex_scanner_t
 
typedef _synctex_scanner_tsynctex_scanner_t
 
typedef unsigned int synctex_charindex_t
 
typedef struct __synctex_updater_t _synctex_updater_t
 
typedef _synctex_updater_tsynctex_updater_t
 

Enumerations

enum  synctex_node_type_t {
  synctex_node_type_error = 0, synctex_node_type_input, synctex_node_type_sheet, synctex_node_type_vbox,
  synctex_node_type_void_vbox, synctex_node_type_hbox, synctex_node_type_void_hbox, synctex_node_type_kern,
  synctex_node_type_glue, synctex_node_type_math, synctex_node_type_boundary, synctex_node_number_of_types
}
 

Functions

synctex_scanner_t synctex_scanner_new_with_output_file (const char *output, const char *build_directory, int parse)
 
void synctex_scanner_free (synctex_scanner_t scanner)
 
synctex_scanner_t synctex_scanner_parse (synctex_scanner_t scanner)
 
int synctex_display_query (synctex_scanner_t scanner, const char *name, int line, int column)
 
int synctex_edit_query (synctex_scanner_t scanner, int page, float h, float v)
 
synctex_node_t synctex_next_result (synctex_scanner_t scanner)
 
void synctex_scanner_display (synctex_scanner_t scanner)
 
int synctex_scanner_x_offset (synctex_scanner_t scanner)
 
int synctex_scanner_y_offset (synctex_scanner_t scanner)
 
float synctex_scanner_magnification (synctex_scanner_t scanner)
 
const char * synctex_scanner_get_name (synctex_scanner_t scanner, int tag)
 
int synctex_scanner_get_tag (synctex_scanner_t scanner, const char *name)
 
synctex_node_t synctex_scanner_input (synctex_scanner_t scanner)
 
const char * synctex_scanner_get_output (synctex_scanner_t scanner)
 
const char * synctex_scanner_get_synctex (synctex_scanner_t scanner)
 
synctex_node_t synctex_node_parent (synctex_node_t node)
 
synctex_node_t synctex_node_sheet (synctex_node_t node)
 
synctex_node_t synctex_node_child (synctex_node_t node)
 
synctex_node_t synctex_node_sibling (synctex_node_t node)
 
synctex_node_t synctex_node_next (synctex_node_t node)
 
synctex_node_t synctex_sheet (synctex_scanner_t scanner, int page)
 
synctex_node_t synctex_sheet_content (synctex_scanner_t scanner, int page)
 
synctex_node_type_t synctex_node_type (synctex_node_t node)
 
const char * synctex_node_isa (synctex_node_t node)
 
void synctex_node_log (synctex_node_t node)
 
void synctex_node_display (synctex_node_t node)
 
synctex_charindex_t synctex_node_charindex (synctex_node_t node)
 
int synctex_node_tag (synctex_node_t node)
 
int synctex_node_line (synctex_node_t node)
 
int synctex_node_column (synctex_node_t node)
 
int synctex_node_mean_line (synctex_node_t node)
 
int synctex_node_child_count (synctex_node_t node)
 
int synctex_node_page (synctex_node_t node)
 
int synctex_node_h (synctex_node_t node)
 
int synctex_node_v (synctex_node_t node)
 
int synctex_node_width (synctex_node_t node)
 
int synctex_node_box_h (synctex_node_t node)
 
int synctex_node_box_v (synctex_node_t node)
 
int synctex_node_box_width (synctex_node_t node)
 
int synctex_node_box_height (synctex_node_t node)
 
int synctex_node_box_depth (synctex_node_t node)
 
float synctex_node_visible_h (synctex_node_t node)
 
float synctex_node_visible_v (synctex_node_t node)
 
float synctex_node_visible_width (synctex_node_t node)
 
float synctex_node_box_visible_h (synctex_node_t node)
 
float synctex_node_box_visible_v (synctex_node_t node)
 
float synctex_node_box_visible_width (synctex_node_t node)
 
float synctex_node_box_visible_height (synctex_node_t node)
 
float synctex_node_box_visible_depth (synctex_node_t node)
 
synctex_updater_t synctex_updater_new_with_output_file (const char *output, const char *directory)
 
void synctex_updater_append_magnification (synctex_updater_t updater, char *magnification)
 
void synctex_updater_append_x_offset (synctex_updater_t updater, char *x_offset)
 
void synctex_updater_append_y_offset (synctex_updater_t updater, char *y_offset)
 
void synctex_updater_free (synctex_updater_t updater)
 

Typedef Documentation

Definition at line 73 of file synctex_parser.h.

Definition at line 339 of file synctex_parser.h.

typedef unsigned int synctex_charindex_t

Definition at line 270 of file synctex_parser.h.

typedef struct _synctex_node* synctex_node_t

Definition at line 64 of file synctex_parser.h.

Definition at line 74 of file synctex_parser.h.

Definition at line 340 of file synctex_parser.h.

Enumeration Type Documentation

Enumerator
synctex_node_type_error 
synctex_node_type_input 
synctex_node_type_sheet 
synctex_node_type_vbox 
synctex_node_type_void_vbox 
synctex_node_type_hbox 
synctex_node_type_void_hbox 
synctex_node_type_kern 
synctex_node_type_glue 
synctex_node_type_math 
synctex_node_type_boundary 
synctex_node_number_of_types 

Definition at line 243 of file synctex_parser.h.

Function Documentation

int synctex_display_query ( synctex_scanner_t  scanner,
const char *  name,
int  line,
int  column 
)

Definition at line 3441 of file synctex_parser.c.

3441  {
3442 # ifdef __DARWIN_UNIX03
3443 # pragma unused(column)
3444 # endif
3445  int tag = synctex_scanner_get_tag(scanner,name);
3446  size_t size = 0;
3447  int friend_index = 0;
3448  int max_line = 0;
3449  synctex_node_t node = NULL;
3450  if (tag == 0) {
3451  printf("SyncTeX Warning: No tag for %s\n",name);
3452  return -1;
3453  }
3454  free(SYNCTEX_START);
3456  max_line = line < INT_MAX-scanner->number_of_lists ? line+scanner->number_of_lists:INT_MAX;
3457  while(line<max_line) {
3458  /* This loop will only be performed once for advanced viewers */
3459  friend_index = (tag+line)%(scanner->number_of_lists);
3460  if ((node = (scanner->lists_of_friends)[friend_index])) {
3461  do {
3463  && (tag == SYNCTEX_TAG(node))
3464  && (line == SYNCTEX_LINE(node))) {
3465  if (SYNCTEX_CUR == SYNCTEX_END) {
3466  size += 16;
3467  SYNCTEX_END = realloc(SYNCTEX_START,size*sizeof(synctex_node_t *));
3469  SYNCTEX_START = SYNCTEX_END;
3470  SYNCTEX_END = SYNCTEX_START + size*sizeof(synctex_node_t *);
3471  }
3472  *(synctex_node_t *)SYNCTEX_CUR = node;
3473  SYNCTEX_CUR += sizeof(synctex_node_t);
3474  }
3475  } while ((node = SYNCTEX_FRIEND(node)));
3476  if (SYNCTEX_START == NULL) {
3477  /* We did not find any matching boundary, retry with glue or kern */
3478  node = (scanner->lists_of_friends)[friend_index];/* no need to test it again, already done */
3479  do {
3481  && (tag == SYNCTEX_TAG(node))
3482  && (line == SYNCTEX_LINE(node))) {
3483  if (SYNCTEX_CUR == SYNCTEX_END) {
3484  size += 16;
3485  SYNCTEX_END = realloc(SYNCTEX_START,size*sizeof(synctex_node_t *));
3487  SYNCTEX_START = SYNCTEX_END;
3488  SYNCTEX_END = SYNCTEX_START + size*sizeof(synctex_node_t *);
3489  }
3490  *(synctex_node_t *)SYNCTEX_CUR = node;
3491  SYNCTEX_CUR += sizeof(synctex_node_t);
3492  }
3493  } while ((node = SYNCTEX_FRIEND(node)));
3494  if (SYNCTEX_START == NULL) {
3495  /* We did not find any matching glue or kern, retry with boxes */
3496  node = (scanner->lists_of_friends)[friend_index];/* no need to test it again, already done */
3497  do {
3498  if ((tag == SYNCTEX_TAG(node))
3499  && (line == SYNCTEX_LINE(node))) {
3500  if (SYNCTEX_CUR == SYNCTEX_END) {
3501  size += 16;
3502  SYNCTEX_END = realloc(SYNCTEX_START,size*sizeof(synctex_node_t *));
3504  SYNCTEX_START = SYNCTEX_END;
3505  SYNCTEX_END = SYNCTEX_START + size*sizeof(synctex_node_t *);
3506  }
3507  *(synctex_node_t *)SYNCTEX_CUR = node;
3508  SYNCTEX_CUR += sizeof(synctex_node_t);
3509  }
3510  } while((node = SYNCTEX_FRIEND(node)));
3511  }
3512  }
3514  /* Now reverse the order to have nodes in display order, and then keep just a few nodes.
3515  * Order first the best node. */
3516  if ((SYNCTEX_START) && (SYNCTEX_END)) {
3517  unsigned int best_match = -1;
3518  unsigned int next_match = -1;
3519  unsigned int best_weight = 0;
3520  synctex_node_t * best_ref = NULL;
3521  synctex_node_t * start_ref = (synctex_node_t *)SYNCTEX_START;
3522  synctex_node_t * end_ref = (synctex_node_t *)SYNCTEX_END;
3523  --end_ref;
3524  while (start_ref < end_ref) {
3525  node = *start_ref;
3526  *start_ref = *end_ref;
3527  *end_ref = node;
3528  ++start_ref;
3529  --end_ref;
3530  }
3531  /* Now reorder the nodes to put first the one which fits best.
3532  * The idea is to walk along the list of nodes and pick up the first one
3533  * which line info is exactly the mean line of its parent, or at least very close.
3534  * Then we choose among all such node the one with the maximum number of child nodes.
3535  * Then we switch with the first node.
3536  */
3537  best_ref = start_ref = (synctex_node_t *)SYNCTEX_START;
3538  node = *start_ref;
3539  best_match = abs(SYNCTEX_LINE(node)-SYNCTEX_MEAN_LINE(SYNCTEX_PARENT(node)));
3540  end_ref = (synctex_node_t *)SYNCTEX_END;
3541  while (++start_ref<end_ref) {
3542  synctex_node_t parent = NULL;
3543  node = *start_ref;
3544  parent = SYNCTEX_PARENT(node);
3545  next_match = abs(SYNCTEX_LINE(node)-SYNCTEX_MEAN_LINE(parent));
3546  if (next_match < best_match
3547  || (next_match == best_match && SYNCTEX_NODE_WEIGHT(parent)>best_weight)) {
3548  best_match = next_match;
3549  best_ref = start_ref;
3550  best_weight = SYNCTEX_NODE_WEIGHT(parent);
3551  }
3552  }
3553  node = *best_ref;
3554  *best_ref = *(synctex_node_t *)SYNCTEX_START;
3555  *(synctex_node_t *)SYNCTEX_START = node;
3556  /* Basically, we keep the first node for each parent.
3557  * More precisely, we keep only nodes that are not children of
3558  * their predecessor's parent. */
3559  start_ref = (synctex_node_t *)SYNCTEX_START;
3560  end_ref = (synctex_node_t *)SYNCTEX_START;
3561 next_end:
3562  end_ref += 1; /* we allways have start_ref<= end_ref*/
3563  if (end_ref < (synctex_node_t *)SYNCTEX_END) {
3564  node = *end_ref;
3565  while ((node = SYNCTEX_PARENT(node))) {
3566  if (SYNCTEX_PARENT(*start_ref) == node) {
3567  goto next_end;
3568  }
3569  }
3570  start_ref += 1;
3571  *start_ref = *end_ref;
3572  goto next_end;
3573  }
3574  start_ref += 1;
3575  SYNCTEX_END = (char *)start_ref;
3576  SYNCTEX_CUR = NULL;// added on behalf of Jose Alliste
3577  return (SYNCTEX_END-SYNCTEX_START)/sizeof(synctex_node_t);// added on behalf Jan Sundermeyer
3578  }
3579  SYNCTEX_CUR = NULL;
3580  // return (SYNCTEX_END-SYNCTEX_START)/sizeof(synctex_node_t); removed on behalf Jan Sundermeyer
3581  }
3582 # if defined(__SYNCTEX_STRONG_DISPLAY_QUERY__)
3583  break;
3584 # else
3585  ++line;
3586 # endif
3587  }
3588  return 0;
3589 }

+ Here is the caller graph for this function:

int synctex_edit_query ( synctex_scanner_t  scanner,
int  page,
float  h,
float  v 
)

Definition at line 3657 of file synctex_parser.c.

3657  {
3658  synctex_node_t sheet = NULL;
3659  synctex_node_t node = NULL; /* placeholder */
3660  synctex_node_t other_node = NULL; /* placeholder */
3661  synctex_point_t hitPoint = {0,0}; /* placeholder */
3662  synctex_node_set_t bestNodes = {NULL,NULL}; /* holds the best node */
3663  synctex_distances_t bestDistances = {INT_MAX,INT_MAX}; /* holds the best distances for the best node */
3664  synctex_node_t bestContainer = NULL; /* placeholder */
3665  if (NULL == (scanner = synctex_scanner_parse(scanner)) || 0 >= scanner->unit) {/* scanner->unit must be >0 */
3666  return 0;
3667  }
3668  /* Convert the given point to scanner integer coordinates */
3669  hitPoint.h = (h-scanner->x_offset)/scanner->unit;
3670  hitPoint.v = (v-scanner->y_offset)/scanner->unit;
3671  /* We will store in the scanner's buffer the result of the query. */
3672  free(SYNCTEX_START);
3674  /* Find the proper sheet */
3675  sheet = scanner->sheet;
3676  while((sheet) && SYNCTEX_PAGE(sheet) != page) {
3677  sheet = SYNCTEX_SIBLING(sheet);
3678  }
3679  if (NULL == sheet) {
3680  return -1;
3681  }
3682  /* Now sheet points to the sheet node with proper page number */
3683  /* Here is how we work:
3684  * At first we do not consider the visible box dimensions. This will cover the most frequent cases.
3685  * Then we try with the visible box dimensions.
3686  * We try to find a non void box containing the hit point.
3687  * We browse all the horizontal boxes until we find one containing the hit point. */
3688  if ((node = SYNCTEX_NEXT_hbox(sheet))) {
3689  do {
3690  if (_synctex_point_in_box(hitPoint,node,synctex_YES)) {
3691  /* Maybe the hitPoint belongs to a contained vertical box. */
3692 end:
3693  /* This trick is for catching overlapping boxes */
3694  if ((other_node = SYNCTEX_NEXT_hbox(node))) {
3695  do {
3696  if (_synctex_point_in_box(hitPoint,other_node,synctex_YES)) {
3697  node = _synctex_smallest_container(other_node,node);
3698  }
3699  } while((other_node = SYNCTEX_NEXT_hbox(other_node)));
3700  }
3701  /* node is the smallest horizontal box that contains hitPoint. */
3702  if ((bestContainer = _synctex_eq_deepest_container(hitPoint,node,synctex_YES))) {
3703  node = bestContainer;
3704  }
3705  _synctex_eq_get_closest_children_in_box(hitPoint,node,&bestNodes,&bestDistances,synctex_YES);
3706  if (bestNodes.right && bestNodes.left) {
3707  if ((SYNCTEX_TAG(bestNodes.right)!=SYNCTEX_TAG(bestNodes.left))
3708  || (SYNCTEX_LINE(bestNodes.right)!=SYNCTEX_LINE(bestNodes.left))
3709  || (SYNCTEX_COLUMN(bestNodes.right)!=SYNCTEX_COLUMN(bestNodes.left))) {
3710  if ((SYNCTEX_START = malloc(2*sizeof(synctex_node_t)))) {
3711  if (bestDistances.left>bestDistances.right) {
3712  ((synctex_node_t *)SYNCTEX_START)[0] = bestNodes.right;
3713  ((synctex_node_t *)SYNCTEX_START)[1] = bestNodes.left;
3714  } else {
3715  ((synctex_node_t *)SYNCTEX_START)[0] = bestNodes.left;
3716  ((synctex_node_t *)SYNCTEX_START)[1] = bestNodes.right;
3717  }
3719  SYNCTEX_CUR = NULL;
3720  return (SYNCTEX_END-SYNCTEX_START)/sizeof(synctex_node_t);
3721  }
3722  return SYNCTEX_STATUS_ERROR;
3723  }
3724  /* both nodes have the same input coordinates
3725  * We choose the one closest to the hit point */
3726  if (bestDistances.left>bestDistances.right) {
3727  bestNodes.left = bestNodes.right;
3728  }
3729  bestNodes.right = NULL;
3730  } else if (bestNodes.right) {
3731  bestNodes.left = bestNodes.right;
3732  } else if (!bestNodes.left){
3733  bestNodes.left = node;
3734  }
3735  if ((SYNCTEX_START = malloc(sizeof(synctex_node_t)))) {
3736  * (synctex_node_t *)SYNCTEX_START = bestNodes.left;
3738  SYNCTEX_CUR = NULL;
3739  return (SYNCTEX_END-SYNCTEX_START)/sizeof(synctex_node_t);
3740  }
3741  return SYNCTEX_STATUS_ERROR;
3742  }
3743  } while ((node = SYNCTEX_NEXT_hbox(node)));
3744  /* All the horizontal boxes have been tested,
3745  * None of them contains the hit point.
3746  */
3747  }
3748  /* We are not lucky */
3749  if ((node = SYNCTEX_CHILD(sheet))) {
3750  goto end;
3751  }
3752  return 0;
3753 }

+ Here is the caller graph for this function:

synctex_node_t synctex_next_result ( synctex_scanner_t  scanner)

Definition at line 3591 of file synctex_parser.c.

3591  {
3592  if (NULL == SYNCTEX_CUR) {
3594  } else {
3595  SYNCTEX_CUR+=sizeof(synctex_node_t);
3596  }
3597  if (SYNCTEX_CUR<SYNCTEX_END) {
3598  return *(synctex_node_t*)SYNCTEX_CUR;
3599  } else {
3600  return NULL;
3601  }
3602 }

+ Here is the caller graph for this function:

int synctex_node_box_depth ( synctex_node_t  node)

Definition at line 3245 of file synctex_parser.c.

3245  {
3246  if (!node) {
3247  return 0;
3248  }
3249  if (SYNCTEX_IS_BOX(node)) {
3250 result:
3251  return SYNCTEX_DEPTH(node);
3252  }
3253  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3254  goto result;
3255  }
3256  return 0;
3257 }
int synctex_node_box_h ( synctex_node_t  node)

Definition at line 3193 of file synctex_parser.c.

3193  {
3194  if (!node) {
3195  return 0;
3196  }
3197  if (SYNCTEX_IS_BOX(node)) {
3198 result:
3199  return SYNCTEX_HORIZ(node);
3200  }
3201  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3202  goto result;
3203  }
3204  return 0;
3205 }
int synctex_node_box_height ( synctex_node_t  node)

Definition at line 3232 of file synctex_parser.c.

3232  {
3233  if (!node) {
3234  return 0;
3235  }
3236  if (SYNCTEX_IS_BOX(node)) {
3237 result:
3238  return SYNCTEX_HEIGHT(node);
3239  }
3240  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3241  goto result;
3242  }
3243  return 0;
3244 }
int synctex_node_box_v ( synctex_node_t  node)

Definition at line 3206 of file synctex_parser.c.

3206  {
3207  if (!node) {
3208  return 0;
3209  }
3210  if (SYNCTEX_IS_BOX(node)) {
3211 result:
3212  return SYNCTEX_VERT(node);
3213  }
3214  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3215  goto result;
3216  }
3217  return 0;
3218 }
float synctex_node_box_visible_depth ( synctex_node_t  node)

Definition at line 3352 of file synctex_parser.c.

3352  {
3353  if (!node) {
3354  return 0;
3355  }
3356  switch(node->class->type) {
3360  return SYNCTEX_DEPTH(node)*node->class->scanner->unit;
3362 result:
3363  return SYNCTEX_DEPTH_V(node)*node->class->scanner->unit;
3364  }
3365  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3366  goto result;
3367  }
3368  return 0;
3369 }

+ Here is the caller graph for this function:

float synctex_node_box_visible_h ( synctex_node_t  node)

Definition at line 3280 of file synctex_parser.c.

3280  {
3281  if (!node) {
3282  return 0;
3283  }
3284  switch(node->class->type) {
3288  return SYNCTEX_HORIZ(node)*node->class->scanner->unit+node->class->scanner->x_offset;
3290 result:
3291  return SYNCTEX_HORIZ_V(node)*node->class->scanner->unit+node->class->scanner->x_offset;
3292  }
3293  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3294  goto result;
3295  }
3296  return 0;
3297 }

+ Here is the caller graph for this function:

float synctex_node_box_visible_height ( synctex_node_t  node)

Definition at line 3334 of file synctex_parser.c.

3334  {
3335  if (!node) {
3336  return 0;
3337  }
3338  switch(node->class->type) {
3342  return SYNCTEX_HEIGHT(node)*node->class->scanner->unit;
3344 result:
3345  return SYNCTEX_HEIGHT_V(node)*node->class->scanner->unit;
3346  }
3347  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3348  goto result;
3349  }
3350  return 0;
3351 }

+ Here is the caller graph for this function:

float synctex_node_box_visible_v ( synctex_node_t  node)

Definition at line 3298 of file synctex_parser.c.

3298  {
3299  if (!node) {
3300  return 0;
3301  }
3302  switch(node->class->type) {
3306  return SYNCTEX_VERT(node)*node->class->scanner->unit+node->class->scanner->y_offset;
3308 result:
3309  return SYNCTEX_VERT_V(node)*node->class->scanner->unit+node->class->scanner->y_offset;
3310  }
3311  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3312  goto result;
3313  }
3314  return 0;
3315 }

+ Here is the caller graph for this function:

float synctex_node_box_visible_width ( synctex_node_t  node)

Definition at line 3316 of file synctex_parser.c.

3316  {
3317  if (!node) {
3318  return 0;
3319  }
3320  switch(node->class->type) {
3324  return SYNCTEX_WIDTH(node)*node->class->scanner->unit;
3326 result:
3327  return SYNCTEX_WIDTH_V(node)*node->class->scanner->unit;
3328  }
3329  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3330  goto result;
3331  }
3332  return 0;
3333 }

+ Here is the caller graph for this function:

int synctex_node_box_width ( synctex_node_t  node)

Definition at line 3219 of file synctex_parser.c.

3219  {
3220  if (!node) {
3221  return 0;
3222  }
3223  if (SYNCTEX_IS_BOX(node)) {
3224 result:
3225  return SYNCTEX_WIDTH(node);
3226  }
3227  if ((node = SYNCTEX_PARENT(node)) && (node->class->type != synctex_node_type_sheet)) {
3228  goto result;
3229  }
3230  return 0;
3231 }
synctex_charindex_t synctex_node_charindex ( synctex_node_t  node)

Definition at line 3390 of file synctex_parser.c.

3390  {
3391  return node?SYNCTEX_CHARINDEX(node):0;
3392 }
synctex_node_t synctex_node_child ( synctex_node_t  node)

Definition at line 757 of file synctex_parser.c.

758 {
759  return SYNCTEX_CHILD(node);
760 }
int synctex_node_child_count ( synctex_node_t  node)

Definition at line 3402 of file synctex_parser.c.

3402  {
3403  return node?(node->class->type==synctex_node_type_hbox?SYNCTEX_NODE_WEIGHT(node):0):-1;
3404 }
int synctex_node_column ( synctex_node_t  node)

Definition at line 3405 of file synctex_parser.c.

3405  {
3406 # ifdef __DARWIN_UNIX03
3407 # pragma unused(node)
3408 # endif
3409  return -1;
3410 }

+ Here is the caller graph for this function:

void synctex_node_display ( synctex_node_t  node)

Definition at line 937 of file synctex_parser.c.

937  {
938  SYNCTEX_DISPLAY(node);
939 }
int synctex_node_h ( synctex_node_t  node)

Definition at line 3175 of file synctex_parser.c.

3175  {
3176  if (!node) {
3177  return 0;
3178  }
3179  return SYNCTEX_HORIZ(node);
3180 }
const char* synctex_node_isa ( synctex_node_t  node)

Definition at line 795 of file synctex_parser.c.

795  {
796 static const char * isa[synctex_node_number_of_types] =
797  {"Not a node","input","sheet","vbox","void vbox","hbox","void hbox","kern","glue","math","boundary"};
798  return isa[synctex_node_type(node)];
799 }

+ Here is the caller graph for this function:

int synctex_node_line ( synctex_node_t  node)

Definition at line 3396 of file synctex_parser.c.

3396  {
3397  return node?SYNCTEX_LINE(node):-1;
3398 }

+ Here is the caller graph for this function:

void synctex_node_log ( synctex_node_t  node)

Definition at line 809 of file synctex_parser.c.

809  {
810  SYNCTEX_LOG(node);
811 }

+ Here is the caller graph for this function:

int synctex_node_mean_line ( synctex_node_t  node)

Definition at line 3399 of file synctex_parser.c.

3399  {
3400  return node?(node->class->type==synctex_node_type_hbox?SYNCTEX_MEAN_LINE(node):SYNCTEX_LINE(node)):-1;
3401 }
synctex_node_t synctex_node_next ( synctex_node_t  node)

Definition at line 765 of file synctex_parser.c.

765  {
766  if (SYNCTEX_CHILD(node)) {
767  return SYNCTEX_CHILD(node);
768  }
769 sibling:
770  if (SYNCTEX_SIBLING(node)) {
771  return SYNCTEX_SIBLING(node);
772  }
773  if ((node = SYNCTEX_PARENT(node))) {
774  if (node->class->type == synctex_node_type_sheet) {/* EXC_BAD_ACCESS? */
775  return NULL;
776  }
777  goto sibling;
778  }
779  return NULL;
780 }
int synctex_node_page ( synctex_node_t  node)

Definition at line 3375 of file synctex_parser.c.

3375  {
3376  synctex_node_t parent = NULL;
3377  if (!node) {
3378  return -1;
3379  }
3380  parent = SYNCTEX_PARENT(node);
3381  while(parent) {
3382  node = parent;
3383  parent = SYNCTEX_PARENT(node);
3384  }
3385  if (node->class->type == synctex_node_type_sheet) {
3386  return SYNCTEX_PAGE(node);
3387  }
3388  return -1;
3389 }

+ Here is the caller graph for this function:

synctex_node_t synctex_node_parent ( synctex_node_t  node)

Definition at line 745 of file synctex_parser.c.

746 {
747  return SYNCTEX_PARENT(node);
748 }
synctex_node_t synctex_node_sheet ( synctex_node_t  node)

Definition at line 749 of file synctex_parser.c.

750 {
751  while(node && node->class->type != synctex_node_type_sheet) {
752  node = SYNCTEX_PARENT(node);
753  }
754  /* exit the while loop either when node is NULL or node is a sheet */
755  return node;
756 }
synctex_node_t synctex_node_sibling ( synctex_node_t  node)

Definition at line 761 of file synctex_parser.c.

762 {
763  return SYNCTEX_SIBLING(node);
764 }
int synctex_node_tag ( synctex_node_t  node)

Definition at line 3393 of file synctex_parser.c.

3393  {
3394  return node?SYNCTEX_TAG(node):-1;
3395 }

+ Here is the caller graph for this function:

synctex_node_type_t synctex_node_type ( synctex_node_t  node)

Definition at line 787 of file synctex_parser.c.

787  {
788  if (node) {
789  return (((node)->class))->type;
790  }
792 }

+ Here is the caller graph for this function:

int synctex_node_v ( synctex_node_t  node)

Definition at line 3181 of file synctex_parser.c.

3181  {
3182  if (!node) {
3183  return 0;
3184  }
3185  return SYNCTEX_VERT(node);
3186 }
float synctex_node_visible_h ( synctex_node_t  node)

Definition at line 3262 of file synctex_parser.c.

3262  {
3263  if (!node) {
3264  return 0;
3265  }
3266  return SYNCTEX_HORIZ(node)*node->class->scanner->unit+node->class->scanner->x_offset;
3267 }
float synctex_node_visible_v ( synctex_node_t  node)

Definition at line 3268 of file synctex_parser.c.

3268  {
3269  if (!node) {
3270  return 0;
3271  }
3272  return SYNCTEX_VERT(node)*node->class->scanner->unit+node->class->scanner->y_offset;
3273 }
float synctex_node_visible_width ( synctex_node_t  node)

Definition at line 3274 of file synctex_parser.c.

3274  {
3275  if (!node) {
3276  return 0;
3277  }
3278  return SYNCTEX_WIDTH(node)*node->class->scanner->unit;
3279 }
int synctex_node_width ( synctex_node_t  node)

Definition at line 3187 of file synctex_parser.c.

3187  {
3188  if (!node) {
3189  return 0;
3190  }
3191  return SYNCTEX_WIDTH(node);
3192 }
void synctex_scanner_display ( synctex_scanner_t  scanner)

Definition at line 3031 of file synctex_parser.c.

3031  {
3032  if (NULL == scanner) {
3033  return;
3034  }
3035  printf("The scanner:\noutput:%s\noutput_fmt:%s\nversion:%i\n",scanner->output,scanner->output_fmt,scanner->version);
3036  printf("pre_unit:%i\nx_offset:%i\ny_offset:%i\n",scanner->pre_unit,scanner->pre_x_offset,scanner->pre_y_offset);
3037  printf("count:%i\npost_magnification:%f\npost_x_offset:%f\npost_y_offset:%f\n",
3038  scanner->count,scanner->unit,scanner->x_offset,scanner->y_offset);
3039  printf("The input:\n");
3040  SYNCTEX_DISPLAY(scanner->input);
3041  if (scanner->count<1000) {
3042  printf("The sheets:\n");
3043  SYNCTEX_DISPLAY(scanner->sheet);
3044  printf("The friends:\n");
3045  if (scanner->lists_of_friends) {
3046  int i = scanner->number_of_lists;
3047  synctex_node_t node;
3048  while(i--) {
3049  printf("Friend index:%i\n",i);
3050  node = (scanner->lists_of_friends)[i];
3051  while(node) {
3052  printf("%s:%i,%i\n",
3053  synctex_node_isa(node),
3054  SYNCTEX_TAG(node),
3055  SYNCTEX_LINE(node)
3056  );
3057  node = SYNCTEX_FRIEND(node);
3058  }
3059  }
3060  }
3061  } else {
3062  printf("SyncTeX Warning: Too many objects\n");
3063  }
3064 }
void synctex_scanner_free ( synctex_scanner_t  scanner)

Definition at line 2908 of file synctex_parser.c.

2908  {
2909  if (NULL == scanner) {
2910  return;
2911  }
2912  if (SYNCTEX_FILE) {
2913  gzclose(SYNCTEX_FILE);
2914  SYNCTEX_FILE = NULL;
2915  }
2916  SYNCTEX_FREE(scanner->sheet);
2917  SYNCTEX_FREE(scanner->input);
2918  free(SYNCTEX_START);
2919  free(scanner->output_fmt);
2920  free(scanner->output);
2921  free(scanner->synctex);
2922  free(scanner->lists_of_friends);
2923  free(scanner);
2924 }

+ Here is the caller graph for this function:

const char* synctex_scanner_get_name ( synctex_scanner_t  scanner,
int  tag 
)

Definition at line 3066 of file synctex_parser.c.

3066  {
3067  synctex_node_t input = NULL;
3068  if (NULL == scanner) {
3069  return NULL;
3070  }
3071  input = scanner->input;
3072  do {
3073  if (tag == SYNCTEX_TAG(input)) {
3074  return (SYNCTEX_NAME(input));
3075  }
3076  } while((input = SYNCTEX_SIBLING(input)) != NULL);
3077  return NULL;
3078 }

+ Here is the caller graph for this function:

const char* synctex_scanner_get_output ( synctex_scanner_t  scanner)

Definition at line 3165 of file synctex_parser.c.

3165  {
3166  return NULL != scanner && scanner->output?scanner->output:"";
3167 }
const char* synctex_scanner_get_synctex ( synctex_scanner_t  scanner)

Definition at line 3168 of file synctex_parser.c.

3168  {
3169  return NULL != scanner && scanner->synctex?scanner->synctex:"";
3170 }
int synctex_scanner_get_tag ( synctex_scanner_t  scanner,
const char *  name 
)

Definition at line 3112 of file synctex_parser.c.

3112  {
3113  size_t char_index = strlen(name);
3114  if ((scanner = synctex_scanner_parse(scanner)) && (0 < char_index)) {
3115  /* the name is not void */
3116  char_index -= 1;
3117  if (!SYNCTEX_IS_PATH_SEPARATOR(name[char_index])) {
3118  /* the last character of name is not a path separator */
3119  int result = _synctex_scanner_get_tag(scanner,name);
3120  if (result) {
3121  return result;
3122  } else {
3123  /* the given name was not the one known by TeX
3124  * try a name relative to the enclosing directory of the scanner->output file */
3125  const char * relative = name;
3126  const char * ptr = scanner->output;
3127  while((strlen(relative) > 0) && (strlen(ptr) > 0) && (*relative == *ptr))
3128  {
3129  relative += 1;
3130  ptr += 1;
3131  }
3132  /* Find the last path separator before relative */
3133  while(relative > name) {
3134  if (SYNCTEX_IS_PATH_SEPARATOR(*(relative-1))) {
3135  break;
3136  }
3137  relative -= 1;
3138  }
3139  if ((relative > name) && (result = _synctex_scanner_get_tag(scanner,relative))) {
3140  return result;
3141  }
3142  if (SYNCTEX_IS_PATH_SEPARATOR(name[0])) {
3143  /* No tag found for the given absolute name,
3144  * Try each relative path starting from the shortest one */
3145  while(0<char_index) {
3146  char_index -= 1;
3147  if (SYNCTEX_IS_PATH_SEPARATOR(name[char_index])
3148  && (result = _synctex_scanner_get_tag(scanner,name+char_index+1))) {
3149  return result;
3150  }
3151  }
3152  }
3153  }
3154  return result;
3155  }
3156  }
3157  return 0;
3158 }

+ Here is the caller graph for this function:

synctex_node_t synctex_scanner_input ( synctex_scanner_t  scanner)

Definition at line 3159 of file synctex_parser.c.

3159  {
3160  return scanner?scanner->input:NULL;
3161 }
float synctex_scanner_magnification ( synctex_scanner_t  scanner)

Definition at line 3028 of file synctex_parser.c.

3028  {
3029  return scanner?scanner->unit:1;
3030 }
synctex_scanner_t synctex_scanner_new_with_output_file ( const char *  output,
const char *  build_directory,
int  parse 
)

Definition at line 2687 of file synctex_parser.c.

2687  {
2688  gzFile file = NULL;
2689  char * synctex = NULL;
2690  synctex_scanner_t scanner = NULL;
2691  synctex_io_mode_t io_mode = 0;
2692  /* Here we assume that int are smaller than void * */
2693  if (sizeof(int)>sizeof(void*)) {
2694  _synctex_error("INTERNAL INCONSISTENCY: int's are unexpectedly bigger than pointers, bailing out.");
2695  return NULL;
2696  }
2697  /* We ensure that SYNCTEX_BUFFER_SIZE < UINT_MAX, I don't know if it makes sense... */
2698  if (SYNCTEX_BUFFER_SIZE >= UINT_MAX) {
2699  _synctex_error("Internal inconsistency, bad SYNCTEX_BUFFER_SIZE (1)");
2700  return NULL;
2701  }
2702  /* for integers: */
2704  _synctex_error("Internal inconsistency, bad SYNCTEX_BUFFER_SIZE (2)");
2705  return NULL;
2706  }
2707  /* now open the synctex file */
2708  if (_synctex_open(output,build_directory,&synctex,&file,synctex_ADD_QUOTES,&io_mode) || !file) {
2709  if (_synctex_open(output,build_directory,&synctex,&file,synctex_DONT_ADD_QUOTES,&io_mode) || !file) {
2710  return NULL;
2711  }
2712  }
2714  if (NULL == scanner) {
2715  _synctex_error("malloc problem");
2716  free(synctex);
2717  gzclose(file);
2718  return NULL;
2719  }
2720  /* make a private copy of output for the scanner */
2721  if (NULL == (scanner->output = (char *)malloc(strlen(output)+1))){
2722  _synctex_error("! synctex_scanner_new_with_output_file: Memory problem (2), scanner's output is not reliable.");
2723  } else if (scanner->output != strcpy(scanner->output,output)) {
2724  _synctex_error("! synctex_scanner_new_with_output_file: Copy problem, scanner's output is not reliable.");
2725  }
2726  scanner->synctex = synctex;/* Now the scanner owns synctex */
2727  SYNCTEX_FILE = file;
2728  return parse? synctex_scanner_parse(scanner):scanner;
2729 }

+ Here is the caller graph for this function:

synctex_scanner_t synctex_scanner_parse ( synctex_scanner_t  scanner)

Definition at line 2927 of file synctex_parser.c.

2927  {
2928  synctex_status_t status = 0;
2929  if (!scanner || scanner->flags.has_parsed) {
2930  return scanner;
2931  }
2932  scanner->flags.has_parsed=1;
2933  scanner->pre_magnification = 1000;
2934  scanner->pre_unit = 8192;
2935  scanner->pre_x_offset = scanner->pre_y_offset = 578;
2936  /* initialize the offset with a fake unprobable value,
2937  * If there is a post scriptum section, this value will be overriden by the real life value */
2938  scanner->x_offset = scanner->y_offset = 6.027e23f;
2939 # define DEFINE_synctex_scanner_class(NAME)\
2940  scanner->class[synctex_node_type_##NAME] = synctex_class_##NAME;\
2941  (scanner->class[synctex_node_type_##NAME]).scanner = scanner
2945  DEFINE_synctex_scanner_class(void_hbox);
2947  DEFINE_synctex_scanner_class(void_vbox);
2951  DEFINE_synctex_scanner_class(boundary);
2952  SYNCTEX_START = (char *)malloc(SYNCTEX_BUFFER_SIZE+1); /* one more character for null termination */
2953  if (NULL == SYNCTEX_START) {
2954  _synctex_error("malloc error");
2955  synctex_scanner_free(scanner);
2956  return NULL;
2957  }
2959  /* SYNCTEX_END always points to a null terminating character.
2960  * Maybe there is another null terminating character between SYNCTEX_CUR and SYNCTEX_END-1.
2961  * At least, we are sure that SYNCTEX_CUR points to a string covering a valid part of the memory. */
2962  *SYNCTEX_END = '\0';
2964 # if defined(SYNCTEX_USE_CHARINDEX)
2965  scanner->charindex_offset = -SYNCTEX_BUFFER_SIZE;
2966 # endif
2967  status = _synctex_scan_preamble(scanner);
2968  if (status<SYNCTEX_STATUS_OK) {
2969  _synctex_error("SyncTeX Error: Bad preamble\n");
2970 bailey:
2971  synctex_scanner_free(scanner);
2972  return NULL;
2973  }
2974  status = _synctex_scan_content(scanner);
2975  if (status<SYNCTEX_STATUS_OK) {
2976  _synctex_error("SyncTeX Error: Bad content\n");
2977  goto bailey;
2978  }
2979  /* Everything is finished, free the buffer, close the file */
2980  free((void *)SYNCTEX_START);
2982  gzclose(SYNCTEX_FILE);
2983  SYNCTEX_FILE = NULL;
2984  /* Final tuning: set the default values for various parameters */
2985  /* 1 pre_unit = (scanner->pre_unit)/65536 pt = (scanner->pre_unit)/65781.76 bp
2986  * 1 pt = 65536 sp */
2987  if (scanner->pre_unit<=0) {
2988  scanner->pre_unit = 8192;
2989  }
2990  if (scanner->pre_magnification<=0) {
2991  scanner->pre_magnification = 1000;
2992  }
2993  if (scanner->unit <= 0) {
2994  /* no post magnification */
2995  scanner->unit = scanner->pre_unit / 65781.76;/* 65781.76 or 65536.0*/
2996  } else {
2997  /* post magnification */
2998  scanner->unit *= scanner->pre_unit / 65781.76;
2999  }
3000  scanner->unit *= scanner->pre_magnification / 1000.0;
3001  if (scanner->x_offset > 6e23) {
3002  /* no post offset */
3003  scanner->x_offset = scanner->pre_x_offset * (scanner->pre_unit / 65781.76);
3004  scanner->y_offset = scanner->pre_y_offset * (scanner->pre_unit / 65781.76);
3005  } else {
3006  /* post offset */
3007  scanner->x_offset /= 65781.76f;
3008  scanner->y_offset /= 65781.76f;
3009  }
3010  return scanner;
3011  #undef SYNCTEX_FILE
3012 }

+ Here is the caller graph for this function:

int synctex_scanner_x_offset ( synctex_scanner_t  scanner)

Definition at line 3022 of file synctex_parser.c.

3022  {
3023  return scanner?scanner->x_offset:0;
3024 }
int synctex_scanner_y_offset ( synctex_scanner_t  scanner)

Definition at line 3025 of file synctex_parser.c.

3025  {
3026  return scanner?scanner->y_offset:0;
3027 }
synctex_node_t synctex_sheet ( synctex_scanner_t  scanner,
int  page 
)

Definition at line 3416 of file synctex_parser.c.

3416  {
3417  if (scanner) {
3418  synctex_node_t sheet = scanner->sheet;
3419  while(sheet) {
3420  if (page == SYNCTEX_PAGE(sheet)) {
3421  return sheet;
3422  }
3423  sheet = SYNCTEX_SIBLING(sheet);
3424  }
3425  }
3426  return NULL;
3427 }

+ Here is the caller graph for this function:

synctex_node_t synctex_sheet_content ( synctex_scanner_t  scanner,
int  page 
)

Definition at line 3429 of file synctex_parser.c.

3429  {
3430  if (scanner) {
3431  return SYNCTEX_CHILD(synctex_sheet(scanner,page));
3432  }
3433  return NULL;
3434 }
void synctex_updater_append_magnification ( synctex_updater_t  updater,
char *  magnification 
)

Definition at line 4387 of file synctex_parser.c.

4387  {
4388  if (NULL==updater) {
4389  return;
4390  }
4391  if (magnification && strlen(magnification)) {
4392  updater->length += SYNCTEX_fprintf(SYNCTEX_FILE,"Magnification:%s\n",magnification);
4393  }
4394 }
void synctex_updater_append_x_offset ( synctex_updater_t  updater,
char *  x_offset 
)

Definition at line 4396 of file synctex_parser.c.

4396  {
4397  if (NULL==updater) {
4398  return;
4399  }
4400  if (x_offset && strlen(x_offset)) {
4401  updater->length += SYNCTEX_fprintf(SYNCTEX_FILE,"X Offset:%s\n",x_offset);
4402  }
4403 }
void synctex_updater_append_y_offset ( synctex_updater_t  updater,
char *  y_offset 
)

Definition at line 4405 of file synctex_parser.c.

4405  {
4406  if (NULL==updater) {
4407  return;
4408  }
4409  if (y_offset && strlen(y_offset)) {
4410  updater->length += SYNCTEX_fprintf(SYNCTEX_FILE,"Y Offset:%s\n",y_offset);
4411  }
4412 }
void synctex_updater_free ( synctex_updater_t  updater)

Definition at line 4414 of file synctex_parser.c.

4414  {
4415  if (NULL==updater) {
4416  return;
4417  }
4418  if (updater->length>0) {
4419  SYNCTEX_fprintf(SYNCTEX_FILE,"!%i\n",updater->length);
4420  }
4421  if (SYNCTEX_NO_GZ) {
4422  fclose((FILE *)SYNCTEX_FILE);
4423  } else {
4424  gzclose((gzFile)SYNCTEX_FILE);
4425  }
4426  free(updater);
4427  printf("... done.\n");
4428  return;
4429 }
synctex_updater_t synctex_updater_new_with_output_file ( const char *  output,
const char *  directory 
)

Definition at line 4343 of file synctex_parser.c.

4343  {
4344  synctex_updater_t updater = NULL;
4345  char * synctex = NULL;
4346  synctex_io_mode_t io_mode = 0;
4347  const char * mode = NULL;
4348  /* prepare the updater, the memory is the only one dynamically allocated */
4350  if (NULL == updater) {
4351  _synctex_error("! synctex_updater_new_with_file: malloc problem");
4352  return NULL;
4353  }
4354  if (_synctex_open(output,build_directory,&synctex,&SYNCTEX_FILE,synctex_ADD_QUOTES,&io_mode)
4355  && _synctex_open(output,build_directory,&synctex,&SYNCTEX_FILE,synctex_DONT_ADD_QUOTES,&io_mode)) {
4356 return_on_error:
4357  free(updater);
4358  updater = NULL;
4359  return NULL;
4360  }
4361  /* OK, the file exists, we close it and reopen it with the correct mode.
4362  * The receiver is now the owner of the "synctex" variable. */
4363  gzclose(SYNCTEX_FILE);
4364  SYNCTEX_FILE = NULL;
4366  mode = _synctex_get_io_mode_name(io_mode|synctex_io_append_mask);/* either "a" or "ab", depending on the file extension */
4367  if (SYNCTEX_NO_GZ) {
4368  if (NULL == (SYNCTEX_FILE = (void *)fopen(synctex,mode))) {
4369 no_write_error:
4370  _synctex_error("! synctex_updater_new_with_file: Can't append to %s",synctex);
4371  free(synctex);
4372  goto return_on_error;
4373  }
4374  updater->fprintf = (synctex_fprintf_t)(&fprintf);
4375  } else {
4376  if (NULL == (SYNCTEX_FILE = (void *)gzopen(synctex,mode))) {
4377  goto no_write_error;
4378  }
4379  updater->fprintf = (synctex_fprintf_t)(&gzprintf);
4380  }
4381  printf("SyncTeX: updating %s...",synctex);
4382  free(synctex);
4383  return updater;
4384 }