Save line to clipboard on right click
This commit is contained in:
@@ -302,20 +302,26 @@ bool GlobalCommand(Event event) {
|
|||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
|
||||||
Int p = ScreenSpaceToBufferPos(window, view, buffer, mouse);
|
Int p = ScreenSpaceToBufferPos(window, view, buffer, mouse);
|
||||||
Int saved_front = 0;
|
Int saved_front = -1;
|
||||||
|
|
||||||
IterRemove(view->carets) {
|
IterRemove(view->carets) {
|
||||||
IterRemovePrepare(view->carets);
|
IterRemovePrepare(view->carets);
|
||||||
if (InBounds(it.range, p)) {
|
if (InBounds(it.range, p)) {
|
||||||
String16 string = GetString(*buffer, it.range);
|
String16 string = GetString(*buffer, it.range);
|
||||||
string = Copy(GetSystemAllocator(), string);
|
SaveStringInClipboard(string);
|
||||||
MakeSureToUseSystemAllocator_SaveInClipboard(string);
|
|
||||||
|
|
||||||
remove_item = true;
|
remove_item = true;
|
||||||
saved_front = GetFront(it);
|
saved_front = GetFront(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (view->carets.len == 0) Add(&view->carets, MakeCaret(saved_front));
|
if (view->carets.len == 0) Add(&view->carets, MakeCaret(saved_front));
|
||||||
|
|
||||||
|
if (saved_front == -1) {
|
||||||
|
Int line = PosToLine(*buffer, p);
|
||||||
|
Range line_range = GetLineRangeWithoutNL(*buffer, line);
|
||||||
|
String16 string = GetString(*buffer, line_range);
|
||||||
|
SaveStringInClipboard(string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ void MakeSureToUseSystemAllocator_SaveInClipboard(String16 string, Array<String1
|
|||||||
SDL_SetClipboardText(ToString(scratch, SavedClipboardString).data);
|
SDL_SetClipboardText(ToString(scratch, SavedClipboardString).data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SaveStringInClipboard(String16 string) {
|
||||||
|
string = Copy(GetSystemAllocator(), string);
|
||||||
|
MakeSureToUseSystemAllocator_SaveInClipboard(string);
|
||||||
|
}
|
||||||
|
|
||||||
void Command_Copy(View *view) {
|
void Command_Copy(View *view) {
|
||||||
Allocator sys_allocator = GetSystemAllocator();
|
Allocator sys_allocator = GetSystemAllocator();
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ alt mleft -
|
|||||||
alt ctrl mleft -
|
alt ctrl mleft -
|
||||||
alt shift mleft -
|
alt shift mleft -
|
||||||
alt mright - go back
|
alt mright - go back
|
||||||
mright - @todo: destroy pointed at selection and copy
|
mright - destroy pointed at selection and copy
|
||||||
ctrl mright - load word
|
ctrl mright - load word
|
||||||
shift mright -
|
shift mright -
|
||||||
ctrl shift mright - exec word
|
ctrl shift mright - exec word
|
||||||
|
|||||||
Reference in New Issue
Block a user