<commit_before>#include "e.h"
#include "e_mod_main.h"
#include "evry.h"

#define INPUTLEN 40
#define MATCH_LAG 0.33


typedef struct _Evry_State Evry_State;

struct _Evry_State
{
  Eina_List *cur_items;
  Eina_List *cur_plugins;
  Eina_List *plugins;
  Evry_Plugin *cur_plugin;
  Evry_Item *sel_item;

  Eina_List *cur_actions;
  Evry_Action *cur_action;

  /* Eina_List *sel_items; */
  char *input;
  const char *request_type;
  
  Eina_Bool initial;
};

static int  _evry_cb_key_down(void *data, int type, void *event);
static int  _evry_cb_key_down(void *data, int type, void *event);
static int  _evry_cb_mouse_down(void *data, int type, void *event);
static int  _evry_cb_mouse_up(void *data, int type, void *event);
static int  _evry_cb_mouse_move(void *data, int type, void *event);
static int  _evry_cb_mouse_wheel(void *data, int type, void *event);
static void _evry_cb_item_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void _evry_cb_item_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void _evry_backspace(void);
static void _evry_update(void);
static void _evry_list_clear(void);
static void _evry_show_items(Evry_Plugin *plugin);
static int  _evry_update_timer(void *data);
static void _evry_matches_update(void);
static void _evry_clear(void);
static void _evry_item_next(void);
static void _evry_item_prev(void);
static void _evry_plugin_next(void);
static void _evry_plugin_prev(void);
static void _evry_scroll_to(int i);
static void _evry_item_desel(Evry_Item *it);
static void _evry_item_sel(Evry_Item *it);
static void _evry_action(int finished);
static void _evry_action_select(void);
static void _evry_cb_plugin_sel(void *data1, void *data2);
static int  _evry_animator(void *data);
static int  _evry_scroll_timer(void *data);
static int  _evry_push_state(void);
static int  _evry_pop_state(void);
static void _evry_plugin_selector_append(Evry_Plugin *p);
static int _evry_cb_plugin_sort(const void *data1, const void *data2);

static int  _evry_plug_act_select_init(void);
static int  _evry_plug_act_select_actions_set(void);
static int  _evry_plug_act_select_fetch(const char *input);
static int  _evry_plug_act_select_action(Evry_Item *item, const char *input);
static void _evry_plug_act_select_cleanup(void);
static void _evry_plug_act_select_item_icon_get(Evry_Item *it, Evas *e);



/* local subsystem globals */
static E_Popup     *popup = NULL;
static Ecore_X_Window input_window = 0;
static Eina_List   *handlers = NULL;
static Ecore_Timer *update_timer = NULL;
static Evas_Object *o_list = NULL;
static Evas_Object *o_main = NULL;
static Evas_Object *o_selector = NULL;
static Evas_Object *o_selector_frame = NULL;
static int          ev_last_is_mouse;
static Evry_Item   *item_mouseover = NULL;
static Ecore_Animator *scroll_animator = NULL;
static Ecore_Timer *scroll_timer = NULL;
static double       scroll_align_to;
static double       scroll_align;
static Eina_List   *plugins = NULL;
static Eina_List   *actions = NULL;
static Evry_State  *cur_state = NULL;
static Eina_List   *stack = NULL;
static Evry_Plugin *action_selector = NULL;

/* externally accessible functions */
EAPI int
evry_init(void)
{
   _evry_plug_act_select_init();
   
   return 1;
}

EAPI int
evry_shutdown(void)
{
   evry_hide();
   return 1;
}

EAPI void
evry_plugin_register(Evry_Plugin *plugin)
{
   plugins = eina_list_append(plugins, plugin);
   /* TODO sorting, initialization, etc */
}

EAPI void
evry_plugin_unregister(Evry_Plugin *plugin)
{
   plugins = eina_list_remove(plugins, plugin);
   /* cleanup */
}

EAPI void
evry_action_register(Evry_Action *action)
{
   actions = eina_list_append(actions, action);
   /* TODO sorting, initialization, etc */
}

EAPI void
evry_action_unregister(Evry_Action *action)
{
   actions = eina_list_remove(actions, action);
   /* cleanup */
}

EAPI int
evry_show(E_Zone *zone)
{
   Evas_Object *o;
   int x, y;

   E_OBJECT_CHECK_RETURN(zone, 0);
   E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0);

   if (popup) return 0;

   input_window = ecore_x_window_input_new(zone->container->win, zone->x,
					   zone->y, zone->w, zone->h);
   ecore_x_window_show(input_window);
   if (!e_grabinput_get(input_window, 1, input_window))
     {
        ecore_x_window_free(input_window);
	input_window = 0;
	return 0;
     }

   x = zone->x + (zone->w / 2) - (evry_conf->width / 2);
   y = zone->y + (zone->h / 2) - (evry_conf->height / 2);

   popup = e_popup_new(zone, x, y, evry_conf->width, evry_conf->height);
   if (!popup) return 0;

   ecore_x_netwm_window_type_set(popup->evas_win, ECORE_X_WINDOW_TYPE_UTILITY);
   
   e_popup_layer_set(popup, 255);
   evas_event_freeze(popup->evas);
   evas_event_feed_mouse_in(popup->evas, ecore_x_current_time_get(), NULL);
   evas_event_feed_mouse_move(popup->evas, -1000000, -1000000, ecore_x_current_time_get(), NULL);
   o = edje_object_add(popup->evas);
   o_main = o;
   e_theme_edje_object_set(o, "base/theme/everything",<commit_msg>'everything' module: show on current zone<commit_after>#include "e.h"
#include "e_mod_main.h"
#include "evry.h"

#define INPUTLEN 40
#define MATCH_LAG 0.33


typedef struct _Evry_State Evry_State;

struct _Evry_State
{
  Eina_List *cur_items;
  Eina_List *cur_plugins;
  Eina_List *plugins;
  Evry_Plugin *cur_plugin;
  Evry_Item *sel_item;

  Eina_List *cur_actions;
  Evry_Action *cur_action;

  /* Eina_List *sel_items; */
  char *input;
  const char *request_type;
  
  Eina_Bool initial;
};

static int  _evry_cb_key_down(void *data, int type, void *event);
static int  _evry_cb_key_down(void *data, int type, void *event);
static int  _evry_cb_mouse_down(void *data, int type, void *event);
static int  _evry_cb_mouse_up(void *data, int type, void *event);
static int  _evry_cb_mouse_move(void *data, int type, void *event);
static int  _evry_cb_mouse_wheel(void *data, int type, void *event);
static void _evry_cb_item_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void _evry_cb_item_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void _evry_backspace(void);
static void _evry_update(void);
static void _evry_list_clear(void);
static void _evry_show_items(Evry_Plugin *plugin);
static int  _evry_update_timer(void *data);
static void _evry_matches_update(void);
static void _evry_clear(void);
static void _evry_item_next(void);
static void _evry_item_prev(void);
static void _evry_plugin_next(void);
static void _evry_plugin_prev(void);
static void _evry_scroll_to(int i);
static void _evry_item_desel(Evry_Item *it);
static void _evry_item_sel(Evry_Item *it);
static void _evry_action(int finished);
static void _evry_action_select(void);
static void _evry_cb_plugin_sel(void *data1, void *data2);
static int  _evry_animator(void *data);
static int  _evry_scroll_timer(void *data);
static int  _evry_push_state(void);
static int  _evry_pop_state(void);
static void _evry_plugin_selector_append(Evry_Plugin *p);
static int _evry_cb_plugin_sort(const void *data1, const void *data2);

static int  _evry_plug_act_select_init(void);
static int  _evry_plug_act_select_actions_set(void);
static int  _evry_plug_act_select_fetch(const char *input);
static int  _evry_plug_act_select_action(Evry_Item *item, const char *input);
static void _evry_plug_act_select_cleanup(void);
static void _evry_plug_act_select_item_icon_get(Evry_Item *it, Evas *e);



/* local subsystem globals */
static E_Popup     *popup = NULL;
static Ecore_X_Window input_window = 0;
static Eina_List   *handlers = NULL;
static Ecore_Timer *update_timer = NULL;
static Evas_Object *o_list = NULL;
static Evas_Object *o_main = NULL;
static Evas_Object *o_selector = NULL;
static Evas_Object *o_selector_frame = NULL;
static int          ev_last_is_mouse;
static Evry_Item   *item_mouseover = NULL;
static Ecore_Animator *scroll_animator = NULL;
static Ecore_Timer *scroll_timer = NULL;
static double       scroll_align_to;
static double       scroll_align;
static Eina_List   *plugins = NULL;
static Eina_List   *actions = NULL;
static Evry_State  *cur_state = NULL;
static Eina_List   *stack = NULL;
static Evry_Plugin *action_selector = NULL;

/* externally accessible functions */
EAPI int
evry_init(void)
{
   _evry_plug_act_select_init();
   
   return 1;
}

EAPI int
evry_shutdown(void)
{
   evry_hide();
   return 1;
}

EAPI void
evry_plugin_register(Evry_Plugin *plugin)
{
   plugins = eina_list_append(plugins, plugin);
   /* TODO sorting, initialization, etc */
}

EAPI void
evry_plugin_unregister(Evry_Plugin *plugin)
{
   plugins = eina_list_remove(plugins, plugin);
   /* cleanup */
}

EAPI void
evry_action_register(Evry_Action *action)
{
   actions = eina_list_append(actions, action);
   /* TODO sorting, initialization, etc */
}

EAPI void
evry_action_unregister(Evry_Action *action)
{
   actions = eina_list_remove(actions, action);
   /* cleanup */
}

EAPI int
evry_show(E_Zone *zone)
{
   Evas_Object *o;
   int x, y;

   E_OBJECT_CHECK_RETURN(zone, 0);
   E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0);

   if (popup) return 0;

   input_window = ecore_x_window_input_new(zone->container->win, zone->x,
					   zone->y, zone->w, zone->h);
   ecore_x_window_show(input_window);
   if (!e_grabinput_get(input_window, 1, input_window))
     {
        ecore_x_window_free(input_window);
	input_window = 0;
	return 0;
     }

   x = (zone->w / 2) - (evry_conf->width / 2);
   y = (zone->h / 2) - (evry_conf->height / 2);

   popup = e_popup_new(zone, x, y, evry_conf->width, evry_conf->height);
   if (!popup) return 0;

   ecore_x_netwm_window_type_set(popup->evas_win, ECORE_X_WINDOW_TYPE_UTILITY);
   
   e_popup_layer_set(popup, 255);
   evas_event_freeze(popup->evas);
   evas_event_feed_mouse_in(popup->evas, ecore_x_current_time_get(), NULL);
   evas_event_feed_mouse_move(popup->evas, -1000000, -1000000, ecore_x_current_time_get(), NULL);
   o = edje_object_add(popup->evas);
   o_main = o;
   e_theme_edje_object_set(o, "base/theme/everything",
{'fraction_non_alphanumeric': 0.10123925644613233, 'fraction_numerical': 0.007995202878273036, 'mean_word_length': 5.498051948051948, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4014233', 'n_tokens_mistral': 3875, 'n_tokens_neox': 3769, 'n_words': 854}