Changeset cf83b7a


Ignore:
Timestamp:
Jun 30, 2003, 6:12:40 PM (17 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
453bd70
Parents:
c9334b1
Message:
Started adding code to do question/response stuff
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rc9334b1 rcf83b7a  
    11$Id$
     2
     32.0.6-pre-2
     4        Started adding code to do question/response stuff
    25
    362.0.6-pre-1
  • commands.c

    r03ad7b2 rcf83b7a  
    7777              "start-command [initial-value]",
    7878              "Initializes the command field to initial-value."),
     79
     80  OWLCMD_ARGS("start-question", owl_command_start_question, OWL_CTX_INTERACTIVE,
     81              "prompts the user to enter a response to some question",
     82              "start-command <question>",
     83              ""),
    7984
    8085  OWLCMD_ARGS("alias", owl_command_alias, OWL_CTX_ANY,
     
    758763                  "", ""),
    759764
     765  OWLCMD_VOID_CTX("editresponse:done", owl_command_editresponse_done,
     766                  OWL_CTX_EDITRESPONSE,
     767                  "completes the response to a question",
     768                  "", ""),
     769
    760770  OWLCMD_VOID_CTX("editmulti:move-up-line", owl_editwin_key_up,
    761771                  OWL_CTX_EDITMULTI,
     
    835845};
    836846
    837 void owl_command_info() {
     847void owl_command_info()
     848{
    838849  owl_function_info();
    839850}
    840851
    841 void owl_command_nop() {
    842 }
    843 
    844 char *owl_command_help(int argc, char **argv, char *buff) {
     852void owl_command_nop()
     853{
     854}
     855
     856char *owl_command_help(int argc, char **argv, char *buff)
     857{
    845858  if (argc!=2) {
    846859    owl_help();
     
    852865}
    853866
    854 char *owl_command_zlist(int argc, char **argv, char *buff) {
     867char *owl_command_zlist(int argc, char **argv, char *buff)
     868{
    855869  int elapsed=0, timesort=0;
    856870  char *file=NULL;
     
    884898}
    885899
    886 char *owl_command_alist() {
     900char *owl_command_alist()
     901{
    887902  owl_function_buddylist(1, 0, NULL);
    888903  return(NULL);
    889904}
    890905
    891 char *owl_command_blist() {
     906char *owl_command_blist()
     907{
    892908  owl_function_buddylist(1, 1, NULL);
    893909  return(NULL);
    894910}
    895911
    896 char *owl_command_toggleoneline() {
     912char *owl_command_toggleoneline()
     913{
    897914  owl_function_toggleoneline();
    898915  return(NULL);
    899916}
    900917
    901 void owl_command_about() {
     918void owl_command_about()
     919{
    902920  owl_function_about();
    903921}
    904922
    905 void owl_command_version() {
     923void owl_command_version()
     924{
    906925  char buff[1024];
    907926
     
    10141033}
    10151034
    1016 char *owl_command_dump(int argc, char **argv, char *buff) {
     1035char *owl_command_dump(int argc, char **argv, char *buff)
     1036{
    10171037  if (argc!=2) {
    10181038    owl_function_makemsg("usage: dump <filename>");
     
    10241044}
    10251045
    1026 char *owl_command_next(int argc, char **argv, char *buff) {
     1046char *owl_command_next(int argc, char **argv, char *buff)
     1047{
    10271048  char *filter=NULL;
    10281049  int skip_deleted=0, last_if_none=0;
     
    10531074}
    10541075
    1055 char *owl_command_prev(int argc, char **argv, char *buff) {
     1076char *owl_command_prev(int argc, char **argv, char *buff)
     1077{
    10561078  char *filter=NULL;
    10571079  int skip_deleted=0, first_if_none=0;
     
    10821104}
    10831105
    1084 char *owl_command_smartnarrow(int argc, char **argv, char *buff) {
     1106char *owl_command_smartnarrow(int argc, char **argv, char *buff)
     1107{
    10851108  char *filtname = NULL;
    10861109
     
    10991122}
    11001123
    1101 char *owl_command_smartfilter(int argc, char **argv, char *buff) {
     1124char *owl_command_smartfilter(int argc, char **argv, char *buff)
     1125{
    11021126  char *filtname = NULL;
    11031127
     
    11121136}
    11131137
    1114 void owl_command_expunge() {
     1138void owl_command_expunge()
     1139{
    11151140  owl_function_expunge();
    11161141}
    11171142
    1118 void owl_command_first() {
     1143void owl_command_first()
     1144{
    11191145  owl_global_set_rightshift(&g, 0);
    11201146  owl_function_firstmsg();
    11211147}
    11221148
    1123 void owl_command_last() {
     1149void owl_command_last()
     1150{
    11241151  owl_function_lastmsg();
    11251152}
    11261153
    1127 void owl_command_resize() {
     1154void owl_command_resize()
     1155{
    11281156  owl_function_resize();
    11291157}
    11301158
    1131 void owl_command_redisplay() {
     1159void owl_command_redisplay()
     1160{
    11321161  owl_function_full_redisplay();
    11331162  owl_global_set_needrefresh(&g);
    11341163}
    11351164
    1136 void owl_command_shift_right() {
     1165void owl_command_shift_right()
     1166{
    11371167  owl_function_shift_right();
    11381168}
    11391169
    1140 void owl_command_shift_left() {
     1170void owl_command_shift_left()
     1171{
    11411172  owl_function_shift_left();
    11421173}
    11431174
    1144 void owl_command_unsuball() {
     1175void owl_command_unsuball()
     1176{
    11451177  owl_function_unsuball();
    11461178}
    11471179
    1148 char *owl_command_loadsubs(int argc, char **argv, char *buff) {
     1180char *owl_command_loadsubs(int argc, char **argv, char *buff)
     1181{
    11491182  if (argc == 2) {
    11501183    owl_function_loadsubs(argv[1]);
     
    11591192
    11601193
    1161 char *owl_command_loadloginsubs(int argc, char **argv, char *buff) {
     1194char *owl_command_loadloginsubs(int argc, char **argv, char *buff)
     1195{
    11621196  if (argc == 2) {
    11631197    owl_function_loadloginsubs(argv[1]);
     
    11711205}
    11721206
    1173 void owl_command_suspend() {
     1207void owl_command_suspend()
     1208{
    11741209  owl_function_suspend();
    11751210}
    11761211
    1177 char *owl_command_start_command(int argc, char **argv, char *buff) {
     1212char *owl_command_start_command(int argc, char **argv, char *buff)
     1213{
    11781214  buff = skiptokens(buff, 1);
    11791215  owl_function_start_command(buff);
    1180   return NULL;
    1181 }
    1182 
    1183 char *owl_command_zaway(int argc, char **argv, char *buff) {
    1184  
     1216  return(NULL);
     1217}
     1218
     1219char *owl_command_start_question(int argc, char **argv, char *buff)
     1220{
     1221  buff = skiptokens(buff, 1);
     1222  owl_function_start_question(buff);
     1223  return(NULL);
     1224}
     1225
     1226char *owl_command_zaway(int argc, char **argv, char *buff)
     1227{
    11851228  if ((argc==1) ||
    11861229      ((argc==2) && !strcmp(argv[1], "on"))) {
     
    12071250
    12081251
    1209 char *owl_command_set(int argc, char **argv, char *buff) {
     1252char *owl_command_set(int argc, char **argv, char *buff)
     1253{
    12101254  char *var, *val;
    12111255  int  silent=0;
     
    12371281}
    12381282
    1239 char *owl_command_unset(int argc, char **argv, char *buff) {
     1283char *owl_command_unset(int argc, char **argv, char *buff)
     1284{
    12401285  char *var, *val;
    12411286  int  silent=0;
     
    12561301}
    12571302
    1258 char *owl_command_print(int argc, char **argv, char *buff) {
     1303char *owl_command_print(int argc, char **argv, char *buff)
     1304{
    12591305  char *var;
    12601306  char valbuff[1024];
     
    12801326
    12811327
    1282 char *owl_command_exec(int argc, char **argv, char *buff) {
     1328char *owl_command_exec(int argc, char **argv, char *buff)
     1329{
    12831330  return owl_function_exec(argc, argv, buff, 0);
    12841331}
    12851332
    1286 char *owl_command_pexec(int argc, char **argv, char *buff) {
     1333char *owl_command_pexec(int argc, char **argv, char *buff)
     1334{
    12871335  return owl_function_exec(argc, argv, buff, 1);
    12881336}
    12891337
    1290 char *owl_command_aexec(int argc, char **argv, char *buff) {
     1338char *owl_command_aexec(int argc, char **argv, char *buff)
     1339{
    12911340  return owl_function_exec(argc, argv, buff, 2);
    12921341}
    12931342
    1294 char *owl_command_perl(int argc, char **argv, char *buff) {
     1343char *owl_command_perl(int argc, char **argv, char *buff)
     1344{
    12951345  return owl_function_perl(argc, argv, buff, 0);
    12961346}
    12971347
    1298 char *owl_command_pperl(int argc, char **argv, char *buff) {
     1348char *owl_command_pperl(int argc, char **argv, char *buff)
     1349{
    12991350  return owl_function_perl(argc, argv, buff, 1);
    13001351}
    13011352
    1302 char *owl_command_aperl(int argc, char **argv, char *buff) {
     1353char *owl_command_aperl(int argc, char **argv, char *buff)
     1354{
    13031355  return owl_function_perl(argc, argv, buff, 2);
    13041356}
    13051357
    1306 char *owl_command_multi(int argc, char **argv, char *buff) {
     1358char *owl_command_multi(int argc, char **argv, char *buff)
     1359{
    13071360  char *lastrv = NULL, *newbuff;
    13081361  char **commands;
     
    13381391
    13391392
    1340 char *owl_command_alias(int argc, char **argv, char *buff) {
     1393char *owl_command_alias(int argc, char **argv, char *buff)
     1394{
    13411395  if (argc < 3) {
    13421396    owl_function_makemsg("Invalid arguments to 'alias' command.");
     
    13491403
    13501404
    1351 char *owl_command_bindkey(int argc, char **argv, char *buff) {
     1405char *owl_command_bindkey(int argc, char **argv, char *buff)
     1406{
    13521407  owl_keymap *km;
    13531408  int ret;
     
    13721427}
    13731428
    1374 void owl_command_quit() {
     1429void owl_command_quit()
     1430{
    13751431  owl_function_quit();
    13761432}
    13771433
    1378 char *owl_command_debug(int argc, char **argv, char *buff) {
     1434char *owl_command_debug(int argc, char **argv, char *buff)
     1435{
    13791436  if (argc<2) {
    13801437    owl_function_makemsg("Need at least one argument to debug command");
     
    13911448}
    13921449
    1393 char *owl_command_term(int argc, char **argv, char *buff) {
     1450char *owl_command_term(int argc, char **argv, char *buff)
     1451{
    13941452  if (argc<2) {
    13951453    owl_function_makemsg("Need at least one argument to the term command");
     
    14071465}
    14081466
    1409 char *owl_command_zlog(int argc, char **argv, char *buff) {
     1467char *owl_command_zlog(int argc, char **argv, char *buff)
     1468{
    14101469  if ((argc<2) || (argc>3)) {
    14111470    owl_function_makemsg("Wrong number of arguments for zlog command");
     
    14311490
    14321491
    1433 void owl_command_zlog_out(void) {
     1492void owl_command_zlog_out(void)
     1493{
    14341494  owl_zephyr_zlog_out();
    14351495}
    14361496
    14371497
    1438 char *owl_command_subscribe(int argc, char **argv, char *buff) {
     1498char *owl_command_subscribe(int argc, char **argv, char *buff)
     1499{
    14391500  char *recip="";
    14401501  int temp=0;
     
    14761537
    14771538
    1478 char *owl_command_unsubscribe(int argc, char **argv, char *buff) {
     1539char *owl_command_unsubscribe(int argc, char **argv, char *buff)
     1540{
    14791541  char *recip="";
    14801542  int temp=0;
     
    15151577}
    15161578
    1517 char *owl_command_echo(int argc, char **argv, char *buff) {
     1579char *owl_command_echo(int argc, char **argv, char *buff)
     1580{
    15181581  buff = skiptokens(buff, 1);
    15191582  owl_function_popless_text(buff);
     
    15211584}
    15221585
    1523 void owl_command_getsubs() {
     1586void owl_command_getsubs(void)
     1587{
    15241588  owl_function_getsubs();
    15251589}
    15261590
    1527 void owl_command_status() {
     1591void owl_command_status(void)
     1592{
    15281593  owl_function_status();
    15291594}
    15301595
    1531 char *owl_command_zwrite(int argc, char **argv, char *buff) {
     1596char *owl_command_zwrite(int argc, char **argv, char *buff)
     1597{
    15321598  owl_zwrite z;
    15331599
     
    15491615}
    15501616
    1551 char *owl_command_aimwrite(int argc, char **argv, char *buff) {
     1617char *owl_command_aimwrite(int argc, char **argv, char *buff)
     1618{
    15521619  char *newbuff;
    15531620  int i, j;
     
    15771644}
    15781645
    1579 char *owl_command_zcrypt(int argc, char **argv, char *buff) {
     1646char *owl_command_zcrypt(int argc, char **argv, char *buff)
     1647{
    15801648  owl_zwrite z;
    15811649
     
    15981666}
    15991667
    1600 char *owl_command_reply(int argc, char **argv, char *buff) {
     1668char *owl_command_reply(int argc, char **argv, char *buff)
     1669{
    16011670  int edit=0;
    16021671 
     
    16231692}
    16241693
    1625 char *owl_command_filter(int argc, char **argv, char *buff) {
     1694char *owl_command_filter(int argc, char **argv, char *buff)
     1695{
    16261696  owl_function_create_filter(argc, argv);
    16271697  return NULL;
    16281698}
    16291699
    1630 char *owl_command_zlocate(int argc, char **argv, char *buff) {
     1700char *owl_command_zlocate(int argc, char **argv, char *buff)
     1701{
    16311702  int auth;
    16321703 
     
    16541725}
    16551726
    1656 char *owl_command_view(int argc, char **argv, char *buff) {
     1727char *owl_command_view(int argc, char **argv, char *buff)
     1728{
    16571729
    16581730  /* Backwards compatability has made this kind of complicated:
     
    17381810
    17391811
    1740 char *owl_command_show(int argc, char **argv, char *buff) {
    1741 
     1812char *owl_command_show(int argc, char **argv, char *buff)
     1813{
    17421814  if (argc<2) {
    17431815    owl_function_help_for_command("show");
     
    17951867}
    17961868
    1797 char *owl_command_viewclass(int argc, char **argv, char *buff) {
     1869char *owl_command_viewclass(int argc, char **argv, char *buff)
     1870{
    17981871  char *filtname;
    17991872  if (argc!=2) {
     
    18071880}
    18081881
    1809 char *owl_command_viewuser(int argc, char **argv, char *buff) {
     1882char *owl_command_viewuser(int argc, char **argv, char *buff)
     1883{
    18101884  char *filtname;
    18111885  if (argc!=2) {
     
    18201894
    18211895
    1822 void owl_command_pop_message(void) {
     1896void owl_command_pop_message(void)
     1897{
    18231898  owl_function_curmsg_to_popwin();
    18241899}
    18251900
    1826 void owl_command_openurl(void) {
     1901void owl_command_openurl(void)
     1902{
    18271903  owl_function_openurl();
    18281904}
    18291905
    1830 char *owl_command_delete(int argc, char **argv, char *buff) {
     1906char *owl_command_delete(int argc, char **argv, char *buff)
     1907{
    18311908  int move_after = 1;
    18321909
     
    18611938}
    18621939
    1863 char *owl_command_undelete(int argc, char **argv, char *buff) {
     1940char *owl_command_undelete(int argc, char **argv, char *buff)
     1941{
    18641942  int move_after = 1;
    18651943
     
    18891967}
    18901968
    1891 void owl_command_beep() {
     1969void owl_command_beep()
     1970{
    18921971  owl_function_beep();
    18931972}
    18941973
    1895 char *owl_command_colorview(int argc, char **argv, char *buff) {
     1974char *owl_command_colorview(int argc, char **argv, char *buff)
     1975{
    18961976  if (argc!=2) {
    18971977    owl_function_makemsg("Wrong number of arguments to colorview command");
     
    19021982}
    19031983
    1904 char *owl_command_zpunt(int argc, char **argv, char *buff) {
     1984char *owl_command_zpunt(int argc, char **argv, char *buff)
     1985{
    19051986  owl_command_zpunt_and_zunpunt(argc, argv, 0);
    19061987  return NULL;
    19071988}
    19081989
    1909 char *owl_command_zunpunt(int argc, char **argv, char *buff) {
     1990char *owl_command_zunpunt(int argc, char **argv, char *buff)
     1991{
    19101992  owl_command_zpunt_and_zunpunt(argc, argv, 1);
    19111993  return NULL;
     
    19131995
    19141996
    1915 void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type) {
     1997void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type)
     1998{
    19161999  /* if type==0 then zpunt
    19172000   * if type==1 then zunpunt
     
    19492032}
    19502033
    1951 char *owl_command_smartzpunt(int argc, char **argv, char *buff) {
     2034char *owl_command_smartzpunt(int argc, char **argv, char *buff)
     2035{
    19522036  if (argc == 1) {
    19532037    owl_function_smartzpunt(0);
     
    19602044}
    19612045
    1962 char *owl_command_getview(int argc, char **argv, char *buff) {
     2046char *owl_command_getview(int argc, char **argv, char *buff)
     2047{
    19632048  char *filtname;
    19642049  if (argc != 1) {
     
    19712056}
    19722057
    1973 char *owl_command_getvar(int argc, char **argv, char *buff) {
     2058char *owl_command_getvar(int argc, char **argv, char *buff)
     2059{
    19742060  char tmpbuff[1024];
    19752061  if (argc != 2) {
     
    19842070}
    19852071
    1986 char *owl_command_search(int argc, char **argv, char *buff) {
     2072char *owl_command_search(int argc, char **argv, char *buff)
     2073{
    19872074  int direction;
    19882075  char *buffstart;
     
    20042091}
    20052092
    2006 char *owl_command_aimlogin(int argc, char **argv, char *buff) {
     2093char *owl_command_aimlogin(int argc, char **argv, char *buff)
     2094{
    20072095  int ret;
    20082096 
     
    20312119}
    20322120
    2033 char *owl_command_aimlogout(int argc, char **argv, char *buff) {
     2121char *owl_command_aimlogout(int argc, char **argv, char *buff)
     2122{
    20342123  /* clear the buddylist */
    20352124  owl_buddylist_clear(owl_global_get_buddylist(&g));
     
    20432132/*********************************************************************/
    20442133
    2045 void owl_command_edit_cancel(owl_editwin *e) {
     2134void owl_command_edit_cancel(owl_editwin *e)
     2135{
    20462136  owl_history *hist;
    20472137
     
    20572147  owl_global_set_typwin_inactive(&g);
    20582148  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
    2059 }
    2060 
    2061 void owl_command_edit_history_prev(owl_editwin *e) {
     2149
     2150  owl_function_activate_keymap("recv");
     2151}
     2152
     2153void owl_command_edit_history_prev(owl_editwin *e)
     2154{
    20622155  owl_history *hist;
    20632156  char *ptr;
     
    20792172}
    20802173
    2081 void owl_command_edit_history_next(owl_editwin *e) {
     2174void owl_command_edit_history_next(owl_editwin *e)
     2175{
    20822176  owl_history *hist;
    20832177  char *ptr;
     
    20952189}
    20962190
    2097 char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff) {
     2191char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff)
     2192{
    20982193  buff = skiptokens(buff, 1);
    20992194  owl_editwin_insert_string(e, buff);
     
    21032198}
    21042199
    2105 void owl_command_editline_done(owl_editwin *e) {
     2200void owl_command_editline_done(owl_editwin *e)
     2201{
    21062202  owl_history *hist=owl_editwin_get_history(e);
    21072203  char *rv, *cmd;
     
    21242220}
    21252221
    2126 void owl_command_editmulti_done(owl_editwin *e) {
     2222
     2223void owl_command_editresponse_done(owl_editwin *e)
     2224{
     2225  owl_global_set_response(&g, owl_editwin_get_text(e));
     2226
     2227  owl_global_set_typwin_inactive(&g);
     2228  owl_editwin_fullclear(e);
     2229  wnoutrefresh(owl_editwin_get_curswin(e));
     2230  owl_global_set_needrefresh(&g);
     2231
     2232  owl_function_makemsg("Thank you");
     2233}
     2234
     2235
     2236void owl_command_editmulti_done(owl_editwin *e)
     2237{
    21272238  owl_history *hist=owl_editwin_get_history(e);
    21282239
     
    21382249}
    21392250
    2140 void owl_command_editmulti_done_or_delete(owl_editwin *e) {
     2251void owl_command_editmulti_done_or_delete(owl_editwin *e)
     2252{
    21412253  if (owl_editwin_is_at_end(e)) {
    21422254    owl_command_editmulti_done(e);
     
    21512263/*********************************************************************/
    21522264
    2153 void owl_command_popless_quit(owl_viewwin *vw) {
     2265void owl_command_popless_quit(owl_viewwin *vw)
     2266{
    21542267  owl_popwin_close(owl_global_get_popwin(&g));
    21552268  owl_viewwin_free(vw);
  • context.c

    r53f421b rcf83b7a  
    9393}
    9494
     95void owl_context_set_editresponse(owl_context *ctx, owl_editwin *ew)
     96{
     97  ctx->data = (void*)ew;
     98  SET_ACTIVE(ctx, OWL_CTX_EDITRESPONSE);
     99}
     100
  • editwin.c

    rc9334b1 rcf83b7a  
    99#define INCR 5000
    1010
     11/* initialize the editwin e.
     12 * 'win' is an already initialzed curses window that will be used by editwin
     13 */
    1114void owl_editwin_init(owl_editwin *e, WINDOW *win, int winlines, int wincols, int style, owl_history *hist)
    1215{
    13   /* initialize the editwin e.
    14    * 'win' is an already initialzed curses window that will be used by editwin
    15    */
    1616  e->buff=owl_malloc(INCR); 
    1717  e->buff[0]='\0';
     
    2424  e->winlines=winlines;
    2525  e->wincols=wincols;
    26   e->fillcol=owl_editwin_limit_maxcols(wincols-1,
    27                                        owl_global_get_edit_maxfillcols(&g));
    28   e->wrapcol=owl_editwin_limit_maxcols(wincols-1,
    29                                        owl_global_get_edit_maxwrapcols(&g));
     26  e->fillcol=owl_editwin_limit_maxcols(wincols-1, owl_global_get_edit_maxfillcols(&g));
     27  e->wrapcol=owl_editwin_limit_maxcols(wincols-1, owl_global_get_edit_maxwrapcols(&g));
    3028  e->curswin=win;
    3129  e->style=style;
     
    4543  e->winlines=winlines;
    4644  e->wincols=wincols;
    47   e->fillcol=owl_editwin_limit_maxcols(wincols-1,
    48                                        owl_global_get_edit_maxfillcols(&g));
    49   e->wrapcol=owl_editwin_limit_maxcols(wincols-1,
    50                                        owl_global_get_edit_maxwrapcols(&g));
     45  e->fillcol=owl_editwin_limit_maxcols(wincols-1, owl_global_get_edit_maxfillcols(&g));
     46  e->wrapcol=owl_editwin_limit_maxcols(wincols-1, owl_global_get_edit_maxwrapcols(&g));
    5147}
    5248
     
    205201 
    206202  char *ptr1, *ptr2, *ptr3, *buff;
    207   int i, j;
     203  int i;
    208204
    209205  werase(e->curswin);
     
    855851}
    856852
    857 /* returns if only whitespace remains */
     853/* returns true if only whitespace remains */
    858854int owl_editwin_is_at_end(owl_editwin *e)
    859855{
  • functions.c

    r5bb6c21 rcf83b7a  
    19221922  }
    19231923  owl_editwin_redisplay(tw, 0);
     1924
     1925  owl_context_set_editline(owl_global_get_context(&g), tw);
     1926  owl_function_activate_keymap("editline");
     1927   
     1928}
     1929
     1930void owl_function_start_question(char *line)
     1931{
     1932  owl_editwin *tw;
     1933
     1934  tw=owl_global_get_typwin(&g);
     1935  owl_global_set_typwin_active(&g);
     1936  owl_editwin_new_style(tw, OWL_EDITWIN_STYLE_ONELINE, owl_global_get_cmd_history(&g));
     1937
     1938  owl_editwin_set_locktext(tw, line);
     1939  owl_global_set_needrefresh(&g);
     1940
     1941  owl_editwin_redisplay(tw, 0);
     1942
     1943  owl_context_set_editresponse(owl_global_get_context(&g), tw);
     1944  owl_function_activate_keymap("editresponse");
    19241945}
    19251946
  • global.c

    r591e6aa7 rcf83b7a  
    9696  owl_timer_create_countdown(&(g->aim_ignorelogin_timer), 0);
    9797  owl_buddylist_init(&(g->buddylist));
     98  g->response=NULL;
    9899}
    99100
     
    762763}
    763764
    764 void owl_global_add_style(owl_global *g, owl_style *s) {
     765void owl_global_add_style(owl_global *g, owl_style *s)
     766{
    765767  owl_list_append_element(&(g->stylelist), s);
    766768}
     769
     770char *owl_global_get_response(owl_global *g)
     771{
     772  if (g->response==NULL) return("");
     773  return(g->response);
     774}
     775
     776void owl_global_set_response(owl_global *g, char *resp)
     777{
     778  if (g->response) owl_free(g->response);
     779  g->response=resp;
     780}
  • keybinding.c

    r1aee7d9 rcf83b7a  
    1414
    1515/* sets up a new keybinding for a command */
    16 int owl_keybinding_init(owl_keybinding *kb, char *keyseq, char *command, void (*function_fn)(void), char *desc) {
     16int owl_keybinding_init(owl_keybinding *kb, char *keyseq, char *command, void (*function_fn)(void), char *desc)
     17{
    1718  char **ktokens;
    1819  int    nktokens, i;
     
    5253
    5354/* Releases data associated with a keybinding */
    54 void owl_keybinding_free(owl_keybinding *kb) {
     55void owl_keybinding_free(owl_keybinding *kb)
     56{
    5557  if (kb->j) owl_free(kb->j);
    5658  if (kb->desc) owl_free(kb->desc);
     
    5961
    6062/* Releases data associated with a keybinding, and the kb itself */
    61 void owl_keybinding_free_all(owl_keybinding *kb) {
     63void owl_keybinding_free_all(owl_keybinding *kb)
     64{
    6265  owl_keybinding_free(kb);
    6366  owl_free(kb);
     
    6568
    6669/* executes a keybinding */
    67 void owl_keybinding_execute(owl_keybinding *kb, int j) {
     70void owl_keybinding_execute(owl_keybinding *kb, int j)
     71{
    6872  if (kb->type == OWL_KEYBINDING_COMMAND && kb->command) {
    6973    owl_function_command_norv(kb->command);
     
    7478
    7579/* returns 0 on success */
    76 int owl_keybinding_stack_tostring(int *j, char *buff, int bufflen) {
     80int owl_keybinding_stack_tostring(int *j, char *buff, int bufflen)
     81{
    7782  char *pos = buff;
    7883  int   rem = bufflen;
     
    9095
    9196/* returns 0 on success */
    92 int owl_keybinding_tostring(owl_keybinding *kb, char *buff, int bufflen) {
     97int owl_keybinding_tostring(owl_keybinding *kb, char *buff, int bufflen)
     98{
    9399  return owl_keybinding_stack_tostring(kb->j, buff, bufflen);
    94100}
    95101
    96 char *owl_keybinding_get_desc(owl_keybinding *kb) {
     102char *owl_keybinding_get_desc(owl_keybinding *kb)
     103{
    97104  return kb->desc;
    98105}
    99106
    100107/* returns 0 on no match, 1 on subset match, and 2 on complete match */
    101 int owl_keybinding_match(owl_keybinding *kb, int *kpstack) {
     108int owl_keybinding_match(owl_keybinding *kb, int *kpstack)
     109{
    102110  int *kbstack = kb->j;
    103111 
     
    118126
    119127/* returns 1 if keypress sequence is the same */
    120 int owl_keybinding_equal(owl_keybinding *kb1, owl_keybinding *kb2) {
     128int owl_keybinding_equal(owl_keybinding *kb1, owl_keybinding *kb2)
     129{
    121130  int *j1 = kb1->j;
    122131  int *j2 = kb2->j;
  • keymap.c

    rf87c490 rcf83b7a  
    55
    66/* returns 0 on success */
    7 int owl_keymap_init(owl_keymap *km, char *name, char *desc, void (*default_fn)(int), void (*prealways_fn)(int), void (*postalways_fn)(int)) {
     7int owl_keymap_init(owl_keymap *km, char *name, char *desc, void (*default_fn)(int), void (*prealways_fn)(int), void (*postalways_fn)(int))
     8{
    89  if (!name || !desc) return(-1);
    910  if ((km->name = owl_strdup(name)) == NULL) return(-1);
     
    1819
    1920/* note that this will free the memory for the bindings! */
    20 void owl_keymap_free(owl_keymap *km) {
     21void owl_keymap_free(owl_keymap *km)
     22{
    2123  owl_free(km->name);
    2224  owl_free(km->desc);
     
    2426}
    2527
    26 void owl_keymap_set_submap(owl_keymap *km, owl_keymap *submap) {
     28void owl_keymap_set_submap(owl_keymap *km, owl_keymap *submap)
     29{
    2730  km->submap = submap;
    2831}
    2932
    3033/* creates and adds a key binding */
    31 int owl_keymap_create_binding(owl_keymap *km, char *keyseq, char *command, void (*function_fn)(void), char *desc) {
     34int owl_keymap_create_binding(owl_keymap *km, char *keyseq, char *command, void (*function_fn)(void), char *desc)
     35{
    3236  owl_keybinding *kb, *curkb;
    3337  int i;
     
    5256
    5357/* returns a summary line describing this keymap.  the caller must free. */
    54 char *owl_keymap_summary(owl_keymap *km) {
     58char *owl_keymap_summary(owl_keymap *km)
     59{
    5560  char *s;
    5661  int slen;
     
    6368
    6469/* Appends details about the keymap to fm */
    65 void owl_keymap_get_details(owl_keymap *km, owl_fmtext *fm) {
     70void owl_keymap_get_details(owl_keymap *km, owl_fmtext *fm)
     71{
    6672  int i, nbindings;
    6773  owl_keybinding *kb;
     
    131137/* NOTE: keyhandler has private access to the internals of keymap */
    132138
    133 int owl_keyhandler_init(owl_keyhandler *kh) {
     139int owl_keyhandler_init(owl_keyhandler *kh)
     140{
    134141  if (0 != owl_dict_create(&kh->keymaps)) return(-1);
    135142  kh->active = NULL;
     
    139146
    140147/* adds a new keymap */
    141 void owl_keyhandler_add_keymap(owl_keyhandler *kh, owl_keymap *km) {
     148void owl_keyhandler_add_keymap(owl_keyhandler *kh, owl_keymap *km)
     149{
    142150  owl_dict_insert_element(&kh->keymaps, km->name, km, NULL);
    143151}
    144152
    145 owl_keymap *owl_keyhandler_create_and_add_keymap(owl_keyhandler *kh, char *name, char *desc, void (*default_fn)(int), void (*prealways_fn)(int), void (*postalways_fn)(int)) {
     153owl_keymap *owl_keyhandler_create_and_add_keymap(owl_keyhandler *kh, char *name, char *desc, void (*default_fn)(int), void (*prealways_fn)(int), void (*postalways_fn)(int))
     154{
    146155  owl_keymap *km;
    147156  km = (owl_keymap*)owl_malloc(sizeof(owl_keymap));
     
    153162
    154163/* resets state and clears out key stack */
    155 void owl_keyhandler_reset(owl_keyhandler *kh) {
     164void owl_keyhandler_reset(owl_keyhandler *kh)
     165{
    156166  kh->in_esc = 0;
    157167  memset(kh->kpstack, 0, (OWL_KEYMAP_MAXSTACK+1)*sizeof(int));
     
    159169}
    160170
    161 owl_keymap *owl_keyhandler_get_keymap(owl_keyhandler *kh, char *mapname) {
     171owl_keymap *owl_keyhandler_get_keymap(owl_keyhandler *kh, char *mapname)
     172{
    162173  return (owl_keymap*)owl_dict_find_element(&kh->keymaps, mapname);
    163174}
    164175
    165176/* free the list with owl_cmddict_namelist_free */
    166 void owl_keyhandler_get_keymap_names(owl_keyhandler *kh, owl_list *l) {
     177void owl_keyhandler_get_keymap_names(owl_keyhandler *kh, owl_list *l)
     178{
    167179  owl_dict_get_keys(&kh->keymaps, l);
    168180}
    169181
    170 void owl_keyhandler_keymap_namelist_free(owl_list *l) {
     182void owl_keyhandler_keymap_namelist_free(owl_list *l)
     183{
    171184  owl_list_free_all(l, owl_free);
    172185}
     
    176189/* sets the active keymap, which will also reset any key state.
    177190 * returns the new keymap, or NULL on failure. */
    178 owl_keymap *owl_keyhandler_activate(owl_keyhandler *kh, char *mapname) {
     191owl_keymap *owl_keyhandler_activate(owl_keyhandler *kh, char *mapname)
     192{
    179193  owl_keymap *km;
    180194  if (kh->active && !strcmp(mapname, kh->active->name)) return(kh->active);
     
    188202/* processes a keypress.  returns 0 if the keypress was handled,
    189203 * 1 if not handled, -1 on error, and -2 if j==ERR. */
    190 int owl_keyhandler_process(owl_keyhandler *kh, int j) {
     204int owl_keyhandler_process(owl_keyhandler *kh, int j)
     205{
    191206  owl_keymap     *km;
    192207  owl_keybinding *kb;
     
    272287}
    273288
    274 void owl_keyhandler_invalidkey(owl_keyhandler *kh) {
     289void owl_keyhandler_invalidkey(owl_keyhandler *kh)
     290{
    275291    char kbbuff[500];
    276292    owl_keybinding_stack_tostring(kh->kpstack, kbbuff, 500);
  • keypress.c

    rf87c490 rcf83b7a  
    131131
    132132/* returns 0 on success */
    133 int owl_keypress_tostring(int j, int esc, char *buff, int bufflen) {
     133int owl_keypress_tostring(int j, int esc, char *buff, int bufflen)
     134{
    134135  char kb[64], kb2[2];
    135136  struct _owl_keypress_specialmap *sm;
     
    173174
    174175/* returns ERR on failure, else a keycode */
    175 int owl_keypress_fromstring(char *kb) {
     176int owl_keypress_fromstring(char *kb)
     177{
    176178  struct _owl_keypress_specialmap *sm;
    177179  int ismeta=0, isctrl=0;
  • keys.c

    rc3ab155 rcf83b7a  
    125125  BIND_CMD("LF",          "editline:done", "executes the command");
    126126  BIND_CMD("CR",          "editline:done", "executes the command");
     127
     128 
     129  /****************************************************************/
     130  /**************************** EDITRESPONSE **********************/
     131  /****************************************************************/
     132
     133  km_ew_onel = km = owl_keyhandler_create_and_add_keymap(kh, "editresponse",
     134       "Single-line response to question",
     135       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
     136  owl_keymap_set_submap(km_ew_onel, km_editwin);
     137
     138  BIND_CMD("C-u",         "edit:delete-all", "Clears the entire line");
     139
     140  BIND_CMD("LF",          "editresponse:done", "executes the command");
     141  BIND_CMD("CR",          "editresponse:done", "executes the command");
    127142
    128143
  • owl.c

    re7cc1c3 rcf83b7a  
    488488    } else if (owl_global_is_typwin_active(&g)
    489489               && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) {
     490      /*
    490491      owl_context_set_editline(owl_global_get_context(&g), tw);
    491492      owl_function_activate_keymap("editline");
     493      */
    492494    } else if (owl_global_is_typwin_active(&g)
    493495               && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) {
  • owl.h

    rc9334b1 rcf83b7a  
    1717static const char owl_h_fileIdent[] = "$Id$";
    1818
    19 #define OWL_VERSION         2.0.6-pre-1
    20 #define OWL_VERSION_STRING "2.0.6-pre-1"
     19#define OWL_VERSION         2.0.6-pre-2
     20#define OWL_VERSION_STRING "2.0.6-pre-2"
    2121
    2222#define OWL_DEBUG 0
     
    9191#define OWL_CTX_RECV         0x0100
    9292#define OWL_CTX_TYPWIN       0xf000
    93 #define OWL_CTX_EDIT         0x3000
     93#define OWL_CTX_EDIT         0x7000
    9494#define OWL_CTX_EDITLINE     0x1000
    9595#define OWL_CTX_EDITMULTI    0x2000
     96#define OWL_CTX_EDITRESPONSE 0x4000
    9697
    9798#define OWL_USERCLUE_NONE       0
     
    444445  owl_list messagequeue;    /* for queueing up aim and other messages */
    445446  owl_list stylelist;       /* global list of available styles */
     447  char *response;           /* response to the last question asked */
    446448} owl_global;
    447449
Note: See TracChangeset for help on using the changeset viewer.