Changeset c3ab155


Ignore:
Timestamp:
Jun 17, 2003, 9:46:10 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
b1299da
Parents:
65e3901
Message:
Really use just one view now, named 'main' and recalculate
  messages when its filter is changed.  This is in preperation for
  other design changes
Added the 'default_style' variable
Added the 'toggle-oneline' command
the 'o' key is bound to 'toggle-oneline'
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rb97fce8 rc3ab155  
    88           format_msg() function is found in .owlconf
    99        Added the 'oneline' style
     10        Added the 'default_style' variable
     11        Added the 'toggle-oneline' command
     12        the 'o' key is bound to 'toggle-oneline'
     13        Really use just one view now, named 'main' and recalculate
     14          messages when its filter is changed
    1015       
    11162.0.3
  • commands.c

    raac889a rc3ab155  
    270270              "alist",
    271271              "Print a listing of buddies logged in, regardless of protocol."),
     272
     273  OWLCMD_ARGS("toggle-oneline", owl_command_toggleoneline, OWL_CTX_INTERACTIVE,
     274              "Toggle the style between oneline and the default style",
     275              "toggle-oneline",
     276              ""),
    272277
    273278  OWLCMD_VOID("recv:shiftleft", owl_command_shift_left, OWL_CTX_INTERACTIVE,
     
    866871char *owl_command_blist() {
    867872  owl_function_buddylist(1, 1, NULL);
     873  return(NULL);
     874}
     875
     876char *owl_command_toggleoneline() {
     877  owl_function_toggleoneline();
    868878  return(NULL);
    869879}
  • functions.c

    rd559df9 rc3ab155  
    19551955}
    19561956
    1957 
    1958 void owl_function_change_view(char *filtname)
     1957#if 0
     1958void owl_function_change_view_old(char *filtname)
    19591959{
    19601960  owl_view *v;
     
    19991999  owl_global_set_curmsg(&g, newpos);
    20002000
     2001  owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
     2002  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2003  owl_global_set_direction_downwards(&g);
     2004}
     2005#endif
     2006
     2007void owl_function_change_view(char *filtname)
     2008{
     2009  owl_view *v;
     2010  owl_filter *f;
     2011  int curid=-1, newpos, curmsg;
     2012  owl_message *curm=NULL;
     2013
     2014  v=owl_global_get_current_view(&g);
     2015
     2016  curmsg=owl_global_get_curmsg(&g);
     2017  if (curmsg==-1) {
     2018    owl_function_debugmsg("Hit the curmsg==-1 case in change_view");
     2019  } else {
     2020    curm=owl_view_get_element(v, curmsg);
     2021    if (curm) {
     2022      curid=owl_message_get_id(curm);
     2023      owl_view_save_curmsgid(v, curid);
     2024    }
     2025  }
     2026
     2027  f=owl_global_get_filter(&g, filtname);
     2028  if (!f) {
     2029    owl_function_makemsg("Unknown filter");
     2030    return;
     2031  }
     2032
     2033  owl_view_new_filter(v, f);
     2034
     2035  /* Figure out what to set the current message to.
     2036   * - If the view we're leaving has messages in it, go to the closest message
     2037   *   to the last message pointed to in that view.
     2038   * - If the view we're leaving is empty, try to restore the position
     2039   *   from the last time we were in the new view.  */
     2040  if (curm) {
     2041    newpos = owl_view_get_nearest_to_msgid(v, curid);
     2042  } else {
     2043    newpos = owl_view_get_nearest_to_saved(v);
     2044  }
     2045
     2046  owl_global_set_curmsg(&g, newpos);
    20012047  owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
    20022048  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     
    29663012  fclose(file);
    29673013}
     3014
     3015void owl_function_toggleoneline()
     3016{
     3017  char *style;
     3018
     3019  style=owl_global_get_style(&g);
     3020
     3021  if (strcmp(style, "oneline")) {
     3022    owl_global_set_style(&g, "oneline");
     3023  } else {
     3024    owl_global_set_style(&g, owl_global_get_default_style(&g));
     3025  }
     3026}
  • keys.c

    r38cf544c rc3ab155  
    246246  BIND_CMD("T",   "delete trash",     "mark all 'trash' messages for deletion");
    247247
     248  BIND_CMD("o",   "toggle-oneline", "");
     249
    248250  BIND_CMD("A",   "zaway toggle",     "toggles zaway on and off");
    249251
  • owl.c

    r8b32593 rc3ab155  
    211211
    212212  /* set the current view */
    213   owl_view_create(owl_global_get_current_view(&g), f);
     213  owl_view_create(owl_global_get_current_view(&g), "main", f, owl_global_get_style_by_name(&g, "default"));
    214214
    215215  /* AIM init */
  • owl.h

    rbd3f232 rc3ab155  
    314314
    315315typedef struct _owl_view {
     316  char *name;
    316317  owl_filter *filter;
    317318  owl_messagelist ml;
     319  owl_style *style;
    318320} owl_view;
    319321
  • stylefunc.c

    r65e3901 rc3ab155  
    430430     
    431431    /* make personal messages bold for smaat users */
    432     if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_personal(m)) {
     432    if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&
     433        owl_message_is_personal(m) &&
     434        owl_message_is_direction_in(m)) {
    433435      owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    434436    }
  • variable.c

    r8b32593 rc3ab155  
    204204                      "available, 'perl'\n",
    205205                      NULL, owl_variable_style_set, NULL),
     206
     207  OWLVAR_STRING( "default_style" /* %OwlVarStub */, "default",
     208                 "name of the default formatting style",
     209                 "This sets the default message formatting style. Possbile\n"
     210                 "values include 'default' 'basic' 'oneline' and if\n"
     211                 "available, 'perl'\n" ),
    206212
    207213  OWLVAR_INT(    "edit:maxfillcols" /* %OwlVarStub:edit_maxfillcols */, 70,
  • view.c

    r3a2daac rc3ab155  
    44static const char fileIdent[] = "$Id$";
    55
    6 void owl_view_create(owl_view *v, owl_filter *f) {
     6void owl_view_create(owl_view *v, char *name, owl_filter *f, owl_style *s)
     7{
     8  v->name=owl_strdup(name);
    79  v->filter=f;
     10  v->style=s;
    811  owl_messagelist_create(&(v->ml));
    912  owl_view_recalculate(v);
    1013}
    1114
    12 void owl_view_consider_message(owl_view *v, owl_message *m) {
    13   /* if the message matches the filter then add to view */
     15
     16/* if the message matches the filter then add to view */
     17void owl_view_consider_message(owl_view *v, owl_message *m)
     18{
    1419  if (owl_filter_message_match(v->filter, m)) {
    1520    owl_messagelist_append_element(&(v->ml), m);
     
    1722}
    1823
    19 void owl_view_recalculate(owl_view *v) {
    20   /* add all the global messages that match the filter */
     24/* remove all messages, add all the global messages that match the
     25 * filter.
     26 */
     27void owl_view_recalculate(owl_view *v)
     28{
    2129  int i, j;
    2230  owl_messagelist *gml;
     
    4149}
    4250
    43 owl_message *owl_view_get_element(owl_view *v, int index) {
     51void owl_view_new_filter(owl_view *v, owl_filter *f)
     52{
     53  v->filter=f;
     54  owl_view_recalculate(v);
     55}
     56
     57void owl_view_set_style(owl_view *v, owl_style *s)
     58{
     59  v->style=s;
     60}
     61
     62owl_message *owl_view_get_element(owl_view *v, int index)
     63{
    4464  return(owl_messagelist_get_element(&(v->ml), index));
    4565}
    4666
    47 void owl_view_delete_element(owl_view *v, int index) {
     67void owl_view_delete_element(owl_view *v, int index)
     68{
    4869  owl_messagelist_delete_element(&(v->ml), index);
    4970}
    5071
    51 void owl_view_undelete_element(owl_view *v, int index) {
     72void owl_view_undelete_element(owl_view *v, int index)
     73{
    5274  owl_messagelist_undelete_element(&(v->ml), index);
    5375}
    5476
    55 int owl_view_get_size(owl_view *v) {
     77int owl_view_get_size(owl_view *v)
     78{
    5679  return(owl_messagelist_get_size(&(v->ml)));
    5780}
     
    5982/* Returns the position in the view with a message closest
    6083 * to the passed msgid. */
    61 int owl_view_get_nearest_to_msgid(owl_view *v, int targetid) {
     84int owl_view_get_nearest_to_msgid(owl_view *v, int targetid)
     85{
    6286  int i, bestdist=-1, bestpos=0, curid, curdist;
    6387
     
    7397}
    7498
    75 int owl_view_get_nearest_to_saved(owl_view *v) {
     99int owl_view_get_nearest_to_saved(owl_view *v)
     100{
    76101  int cachedid;
    77102
     
    83108/* saves the current message position in the filter so it can
    84109 * be restored later if we switch back to this filter. */
    85 void owl_view_save_curmsgid(owl_view *v, int curid) {
     110void owl_view_save_curmsgid(owl_view *v, int curid)
     111{
    86112  owl_filter_set_cachedmsgid(v->filter, curid);
    87113}
    88114
    89 char *owl_view_get_filtname(owl_view *v) {
     115char *owl_view_get_filtname(owl_view *v)
     116{
    90117  return(owl_filter_get_name(v->filter));
    91118}
    92119
    93 void owl_view_free(owl_view *v) {
     120void owl_view_free(owl_view *v)
     121{
    94122  owl_list_free_simple((owl_list *) &(v->ml));
     123  if (v->name) owl_free(v->name);
    95124}
Note: See TracChangeset for help on using the changeset viewer.