Exemple #1
0
/*
  Move n elements in page history; n == 0 doesn't move,
  n < 0 moves n items back, n > 0 moves n items forward.
*/
void page_history_move(int n)
{
    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) {
		xdvi_bell();
		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) {
		xdvi_bell();
		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]);

#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();
}
Exemple #2
0
int cmd_goto(string str) {
   object ob;
   string tmp,flag ;
   int err;

   notify_fail( SYNTAX );

   if(!str || str == "")  return 0;

   if (sscanf(str,"%s %s",flag,tmp)==2) {
	if (flag!="-c") {
		notify_fail (flag+": unknown flag.\n") ;
		return 1 ;
	}
	str = tmp ;
    }
 
   if( ob = find_living(lower_case(str)) ) 
	return goto_location( environment(ob) );
 
   str = resolv_path("cwd", str);
 
    if (!flag || flag!="-c") {
       if(extract(str, strlen(str)-2, strlen(str)-1) != ".c")   str += ".c";

 
       if(!file_exists(str)) {
   	write("Goto: No such location or living object found.\n");
       return 1; }

   }
   err = catch( call_other(str, "???") );		// Load up the room
 
   if (!ob = find_object(str)) {
     write("Goto: Could not load " + str + "\n");
     if(err) write("      " + err );
   return 1; }
 
   goto_location( ob );
 
return 1; }
Exemple #3
0
/*
  Delete n elements from the page history.
  If n < 0, delete current and n-1 previous items and move to the item before them.
  If n > 0, delete current and n-1 next items and move to the item after them.
  E.g. (with current position marked by `<>'):

  a b <c> d e
  -> page_history_delete(-2)
  -> <a> d e

  a b <c> d e
  -> page_history_delete(2)
  -> a b <e>

  Prints an error to the statusline if number of deletions exceeds the limits
  of the list.
*/
void page_history_delete(int n)
{
    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) {
		xdvi_bell();
		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) {
		xdvi_bell();
		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]);
    page_history_show(m_page_history_head, m_page_history);
    page_history_show_statusline(m_page_history_head, m_page_history, msg);
}