2019-09-15 16:29:11 +00:00
|
|
|
/*
|
|
|
|
* This file is part of espanso.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Federico Terzi
|
|
|
|
*
|
|
|
|
* espanso is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* espanso is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-09-05 15:20:52 +00:00
|
|
|
#ifndef ESPANSO_BRIDGE_H
|
|
|
|
#define ESPANSO_BRIDGE_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-09-05 16:34:03 +00:00
|
|
|
extern "C" {
|
|
|
|
|
2019-09-13 09:55:42 +00:00
|
|
|
extern void * context_instance;
|
2019-09-13 12:35:46 +00:00
|
|
|
extern char * icon_path;
|
2019-09-13 09:55:42 +00:00
|
|
|
|
2019-09-05 15:20:52 +00:00
|
|
|
/*
|
2019-09-05 16:34:03 +00:00
|
|
|
* Initialize the AppDelegate and check for accessibility permissions
|
|
|
|
*/
|
2019-09-13 12:35:46 +00:00
|
|
|
int32_t initialize(void * context, const char * icon_path);
|
2019-09-05 15:20:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the event loop indefinitely. Blocking call.
|
|
|
|
*/
|
2019-09-05 16:34:03 +00:00
|
|
|
int32_t eventloop();
|
|
|
|
|
2019-10-23 18:55:54 +00:00
|
|
|
/*
|
|
|
|
* Initialize the application and start the headless eventloop, used for the espanso detect command
|
|
|
|
*/
|
|
|
|
int32_t headless_eventloop();
|
|
|
|
|
2019-09-05 16:34:03 +00:00
|
|
|
/*
|
|
|
|
* Called when a new keypress is made, the first argument is an char array,
|
|
|
|
* while the second is the size of the array.
|
|
|
|
*/
|
2019-09-05 17:18:55 +00:00
|
|
|
typedef void (*KeypressCallback)(void * self, const char *buffer, int32_t len, int32_t is_modifier, int32_t key_code);
|
2019-09-05 16:34:03 +00:00
|
|
|
|
|
|
|
extern KeypressCallback keypress_callback;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register the callback that will be called when a keypress was made
|
|
|
|
*/
|
2019-09-13 09:55:42 +00:00
|
|
|
void register_keypress_callback(KeypressCallback callback);
|
2019-09-05 16:34:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Type the given string by using the CGEventKeyboardSetUnicodeString call
|
|
|
|
*/
|
|
|
|
void send_string(const char * string);
|
|
|
|
|
2019-09-06 08:49:05 +00:00
|
|
|
/*
|
|
|
|
* Send the Virtual Key press
|
|
|
|
*/
|
|
|
|
void send_vkey(int32_t vk);
|
|
|
|
|
2019-10-23 17:13:21 +00:00
|
|
|
/*
|
|
|
|
* Send the Virtual Key press multiple times
|
|
|
|
*/
|
|
|
|
void send_multi_vkey(int32_t vk, int32_t count);
|
|
|
|
|
2019-09-05 16:34:03 +00:00
|
|
|
/*
|
|
|
|
* Send the backspace keypress, *count* times.
|
|
|
|
*/
|
2019-09-09 13:46:57 +00:00
|
|
|
void delete_string(int32_t count);
|
|
|
|
|
2019-09-09 15:03:59 +00:00
|
|
|
/*
|
|
|
|
* Trigger normal paste ( Pressing CMD+V )
|
|
|
|
*/
|
|
|
|
void trigger_paste();
|
|
|
|
|
2019-09-13 12:35:46 +00:00
|
|
|
// UI
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called when the tray icon is clicked
|
|
|
|
*/
|
|
|
|
typedef void (*IconClickCallback)(void * self);
|
|
|
|
extern IconClickCallback icon_click_callback;
|
|
|
|
void register_icon_click_callback(IconClickCallback callback);
|
|
|
|
|
|
|
|
// CONTEXT MENU
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int32_t id;
|
|
|
|
int32_t type;
|
|
|
|
char name[100];
|
|
|
|
} MenuItem;
|
|
|
|
|
|
|
|
int32_t show_context_menu(MenuItem * items, int32_t count);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called when the context menu is clicked
|
|
|
|
*/
|
|
|
|
typedef void (*ContextMenuClickCallback)(void * self, int32_t id);
|
|
|
|
extern ContextMenuClickCallback context_menu_click_callback;
|
|
|
|
extern "C" void register_context_menu_click_callback(ContextMenuClickCallback callback);
|
|
|
|
|
2019-09-09 13:46:57 +00:00
|
|
|
// SYSTEM
|
|
|
|
|
2019-09-13 13:26:17 +00:00
|
|
|
/*
|
|
|
|
* Check if espanso is authorized to control accessibility features, needed to detect key presses.
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
int32_t check_accessibility();
|
|
|
|
|
2019-09-16 22:11:31 +00:00
|
|
|
/*
|
|
|
|
* Prompt to authorize the accessibility features.
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
int32_t prompt_accessibility();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open Security & Privacy settings panel
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
void open_settings_panel();
|
|
|
|
|
2019-09-09 13:46:57 +00:00
|
|
|
/*
|
|
|
|
* Return the active NSRunningApplication path
|
|
|
|
*/
|
|
|
|
int32_t get_active_app_bundle(char * buffer, int32_t size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the active NSRunningApplication bundle identifier
|
|
|
|
*/
|
|
|
|
int32_t get_active_app_identifier(char * buffer, int32_t size);
|
2019-09-05 16:34:03 +00:00
|
|
|
|
2019-09-09 14:43:32 +00:00
|
|
|
// CLIPBOARD
|
2019-09-05 16:34:03 +00:00
|
|
|
|
2019-09-09 14:43:32 +00:00
|
|
|
/*
|
|
|
|
* Return the clipboard text
|
|
|
|
*/
|
|
|
|
int32_t get_clipboard(char * buffer, int32_t size);
|
2019-09-05 16:34:03 +00:00
|
|
|
|
2019-09-09 14:43:32 +00:00
|
|
|
/*
|
|
|
|
* Set the clipboard text
|
|
|
|
*/
|
|
|
|
int32_t set_clipboard(char * text);
|
2019-09-05 15:20:52 +00:00
|
|
|
|
2019-09-09 14:43:32 +00:00
|
|
|
};
|
2019-09-05 15:20:52 +00:00
|
|
|
#endif //ESPANSO_BRIDGE_H
|