void		iter_for_len(t_item *items, t_args *args, int directory)
{
	t_item *start;

	start = NULL;
	set_sd_props(args);
	if (items)
	{
		start = get_start(items);
		while (items)
		{
			if (directory == 0 && items->child == NULL)
			{
				get_max_len(items, args);
				args->sd->nb_items++;
			}
			else
			{
				get_max_len(items, args);
				args->sd->nb_items++;
			}
			items = items->next;
		}
		items = start;
		start = NULL;
	}
}
Exemple #2
0
int			main(int ac, char **av)
{
	int		i = 1;
	int		y = 0;
	int		maxlen = -1;
	char	*start = 0;
	int		len;

	(void)ac;
	while (av[i])
	{
		y = 0;
		while (av[i][y])
		{
			len = get_max_len(av, av[i] + y);
			if (len > maxlen)
			{
				maxlen = len;
				start = av[i] + y;
			}
			y++;
		}
		i++;
	}
	if (start)
		write(1, start, maxlen);
	write(1, "\n", 1);
	return (0);
}
Exemple #3
0
/**
 * Display list items to choose from
 */
ui_event item_menu(cmd_code cmd, int mode)
{
    menu_type menu;
    menu_iter menu_f = {0, 0, get_item_display, get_item_action, 0 };
    ui_event evt = { 0 };

    size_t max_len = Term->wid - 1;

    char selections[40];

    int i;

    /* Set up the menu */
    WIPE(&menu, menu);
    menu_init(&menu, MN_SKIN_SCROLL, &menu_f);
    menu_setpriv(&menu, num_obj, items);
    for (i = 0; i < num_obj; i++)
	selections[i] = items[i].key;
    menu.selections = selections;
    menu.cmd_keys = "/-0123456789";
    get_max_len(&max_len);
    area.page_rows = menu.count + 1;
    area.width = max_len;
    area.col = MIN(Term->wid - 1 - (int) max_len, COL_MAP + tile_width);
    menu_layout(&menu, &area);
    evt = menu_select(&menu, 0, TRUE);

    if (evt.type != EVT_ESCAPE)
    {
	evt.key.code = selection;
    }

    /* Result */
    return (evt);
}
Exemple #4
0
/**
 * Display an entry on the item menu
 */
void get_item_display(menu_type *menu, int oid, bool cursor, int row, int col,
		      int width)
{
    struct object_menu_data *choice = menu_priv(menu);
    size_t max_len = Term->wid - 1;

    const object_type *o_ptr = choice[oid].object;

    int ex_width = 0;

    /* Do we even have a menu? */
    if (!show_list) return;

    /* Width of extra fields */
    if (olist_mode & OLIST_WEIGHT)
	ex_width += 9;
    if (olist_mode & OLIST_PRICE)
	ex_width += 9;
    if (olist_mode & OLIST_FAIL)
	ex_width += 10;

    /* Get max length */
    get_max_len(&max_len);

    /* Print it */
    show_obj(oid, max_len, items[oid].label, o_ptr, cursor, olist_mode);
}
Exemple #5
0
inline Uint32
NdbPack::Data::get_max_len4() const
{
  Uint32 len4 = get_max_len();
  len4 += 3;
  len4 /= 4;
  len4 *= 4;
  return len4;
}
Exemple #6
0
void			init_all(t_all *all, int ac, char **av)
{
	all->tty = open_tty();
	init_termcap(all);
	signals_handlers();
	all->list = init_list(ac, av);
	all->node = all->list;
	((t_select *)all->node->content)->flags |= F_CURSOR;
	bzero(&all->cursor, sizeof(int) * 2);
	get_size_window(all);
	all->maxlen = get_max_len(all->list);
}
Exemple #7
0
void get_ans()
{
    int i, j, tmp;
    dp[mes_len] = 0;
    for(i=mes_len-1; i>=0; i--)
    {
        dp[i] = dp[i+1] + 1; 
        for(j=0; j<W; j++)
            if( strlen(Dict[j] ) <= (mes_len-i) && Dict[j][0] == Mes[i])
            {
                tmp =  get_max_len( &Mes[i] , Dict[j]);
                if( tmp != -1 ) dp[i] = MIN(dp[i], tmp);
            }
    }
}
Exemple #8
0
/*
 * Display a list of objects.  Each object may be prefixed with a label.
 * Used by show_inven(), show_equip(), and show_floor().  Mode flags are
 * documented in object.h
 */
static void show_obj_list(int num_obj, u32b display, olist_detail_t mode)
{
    int i, row = 0, col = 0, sp = 0;
    size_t max_len = Term->wid - 1;
    int ex_width = 0;

    object_type *o_ptr;
    char tmp_val[80];

    bool in_term;

    in_term = (mode & OLIST_WINDOW) ? TRUE : FALSE;

    get_max_len(&max_len);

    /* Check for window size restrictions */
    if (in_term)
    {
	/* Scan windows */
	for (i = 0; i < ANGBAND_TERM_MAX; i++) {
	    /* Unused */
	    if (!angband_term[i])
		continue;
	
	    /* Count windows displaying inven */
	    if (op_ptr->window_flag[i] & display)
		max_len = MIN(max_len, angband_term[i]->wid);
	}
    }	

    /* Width of extra fields */
    if (mode & OLIST_WEIGHT)
	ex_width += 9;
    if (mode & OLIST_PRICE)
	ex_width += 9;
    if (mode & OLIST_FAIL)
	ex_width += 10;

    /* Determine beginning row and column */
    if (in_term) {
	/* Term window */
	row = 0;
	col = 0;
    } else {
	/* Main window */
	row = 1;
	col = Term->wid - 1 - max_len - ex_width;
	col = MIN(col, 20);

	if (col < 3)
	    col = 0;
    }

    /* Output the list */
    for (i = 0; i < num_obj; i++) 
    {
	o_ptr = items[i].object;

	/* Display each line */
	show_obj(i + sp, max_len, items[i].label, o_ptr, FALSE, mode);
	if ((i == (INVEN_FEET - INVEN_WIELD)) && need_spacer)
	{
	    sp = 1;
	    prt("", i + sp + 1, MAX(col - 2, 0));
	}
    }

    /* For the inventory: print the quiver count */
    if (mode & OLIST_QUIVER)
    {
	int count, j;

	/* Adjust for subwindow */
	int skip = (in_term) ? 1 : 0;

	/* Quiver may take multiple lines */
	for(j = 0; j < p_ptr->quiver_slots; j++, i++)
	{
	    /* Number of missiles in this "slot" */
	    if (j == p_ptr->quiver_slots - 1 && p_ptr->quiver_remainder > 0)
		count = p_ptr->quiver_remainder;
	    else
		count = 99;

	    /* Clear the line */
	    prt("", row + i + skip, MAX(col - 2, 0));

	    /* Print the (disabled) label */
	    strnfmt(tmp_val, sizeof(tmp_val), "%c) ", index_to_label(i));
	    c_put_str(TERM_SLATE, tmp_val, row + i + skip, col);

	    /* Print the count */
	    strnfmt(tmp_val, sizeof(tmp_val), "in Quiver: %d missile%s", count,
		    count == 1 ? "" : "s");
	    c_put_str(TERM_L_UMBER, tmp_val, row + i + skip, col + 3);
	}
    }

    /* Clear term windows */
    if (in_term) {
	for (; i < Term->hgt; i++) {
	    prt("", row + i + offset + sp, MAX(col - 2, 0));
	}
    }

    /* Print a drop shadow for the main window if necessary */
    else if (i > 0 && row + i < 24) {
	prt("", row + i + sp, MAX(col - 2, 0));
    }
}