Back to index

tetex-bin  3.0
Functions
pagehist.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void page_history_move (int n)
void page_history_insert (int n)
void page_history_delete (int n)
void page_history_update_toolbar_navigation (void)
void page_history_clear (void)

Function Documentation

Definition at line 436 of file pagehist.c.

{
    struct dl_list *pos, *curr;

    if (resource.page_history_size == 0)
       return;
    
    m_page_history_head = m_page_history;

    for (curr = m_page_history; curr != NULL && curr->prev != NULL; curr = pos) {
       pos = curr->prev;
       free(curr->item);
       (void)dl_list_remove_item(&curr);
       m_page_history_length--;
       page_history_show(m_page_history_head, m_page_history);
       page_history_show_statusline(m_page_history_head, m_page_history, NULL);
    }

/*     for (curr = m_page_history; curr != NULL && curr->next != NULL; curr = pos) { */
/*     pos = curr->next; */
/*     free(curr->item); */
/*     (void)dl_list_remove_item(&curr); */
/*     m_page_history_length--; */
/*     page_history_show(m_page_history_head, m_page_history); */
/*     } */
    

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 482 of file pagehist.c.

{
    struct dl_list *pos;
    struct page_history *item;
    const char *msg = NULL;
    
    if (resource.page_history_size == 0)
       return;
    
    if (m_page_history_head == NULL)
       m_page_history_head = m_page_history;

    /*      fprintf(stderr, "deleting items: |%d|\n", n); */
    
    if (n < 0) { /* delete backwards */
       for (pos = NULL; n < 0; n++) {
           if (m_page_history != NULL)
              pos = m_page_history->prev;
           if (pos == NULL) {
              XBell(DISP, 0);
              msg = " - at begin of page history.";
              break;
           }
           else {
              /* remove item */
              free(m_page_history->item);
              (void)dl_list_remove_item(&m_page_history);
              m_page_history = pos;
              m_page_history_currpos--;
              m_page_history_length--;
           }
       }
    }
    else { /* delete forward */
       for (pos = NULL; n > 0; n--) {
           if (m_page_history != NULL)
              pos = m_page_history->next;
           if (pos == NULL) {
              XBell(DISP, 0);
              msg = " - at end of page history.";
              break;
           }
           else {
              /* remove item */
              free(m_page_history->item);
              if (m_page_history->prev == NULL) { /* at head */
                  m_page_history_head = m_page_history = dl_list_truncate_head(m_page_history);
              }
              else {
                  (void)dl_list_remove_item(&m_page_history);
                  m_page_history = pos;
              }
              /* Note: m_page_history_currpos remains unchanged here */
              m_page_history_length--;
           }
       }
    }
    item = (struct page_history *)m_page_history->item;
#if DEBUG
    fprintf(stderr, "going to page %d\n", item->pageno);
#endif
    goto_location(m_filename_list[item->file_idx], item->pageno);
    page_history_show(m_page_history_head, m_page_history);
    page_history_show_statusline(m_page_history_head, m_page_history, msg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 356 of file pagehist.c.

{
    struct page_history *item = NULL;
    static char *current_filename = NULL;
    static size_t filename_idx = 0; /* index of current filename */

#if DEBUG
    fprintf(stderr, "inserting into history: %d\n", n);
#endif
    page_history_show(m_page_history_head, m_page_history);
    /* do nothing if no history is used */
    if (resource.page_history_size == 0)
       return;

    if (m_page_history_head == NULL)
       m_page_history_head = m_page_history;
    
    item = xmalloc(sizeof *item);
    /* first call, or filename changed -> update file_list */
    if (current_filename == NULL || strcmp(current_filename, globals.dvi_name) != 0) {
       size_t i;
       current_filename = xstrdup(globals.dvi_name);

       for (i = 0; i < m_filename_size; i++) {
#if DEBUG
           fprintf(stderr, "comparing %d: |%s|%s|\n", i, current_filename, m_filename_list[i]);
#endif
           if (strcmp(current_filename, m_filename_list[i]) == 0) { /* found */
              filename_idx = i;
              break;
           }
       }

       if (i >= m_filename_size) { /* not found, insert into file list */
           m_filename_list = xrealloc(m_filename_list, (m_filename_size + 1) * sizeof *m_filename_list);
           m_filename_list[m_filename_size] = filename_append_dvi(current_filename);
           filename_idx = m_filename_size++;
#if DEBUG
           fprintf(stderr, "NEW file %d: %s\n", filename_idx, current_filename);
#endif
       }
    }
    
#if DEBUG
    fprintf(stderr, "-------- %d >= %d?\n", m_page_history_length, resource.page_history_size - 1);
#endif
    if (m_page_history_length >= resource.page_history_size - 1) { /* truncate history */
       free(m_page_history_head->item);
       m_page_history_head = dl_list_truncate_head(m_page_history_head);
    }
    else {
       m_page_history_length++;
    }
    
    item->pageno = n;
    item->file_idx = filename_idx;
    
#if DEBUG
    fprintf(stderr, "inserting %d\n", item->pageno);
#endif
    m_page_history = dl_list_insert(m_page_history, item);
    m_page_history_currpos++;

#if DEBUG
    fprintf(stderr, "head: %p, curr: %p\n", (void *)m_page_history_head, (void *)m_page_history);
#endif
    page_history_show(m_page_history_head, m_page_history);
    page_history_update_toolbar_navigation();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 295 of file pagehist.c.

{
    struct dl_list *pos;
    struct page_history *item;
    const char *msg = NULL;

    page_history_show(m_page_history_head, m_page_history);
    
    if (resource.page_history_size == 0)
       return;
    
    if (m_page_history_head == NULL)
       m_page_history_head = m_page_history;
    
    if (n < 0) { /* move backwards */
       for (pos = NULL; n < 0; n++) {
           if (m_page_history != NULL)
              pos = m_page_history->prev;
           if (pos == NULL) {
              XBell(DISP, 0);
              msg = " - at begin of page history.";
              break;
           }
           else {
              m_page_history = pos;
              m_page_history_currpos--;
           }
       }
    }
    else { /* move forward */
       for (pos = NULL; n > 0; n--) {
           if (m_page_history != NULL)
              pos = m_page_history->next;
           if (pos == NULL) {
              XBell(DISP, 0);
              msg = " - at end of page history.";
              break;
           }
           else {
              m_page_history = pos;
              m_page_history_currpos++;
           }
       }
    }
    item = (struct page_history *)m_page_history->item;
#if DEBUG
    fprintf(stderr, "going to page %d\n", item->pageno);
#endif
    goto_location(m_filename_list[item->file_idx], item->pageno);

#if defined(MOTIF) && HAVE_XPM
    tb_set_pagehist_back_sensitivity(m_page_history->prev != NULL);
    tb_set_pagehist_forward_sensitivity(m_page_history->next != NULL);
#endif
    
    page_history_show(m_page_history_head, m_page_history);
    page_history_show_statusline(m_page_history_head, m_page_history, msg);
    page_history_update_toolbar_navigation();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 427 of file pagehist.c.

{
#if defined(MOTIF) && HAVE_XPM
    tb_set_htex_back_sensitivity(m_page_history->prev != NULL);
    tb_set_htex_forward_sensitivity(m_page_history->next != NULL);
#endif
}

Here is the caller graph for this function: