mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
get_current_selection should return char* not const char*
This commit is contained in:
@@ -1560,7 +1560,7 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
|
|||||||
{
|
{
|
||||||
NSString *text = nil;
|
NSString *text = nil;
|
||||||
if (_glfw.callbacks.get_current_selection) {
|
if (_glfw.callbacks.get_current_selection) {
|
||||||
const char *s = _glfw.callbacks.get_current_selection();
|
char *s = _glfw.callbacks.get_current_selection();
|
||||||
if (s) {
|
if (s) {
|
||||||
text = [NSString stringWithUTF8String:s];
|
text = [NSString stringWithUTF8String:s];
|
||||||
free(s);
|
free(s);
|
||||||
|
|||||||
2
glfw/glfw3.h
vendored
2
glfw/glfw3.h
vendored
@@ -1716,7 +1716,7 @@ typedef void (* GLFWjoystickfun)(int,int);
|
|||||||
typedef void (* GLFWuserdatafun)(unsigned long long, void*);
|
typedef void (* GLFWuserdatafun)(unsigned long long, void*);
|
||||||
typedef void (* GLFWtickcallback)(void*);
|
typedef void (* GLFWtickcallback)(void*);
|
||||||
typedef bool (* GLFWdrawtextfun)(GLFWwindow *window, const char *text, uint32_t fg, uint32_t bg, uint8_t *output_buf, size_t width, size_t height, float x_offset, float y_offset, size_t right_margin);
|
typedef bool (* GLFWdrawtextfun)(GLFWwindow *window, const char *text, uint32_t fg, uint32_t bg, uint8_t *output_buf, size_t width, size_t height, float x_offset, float y_offset, size_t right_margin);
|
||||||
typedef const char* (* GLFWcurrentselectionfun)(void);
|
typedef char* (* GLFWcurrentselectionfun)(void);
|
||||||
|
|
||||||
/*! @brief Video mode type.
|
/*! @brief Video mode type.
|
||||||
*
|
*
|
||||||
|
|||||||
2
kitty/glfw-wrapper.h
generated
2
kitty/glfw-wrapper.h
generated
@@ -1454,7 +1454,7 @@ typedef void (* GLFWjoystickfun)(int,int);
|
|||||||
typedef void (* GLFWuserdatafun)(unsigned long long, void*);
|
typedef void (* GLFWuserdatafun)(unsigned long long, void*);
|
||||||
typedef void (* GLFWtickcallback)(void*);
|
typedef void (* GLFWtickcallback)(void*);
|
||||||
typedef bool (* GLFWdrawtextfun)(GLFWwindow *window, const char *text, uint32_t fg, uint32_t bg, uint8_t *output_buf, size_t width, size_t height, float x_offset, float y_offset, size_t right_margin);
|
typedef bool (* GLFWdrawtextfun)(GLFWwindow *window, const char *text, uint32_t fg, uint32_t bg, uint8_t *output_buf, size_t width, size_t height, float x_offset, float y_offset, size_t right_margin);
|
||||||
typedef const char* (* GLFWcurrentselectionfun)(void);
|
typedef char* (* GLFWcurrentselectionfun)(void);
|
||||||
|
|
||||||
/*! @brief Video mode type.
|
/*! @brief Video mode type.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -464,12 +464,12 @@ application_close_requested_callback(int flags) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
static char*
|
||||||
get_current_selection(void) {
|
get_current_selection(void) {
|
||||||
if (!global_state.boss) return NULL;
|
if (!global_state.boss) return NULL;
|
||||||
PyObject *ret = PyObject_CallMethod(global_state.boss, "get_active_selection", NULL);
|
PyObject *ret = PyObject_CallMethod(global_state.boss, "get_active_selection", NULL);
|
||||||
if (!ret) { PyErr_Print(); return NULL; }
|
if (!ret) { PyErr_Print(); return NULL; }
|
||||||
const char* ans = NULL;
|
char* ans = NULL;
|
||||||
if (PyUnicode_Check(ret)) ans = strdup(PyUnicode_AsUTF8(ret));
|
if (PyUnicode_Check(ret)) ans = strdup(PyUnicode_AsUTF8(ret));
|
||||||
Py_DECREF(ret);
|
Py_DECREF(ret);
|
||||||
return ans;
|
return ans;
|
||||||
|
|||||||
Reference in New Issue
Block a user