Scale fonts context menu (#246)
* Retrieve scale plugin from lite-plugins * New implementation of scale plugin and font C API Introduce two new C API functions, renderer.font.get_size and set_size respectively to get the font size and to set the size to a new value. Using these functions we don't need to know the name of the font but we can just change their size. Adapt the scale plugin to use the new C API function with minor adaptations in the logic. Use smaller step to scale fonts. Rename font_desc_free function, previous name was misleading as only the cached resources are freed. * Add contextmenu plugin from takase From https://github.com/takase1121/lite-contextmenu Adapted to show font scaling commands and find/replace commands. i# testing.lua * Fix the cursor flickering with contextmenu To avoid flickering of the cursor when using the context menu we add a new function `core.request_cursor` that just take note of the cursor requested. The cursor will be actually changed only in root_view:draw() method only when all the drawing operations are done. This means the cursor will be changed only once per frame and only the most recent cursor change request will take effect. * Remove unneeded scale plugin return functions
This commit is contained in:
+19
-1
@@ -65,7 +65,7 @@ static int f_set_tab_size(lua_State *L) {
|
||||
|
||||
static int f_gc(lua_State *L) {
|
||||
FontDesc *self = luaL_checkudata(L, 1, API_TYPE_FONT);
|
||||
font_desc_free(self);
|
||||
font_desc_clear(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -104,6 +104,22 @@ static int f_get_height(lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
static int f_get_size(lua_State *L) {
|
||||
FontDesc *self = luaL_checkudata(L, 1, API_TYPE_FONT);
|
||||
lua_pushnumber(L, self->size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int f_set_size(lua_State *L) {
|
||||
FontDesc *self = luaL_checkudata(L, 1, API_TYPE_FONT);
|
||||
float new_size = luaL_checknumber(L, 2);
|
||||
font_desc_clear(self);
|
||||
self->size = new_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const luaL_Reg lib[] = {
|
||||
{ "__gc", f_gc },
|
||||
{ "load", f_load },
|
||||
@@ -112,6 +128,8 @@ static const luaL_Reg lib[] = {
|
||||
{ "get_width_subpixel", f_get_width_subpixel },
|
||||
{ "get_height", f_get_height },
|
||||
{ "subpixel_scale", f_subpixel_scale },
|
||||
{ "get_size", f_get_size },
|
||||
{ "set_size", f_set_size },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user