コード例 #1
0
static void
notif_timer_cb(struct rtc_ctx *ctx)
{
        void *val = &motion_ctx.motion_value;
	uint16_t len = sizeof(motion_ctx.motion_value);
        motion_read(&motion_ctx, &motion_ctx.motion, &val, &len);
        simble_srv_char_notify(&motion_ctx.motion, false, len,
                &motion_ctx.motion_value);
}
コード例 #2
0
static
const motion *motion_read_or_visual(unsigned *repeat, bool apply_maps)
{
	window *win = windows_cur();
	if(win->ui_mode & UI_VISUAL_ANY){
		static motion visual = {
			.func = m_visual,
			.arg.phow = &visual.how
		};

		*repeat = 0;

		return &visual;
	}

	return motion_read(repeat, apply_maps);
}

void k_prompt_cmd(const keyarg_u *arg, unsigned repeat, const int from_ch)
{
	char *initial = NULL;
	char initial_buf[32];

	window *win = windows_cur();

	if(win->ui_mode & UI_VISUAL_ANY){
		int y1 = 1 + win->ui_pos->y;
		int y2 = 1 + window_uipos_alt(win)->y;

		if(y2 < y1){
			int tmp = y1;
			y1 = y2;
			y2 = tmp;
		}

		snprintf(initial_buf, sizeof initial_buf, "%d,%d", y1, y2);

		initial = initial_buf;
	}

	char *const cmd = prompt(from_ch, initial);

	if(!cmd)
		goto cancel_cmd;

	const cmd_t *cmd_f;
	char **argv;
	int argc;
	bool force;
	struct range rstore, *range = &rstore;

	if(parse_ranged_cmd(
			cmd,
			&cmd_f,
			&argv, &argc,
			&force, &range))
	{
		cmd_dispatch(cmd_f, argc, argv, force, range);
	}
	else
	{
		ui_err("unknown command %s", cmd);
	}

	free_argv(argv, argc);
cancel_cmd:
	free(cmd);
}