Example #1
0
File: re.c Project: slewsys/ed
/* get_matching_node_addr: Return the address of the next line
   matching a pattern in a given direction. Wrap around begin/end of
   editor buffer if necessary. */
int
get_matching_node_address (const regex_t *re, int dir, off_t *addr,
                           ed_buffer_t *ed)
{
  regmatch_t rm[1];
  ed_line_node_t *lp;
  char *s;

  *addr = ed->state->dot;
  if (!re)
    return ERR;
  do
    {
      if ((*addr = (dir ? INC_MOD (*addr, ed->state->lines)
                    : DEC_MOD (*addr, ed->state->lines))))
        {
          lp = get_line_node (*addr, ed);
          if (!(s = get_buffer_line (lp, ed)))
            return ERR;
#ifdef REG_STARTEND
          rm->rm_so = 0;
          rm->rm_eo = lp->len;
          if (!regexec (re, s, 0, rm, REG_STARTEND))
#else
          if (ed->state->is_binary)
            NUL_TO_NEWLINE (s, lp->len);
          if (!regexec (re, s, 0, NULL, 0))
#endif  /* !defined (REG_STARTEND) */
            return 0;
        }
    }
  while (*addr != ed->state->dot);
  ed->exec->err = _("No match");
  return ERR;
}
Example #2
0
File: app.c Project: Foda/pluto-fw
static void main(uint8_t view, const app_t *app, svc_main_proc_event_t event) {
	hal_lcd_clear();
	if(event & SVC_MAIN_PROC_EVENT_KEY_UP) {
		INC_MOD(PRIV(app)->item_current, svc_melodies_n+1);
	}
	else if (event & SVC_MAIN_PROC_EVENT_KEY_DOWN) {
		DEC_MOD(PRIV(app)->item_current, svc_melodies_n+1);
	}
	else if (event & SVC_MAIN_PROC_EVENT_KEY_ENTER_LONG) {
		app_exit();
	}
	svc_lcd_puts(8, "pl");
	if(PRIV(app)->item_current == svc_melodies_n) {
		svc_lcd_puts(0, "----up");
		if(event & SVC_MAIN_PROC_EVENT_KEY_ENTER) {
			PRIV(app)->item_current = 0;
			app_exit();
		}
	}
	else {
		svc_lcd_puts(0, " pla");
		svc_lcd_puti(4, 2, PRIV(app)->item_current);
		if(event & SVC_MAIN_PROC_EVENT_KEY_ENTER) {
			svc_melody_play(PRIV(app)->item_current);
		}
	}
	
}
Example #3
0
void app_app_conf_debug_main(uint8_t view, const app_t *app, svc_main_proc_event_t event) {
	hal_lcd_clear();
	if(event & SVC_MAIN_PROC_EVENT_KEY_UP) {
		INC_MOD(PRIV(app)->debug_item_current, HAL_DEBUG_N+1);
	}
	else if (event & SVC_MAIN_PROC_EVENT_KEY_DOWN) {
		DEC_MOD(PRIV(app)->debug_item_current, HAL_DEBUG_N+1);
	}
	else if (event & SVC_MAIN_PROC_EVENT_KEY_ENTER_LONG) {
		app_set_view(app, 0);
		PRIV(app)->debug_item_current = 0;
	}
	else if(event & SVC_MAIN_PROC_EVENT_KEY_ENTER) {
		PRIV(app)->debug_value = hal_debug_read(PRIV(app)->debug_item_current);
	}
	svc_lcd_puts(8, "db");
	if(PRIV(app)->debug_item_current == HAL_DEBUG_N) {
		svc_lcd_puts(0, "----up");
		if(event & SVC_MAIN_PROC_EVENT_KEY_ENTER) {
			app_set_view(app, 0);
			PRIV(app)->debug_item_current = 0;
		}
	}
	else {
		svc_lcd_puti(6, 2, PRIV(app)->debug_item_current);
		svc_lcd_putix(0, 4, PRIV(app)->debug_value);
	}
	
}
Example #4
0
static void main(uint8_t view, const app_t *app, svc_main_proc_event_t event) {
	hal_lcd_clear();
	if(event & SVC_MAIN_PROC_EVENT_KEY_UP) {
		INC_MOD(PRIV(app)->countdown_current, svc_countdowns_n);
	}
	else if (event & SVC_MAIN_PROC_EVENT_KEY_DOWN) {
		DEC_MOD(PRIV(app)->countdown_current, svc_countdowns_n);
	}
	else if(event & SVC_MAIN_PROC_EVENT_KEY_ENTER_LONG) {
		app_exit();
	}
	else if(event & SVC_MAIN_PROC_EVENT_KEY_DOWN_LONG) {
		svc_countdown_t cd;
		svc_countdown_get(PRIV(app_current)->countdown_current, &cd);
		if(cd.state == SVC_COUNTDOWN_STATE_STOP) {
			svc_countdown_start(PRIV(app_current)->countdown_current);
		}
		else {
			svc_countdown_stop(PRIV(app_current)->countdown_current);
		}
	}

	svc_countdown_t cd;
	svc_countdown_get(PRIV(app)->countdown_current, &cd);
	svc_lcd_puti(0, 2, cd.h);
	svc_lcd_puti(2, 2, cd.m);
	svc_lcd_puti(4, 2, cd.s);
	hal_lcd_seg_set(HAL_LCD_SEG_COLON, 1);
	hal_lcd_seg_set_blink(HAL_LCD_SEG_COLON, cd.state == SVC_COUNTDOWN_STATE_RUN);
	if(cd.state == SVC_COUNTDOWN_STATE_RUN) {
		svc_lcd_puts(8, "ru");
	}
	else {
		svc_lcd_puts(8, "st");
	}
	svc_lcd_puti(6, 2, PRIV(app)->countdown_current);
	if(event & SVC_MAIN_PROC_EVENT_KEY_ENTER) {
		app_set_view(app, 1);
	}
}