Esempio n. 1
0
int add_help(int x, int y)
{
  if (x>=10)
    return y;
  else
    return add_help(x+1, y+ x+1);
}
Esempio n. 2
0
static int help_key(struct _select_def *conf, int key)
{

	switch(key){
	case 's':
	{
		clear();
		move(5,0);
		prints("\033[1;32m提示:\033[m 在帮助主界面中按f可以取消搜索显示当前所有的帮助");
		getdata(6,0, "请输入搜索内容:", help_search, 21, DOECHO, NULL, false);
		if( help_search[0] ){
			conf->pos = 1;
			conf->page_pos = 1;
			return SHOW_DIRCHANGE;
		}
		return SHOW_REFRESH;
	}
	case 'a':
		if( HAS_PERM(getCurrentUser(), PERM_SYSOP) ){
			if( add_help(*((int *)conf->arg), -1) < 0 )
				return SHOW_REFRESH;
			return SHOW_DIRCHANGE;
		}
	case 'e':
		if( HAS_PERM(getCurrentUser(), PERM_SYSOP) ){
			if( add_help(*((int *)conf->arg), conf->pos - conf->page_pos) < 0 )
				return SHOW_REFRESH;
			return SHOW_DIRCHANGE;
		}
	case 'd':
		if( HAS_PERM(getCurrentUser(), PERM_SYSOP) ){
			if( del_help(s_help[conf->pos-conf->page_pos].id) < 0 )
				return SHOW_REFRESH;
			return SHOW_DIRCHANGE;
		}
	case 'f':
		if( help_search[0] ){
			help_search[0]=0;
			return SHOW_DIRCHANGE;
		}
		return SHOW_CONTINUE;
	default:
		break;
	}

	return SHOW_CONTINUE;
}
Esempio n. 3
0
void save_help_olc(HELP_OLC *data) {
  // first, remove our old helpfile from disc
  LIST    *kwds = parse_keywords(data->old_keywords);
  char *primary = listGet(kwds, 0);
  if(primary && *primary)
    remove_help(primary);
  deleteListWith(kwds, free);

  // now, add our new one
  add_help(data->keywords, bufferString(data->info), data->user_groups,
	   data->related, TRUE);
}
Esempio n. 4
0
void register_cmd_run(void) {
  char* _help;
  /*options*/
  run_options=register_runtime_options(run_options);
  run_options=add_command(run_options,"",NULL,cmd_run_star,OPT_SHOW_NONE,1,NULL,NULL);
  /*run_options=add_command(run_options,"version",NULL,cmd_run_version,OPT_SHOW_NONE,0,NULL,NULL);*/
  run_options=nreverse(run_options);

  /*commands*/
  top_options=add_command(top_options,""         ,NULL,cmd_script_frontend,OPT_SHOW_NONE,1,"Run lisp environment then quit (default)",NULL);
  top_commands=add_command(top_commands,ROS_RUN_REPL ,NULL,cmd_run,OPT_SHOW_HELP,1,"Run repl",NULL);
  top_commands=add_command(top_commands,"*"         ,NULL,cmd_script_frontend,OPT_SHOW_NONE,1,"Run lisp environment then quit (default)",NULL);

  _help=cat("Usage: ",argv_orig[0]," [OPTIONS] "ROS_RUN_REPL" [OPTIONS] [-- implementation-native-options...]\n\n",NULL);
  top_helps=add_help(top_helps,ROS_RUN_REPL,_help,run_commands,run_options,NULL,NULL,NULL);
  s(_help);
  _help=cat("Usage: ",argv_orig[0]," [OPTIONS] [--] script-file arguments...\n\n",
            NULL);
  s(_help);
}
Esempio n. 5
0
void register_cmd_install(void) {
  top_commands=add_command(top_commands,"install"    ,NULL,cmd_install,1,1,"Install a given implementation or a system for "PACKAGE" environment",NULL);
  top_helps=add_help(top_helps,"install","",(LVal)NULL,(LVal)NULL,NULL,NULL,install_help);
}
Esempio n. 6
0
int newhelp_loop(int mode)
{

    struct _select_def group_conf;
    int i;
    POINT *pts;

    if (mode < 0 || mode > NUMHELPMODE)
        return -1;

    help_search[0]=0;
    bzero(&group_conf,sizeof(struct _select_def));

    s_help = (struct helps *)malloc(sizeof(struct helps) * BBS_PAGESIZE);
    if (s_help == NULL)
        return -1;
    bzero(s_help, sizeof(struct helps)*BBS_PAGESIZE);

    pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE);
    for (i = 0; i < BBS_PAGESIZE; i++) {
        pts[i].x = 2;
        pts[i].y = i + 3;
    }
    group_conf.item_per_page = BBS_PAGESIZE;
    group_conf.arg = & mode;
    group_conf.flag = LF_VSCROLL | LF_BELL | LF_MULTIPAGE | LF_LOOP;
    group_conf.prompt = "◆";
    group_conf.item_pos = pts;
    group_conf.title_pos.x = 0;
    group_conf.title_pos.y = 0;
    group_conf.pos=1;
    group_conf.page_pos=1;

    group_conf.on_select = help_select;
    group_conf.show_data = help_show;
    group_conf.pre_key_command = help_prekey;
    group_conf.show_title = help_refresh;
    group_conf.get_data = help_getdata;
    group_conf.key_command = help_key;

    group_conf.item_count = count_help(mode);

    if (group_conf.item_count<=0) {
        free(pts);
        free(s_help);
        if (HAS_PERM(getCurrentUser(), PERM_SYSOP)) {
            add_help(mode, -1);
        } else {
            clear();
            prints("现在没有该状态下帮助,或者系统出错\n");
            pressanykey();
        }
        return -1;
    }

    i = get_help(s_help, mode, 0, BBS_PAGESIZE);

    if (i<=0) {
        free(pts);
        free(s_help);
        clear();
        prints("现在没有该状态下帮助,或者系统出错\n");
        pressanykey();
        return -1;
    }

    help_num = i;
    clear();
    list_select_loop(&group_conf);

    for (i=0; i< help_num; i++) {
        if (s_help[i].content) free(s_help[i].content);
    }
    free(pts);
    free(s_help);
    s_help=NULL;
    help_num=0;

    return 1;

}
Esempio n. 7
0
void register_cmd_config(void) {
  top_commands=add_command(top_commands,"config"  ,NULL,cmd_config,1,1,"Get and set options",NULL);
  top_helps=add_help(top_helps,"config","",(LVal)NULL,(LVal)NULL,NULL,NULL,config_help);
}
Esempio n. 8
0
int add_tail(int x)
{
  return add_help(1, 1);
}