/*
* ion/mod_query/wedln.c
*
- * Copyright (c) Tuomo Valkonen 1999-2007.
+ * Copyright (c) Tuomo Valkonen 1999-2008.
*
- * Ion is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
+ * See the included file LICENSE for details.
*/
#include <string.h>
#include <ioncore/event.h>
#include <ioncore/regbind.h>
#include <ioncore/gr-util.h>
+#include <ioncore/sizehint.h>
+#include <ioncore/resize.h>
#include "edln.h"
#include "wedln.h"
#include "inputp.h"
static int get_textarea_height(WEdln *wedln, bool with_spacing)
{
- GrBorderWidths bdw;
- GrFontExtents fnte;
+ int w=1, h=1;
- grbrush_get_border_widths(WEDLN_BRUSH(wedln), &bdw);
- grbrush_get_font_extents(WEDLN_BRUSH(wedln), &fnte);
+ if(WEDLN_BRUSH(wedln)!=NULL)
+ mod_query_get_minimum_extents(WEDLN_BRUSH(wedln), with_spacing, &w, &h);
- return (fnte.max_height+bdw.top+bdw.bottom+
- (with_spacing ? bdw.spacing : 0));
+ return h;
}
}
+void wedln_size_hints(WEdln *wedln, WSizeHints *hints_ret)
+{
+ int w=1, h=1;
+
+ if(WEDLN_BRUSH(wedln)!=NULL){
+ mod_query_get_minimum_extents(WEDLN_BRUSH(wedln), FALSE, &w, &h);
+ w+=wedln->prompt_w+wedln->info_w;
+ w+=grbrush_get_text_width(WEDLN_BRUSH(wedln), "xxxxxxxxxx", 10);
+ }
+
+ hints_ret->min_set=TRUE;
+ hints_ret->min_width=w;
+ hints_ret->min_height=h;
+}
+
+
/*}}}*/
/*{{{ Draw */
-void wedln_draw_completions(WEdln *wedln, bool complete)
+void wedln_draw_completions(WEdln *wedln, int mode)
{
WRectangle geom;
get_completions_geom(wedln, G_CURRENT, &geom);
draw_listing(WEDLN_BRUSH(wedln), &geom, &(wedln->compl_list),
- complete, GR_ATTR(selection));
+ mode, GR_ATTR(selection));
}
}
: GR_ATTR(inactive));
if(completions)
- wedln_draw_completions(wedln, FALSE);
+ wedln_draw_completions(wedln, LISTING_DRAW_ALL);
wedln_draw_textarea(wedln);
input_refit((WInput*)wedln);
if(w==REGION_GEOM(wedln).w && h==REGION_GEOM(wedln).h)
- wedln_draw_completions(wedln, TRUE);
+ wedln_draw_completions(wedln, LISTING_DRAW_COMPLETE);
}
if(wedln->compl_list.strs==NULL)
return;
if(scrollup_listing(&(wedln->compl_list)))
- wedln_draw_completions(wedln, TRUE);
+ wedln_draw_completions(wedln, LISTING_DRAW_COMPLETE);
}
if(wedln->compl_list.strs==NULL)
return;
if(scrolldown_listing(&(wedln->compl_list)))
- wedln_draw_completions(wedln, TRUE);
+ wedln_draw_completions(wedln, LISTING_DRAW_COMPLETE);
}
static void wedln_do_select_completion(WEdln *wedln, int n)
{
- bool complredraw=listing_select(&(wedln->compl_list), n);
- wedln_draw_completions(wedln, complredraw);
+ bool redraw=listing_select(&(wedln->compl_list), n);
+ wedln_draw_completions(wedln, redraw);
update_nocompl++;
edln_set_completion(&(wedln->edln), wedln->compl_list.strs[n],
/*EXTL_DOC
* Call completion handler with the text between the beginning of line and
* current cursor position, or select next/previous completion from list if in
- * auto-show-completions mode and \var{cycle} is set to ``next'' or ``prev'',
- * respectively. The \var{mode} may be ``history'' or ``normal''. If it is
+ * auto-show-completions mode and \var{cycle} is set to \codestr{next} or
+ * \codestr{prev}, respectively.
+ * The \var{mode} may be \codestr{history} or \codestr{normal}. If it is
* not set, the previous mode is used. Normally next entry is not cycled to
* despite the setting of \var{cycle} if mode switch occurs. To override
- * this, use ``next-always'' and ``prev-always'' for \var{cycle}.
+ * this, use \codestr{next-always} and \codestr{prev-always} for \var{cycle}.
*/
EXTL_EXPORT_MEMBER
void wedln_complete(WEdln *wedln, const char *cycle, const char *mode)
wedln->handler=extl_fn_none();
p=edln_finish(&(wedln->edln));
- if(region_manager_allows_destroying((WRegion*)wedln))
- destroy_obj((Obj*)wedln);
+ region_rqdispose((WRegion*)wedln);
if(p!=NULL)
extl_call(handler, "s", NULL, p);
{input_scrolldown, wedln_scrolldown_completions},
{window_insstr, wedln_insstr},
{(DynFun*)input_style, (DynFun*)wedln_style},
+ {region_size_hints, wedln_size_hints},
END_DYNFUNTAB
};