add copy/paste function in text editor

This commit is contained in:
Chee Yee
2023-03-13 04:56:04 -07:00
parent d752dd8fed
commit 5ca56b47df
9 changed files with 36 additions and 8 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ add_executable(ezremote_client
add_self(ezremote_client)
add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.04" 32 0)
add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.05" 32 0)
target_link_libraries(ezremote_client
c
Binary file not shown.
+2
View File
@@ -136,3 +136,5 @@ STR_CLIENT_ID=Client ID
STR_CLIENT_SECRET=Client Secret
STR_GLOBAL=Global
STR_GOOGLE=Google
STR_COPY_LINE=Copy selected line
STR_PASTE_LINE=Paste into selected line
+4
View File
@@ -0,0 +1,4 @@
#pragma once
#define ICON_OF_SQUARE "\xee\x83\x8b" // U+E0CB
#define ICON_OF_TRIANGLE "\xee\x83\x9e" // U+E0CB
+1 -1
View File
@@ -1200,7 +1200,7 @@ typedef ImBitArray<ImGuiKey_NamedKey_COUNT, -ImGuiKey_NamedKey_BEGIN> ImBitAr
#define ImGuiKey_NavGamepadTweakFast ImGuiKey_GamepadR1
#define ImGuiKey_NavGamepadActivate ImGuiKey_GamepadFaceDown
#define ImGuiKey_NavGamepadCancel ImGuiKey_GamepadFaceRight
#define ImGuiKey_NavGamepadMenu ImGuiKey_GamepadFaceLeft
#define ImGuiKey_NavGamepadMenu ImGuiKey_Keypad0
#define ImGuiKey_NavGamepadInput ImGuiKey_GamepadFaceUp
enum ImGuiInputEventType
+2
View File
@@ -150,6 +150,8 @@ char lang_strings[LANG_STRINGS_NUM][LANG_STR_SIZE] = {
"Client Secret", // STR_CLIENT_SECRET
"Global", // STR_GLOBAL
"Google", // STR_GOOGLE
"Copy selected line", // STR_COPY_LINE
"Paste into selected line", // STR_PASTE_LINE
};
bool needs_extended_font = false;
+4 -2
View File
@@ -141,7 +141,9 @@
FUNC(STR_CLIENT_ID) \
FUNC(STR_CLIENT_SECRET) \
FUNC(STR_GLOBAL) \
FUNC(STR_GOOGLE)
FUNC(STR_GOOGLE) \
FUNC(STR_COPY_LINE) \
FUNC(STR_PASTE_LINE)
#define GET_VALUE(x) x,
#define GET_STRING(x) #x,
@@ -151,7 +153,7 @@ enum
FOREACH_STR(GET_VALUE)
};
#define LANG_STRINGS_NUM 138
#define LANG_STRINGS_NUM 140
#define LANG_ID_SIZE 64
#define LANG_STR_SIZE 384
extern char lang_identifiers[LANG_STRINGS_NUM][LANG_ID_SIZE];
+9 -3
View File
@@ -99,7 +99,7 @@ void InitImgui()
0,
};
static const ImWchar icons[] {
static const ImWchar fa_icons[] {
0xF07B, 0xF07B, // folder
0xF65E, 0xF65E, // new folder
0xF15B, 0xF15B, // file
@@ -127,6 +127,12 @@ void InitImgui()
0,
};
static const ImWchar of_icons[] {
0xE0CB, 0xE0CB, // square
0xE0DE, 0xE0DE, // triangle
0,
};
std::string lang = std::string(language);
int32_t lang_idx;
sceSystemServiceParamGetInt( ORBIS_SYSTEM_SERVICE_PARAM_ID_LANG, &lang_idx );
@@ -177,7 +183,8 @@ void InitImgui()
ImFontConfig config;
config.MergeMode = true;
config.GlyphMinAdvanceX = 13.0f; // Use if you want to make the icon monospaced
io.Fonts->AddFontFromFileTTF("/app0/assets/fonts/fa-solid-900.ttf", 20.0f, &config, icons);
io.Fonts->AddFontFromFileTTF("/app0/assets/fonts/fa-solid-900.ttf", 20.0f, &config, fa_icons);
io.Fonts->AddFontFromFileTTF("/app0/assets/fonts/OpenFontIcons.ttf", 20.0f, &config, of_icons);
io.Fonts->Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;
io.Fonts->Build();
@@ -307,7 +314,6 @@ int main()
ImGui_ImplSDL2_InitForSDLRenderer(window, renderer);
ImGui_ImplSDLRenderer_Init(renderer);
ImGui_ImplSDLRenderer_CreateFontsTexture();
ImGui_ImplSDL2_DisableButton(SDL_CONTROLLER_BUTTON_X, true);
if (!initialize_jbc())
{
+13 -1
View File
@@ -13,6 +13,7 @@
#include "lang.h"
#include "ime_dialog.h"
#include "IconsFontAwesome6.h"
#include "OpenFontIcons.h"
#include "server/http_server.h"
#include "clients/gdrive.h"
@@ -77,6 +78,7 @@ char label[256];
bool editor_modified = false;
char edit_file[256];
int edit_line_to_select = -1;
std::string copy_text;
// Overwrite dialog variables
bool dont_prompt_overwrite = false;
@@ -1519,6 +1521,15 @@ namespace Windows
editor_modified = true;
edit_line_to_select = j;
}
else if (ImGui::IsKeyPressed(ImGuiKey_GamepadFaceLeft, false))
{
copy_text = std::string(it->c_str());
}
else if (ImGui::IsKeyPressed(ImGuiKey_GamepadFaceUp, false))
{
it->clear();
it->append(copy_text);
}
}
j++;
}
@@ -1534,7 +1545,8 @@ namespace Windows
ImGui::Text("%s%s", (editor_modified ? "**" : ""), edit_file);
ImGui::Separator();
ImGui::Text("L1 - %s R1 - %s", lang_strings[STR_DELETE_LINE], lang_strings[STR_INSERT_LINE]);
ImGui::Text("L1 - %s R1 - %s %s - %s %s - %s", lang_strings[STR_DELETE_LINE], lang_strings[STR_INSERT_LINE],
ICON_OF_SQUARE, lang_strings[STR_COPY_LINE], ICON_OF_TRIANGLE, lang_strings[STR_PASTE_LINE]);
ImGui::EndPopup();
}
}