summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2024-03-10 09:29:45 +0100
committerAldrik Ramaekers <aldrikboy@gmail.com>2024-03-10 09:29:45 +0100
commitb84007b0bc5fe286c96c675f5c2c210cccbc0490 (patch)
treeeba0e84d3dd525e146153a5a318d577a42b519a9
parentcfbb40b1d08a110a3616a21224c2c13329d12e43 (diff)
set clipboard impl
-rw-r--r--src/linux/main_linux.cpp8
-rw-r--r--src/main.cpp6
-rw-r--r--src/platform.h1
-rw-r--r--src/windows/main_windows.cpp34
4 files changed, 10 insertions, 39 deletions
diff --git a/src/linux/main_linux.cpp b/src/linux/main_linux.cpp
index 2041c09..a4e30d3 100644
--- a/src/linux/main_linux.cpp
+++ b/src/linux/main_linux.cpp
@@ -295,3 +295,11 @@ uint64_t ts_platform_get_time(uint64_t compare) {
return result;
}
+
+void ts_platform_open_file_as(utf8_int8_t* str) {
+ // not implemented
+}
+
+void ts_platform_open_file_in_folder(utf8_int8_t* file) {
+ // not implemented
+} \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index dc9bf8f..5857192 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -289,10 +289,8 @@ void _ts_create_text_match_rows() {
ImGui::SameLine();
ImGui::Selectable("##nolabel", false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap);
- static bool context_menu_open = false;
if (ImGui::IsItemClicked(ImGuiPopupFlags_MouseButtonRight)) {
ImGui::OpenPopup(match_nr);
- context_menu_open = true;
}
if (ImGui::BeginPopup(match_nr)) {
@@ -307,11 +305,11 @@ void _ts_create_text_match_rows() {
#endif
if (ImGui::MenuItem("Copy path"))
{
- ts_platform_copy_to_clipboard(file->file->path);
+ ImGui::SetClipboardText(file->file->path);
}
if (ImGui::MenuItem("Copy line"))
{
- ts_platform_copy_to_clipboard(file->line_info);
+ ImGui::SetClipboardText(file->line_info);
}
ImGui::EndPopup();
}
diff --git a/src/platform.h b/src/platform.h
index 2fa1f43..8d5583c 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -35,7 +35,6 @@ bool ts_platform_dir_exists(utf8_int8_t* dir);
ts_file_content ts_platform_read_file(char *path, const char *mode);
void ts_platform_list_files_block(ts_search_result* result, wchar_t* start_dir = nullptr);
uint64_t ts_platform_get_time(uint64_t compare = 0); // if compare is not 0, return difference between timestamp and now, in milliseconds.
-bool ts_platform_copy_to_clipboard(utf8_int8_t* str);
void ts_platform_open_file_as(utf8_int8_t* str);
void ts_platform_open_file_in_folder(utf8_int8_t* file);
diff --git a/src/windows/main_windows.cpp b/src/windows/main_windows.cpp
index 090898a..c6db7a5 100644
--- a/src/windows/main_windows.cpp
+++ b/src/windows/main_windows.cpp
@@ -431,38 +431,4 @@ void ts_platform_open_file_in_folder(utf8_int8_t* file) {
MultiByteToWideChar(CP_UTF8, 0, file, -1, convstr, MAX_INPUT_LENGTH);
PathCchRemoveFileSpec(convstr, MAX_INPUT_LENGTH);
ShellExecuteW(NULL, L"open", convstr, NULL, NULL, SW_SHOWDEFAULT);
-}
-
-bool ts_platform_copy_to_clipboard(utf8_int8_t* str) {
- HANDLE clipboard_data;
-
- wchar_t convstr[MAX_INPUT_LENGTH];
- memset(convstr, 0, sizeof(convstr));
- int result = MultiByteToWideChar(CP_UTF8, 0, str, -1, convstr, MAX_INPUT_LENGTH);
-
- size_t len = result;
- size_t size = (len+1) * sizeof(wchar_t);
- LPSTR dst;
-
- if (!OpenClipboard(NULL))
- return false;
-
- clipboard_data = GlobalAlloc(GMEM_MOVEABLE, size);
- if (clipboard_data)
- {
- dst = (LPSTR)GlobalLock(clipboard_data);
- memmove(dst, convstr, size);
- dst[len*2] = 0;
- GlobalUnlock(clipboard_data);
-
- SetClipboardData(CF_UNICODETEXT, clipboard_data);
- }
- else
- {
- CloseClipboard();
- return false;
- }
-
- CloseClipboard();
- return true;
} \ No newline at end of file