mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
HexEditor: Fix copy {text/hex} to clipboard
Now the copy action takes exactly the selected chars and not one more.
This commit is contained in:
parent
932ce93fd7
commit
334ed9225a
1 changed files with 5 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "HexEditor.h"
|
||||
#include "AK/Format.h"
|
||||
#include "SearchResultsModel.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
|
@ -157,7 +158,7 @@ bool HexEditor::copy_selected_hex_to_clipboard()
|
|||
return false;
|
||||
|
||||
StringBuilder output_string_builder;
|
||||
for (size_t i = m_selection_start; i <= m_selection_end; i++)
|
||||
for (size_t i = m_selection_start; i < m_selection_end; i++)
|
||||
output_string_builder.appendff("{:02X} ", m_document->get(i).value);
|
||||
|
||||
GUI::Clipboard::the().set_plain_text(output_string_builder.to_string());
|
||||
|
@ -170,7 +171,7 @@ bool HexEditor::copy_selected_text_to_clipboard()
|
|||
return false;
|
||||
|
||||
StringBuilder output_string_builder;
|
||||
for (size_t i = m_selection_start; i <= m_selection_end; i++)
|
||||
for (size_t i = m_selection_start; i < m_selection_end; i++)
|
||||
output_string_builder.append(isprint(m_document->get(i).value) ? m_document->get(i).value : '.');
|
||||
|
||||
GUI::Clipboard::the().set_plain_text(output_string_builder.to_string());
|
||||
|
@ -183,9 +184,9 @@ bool HexEditor::copy_selected_hex_to_clipboard_as_c_code()
|
|||
return false;
|
||||
|
||||
StringBuilder output_string_builder;
|
||||
output_string_builder.appendff("unsigned char raw_data[{}] = {{\n", (m_selection_end - m_selection_start) + 1);
|
||||
output_string_builder.appendff("unsigned char raw_data[{}] = {{\n", m_selection_end - m_selection_start);
|
||||
output_string_builder.append(" ");
|
||||
for (size_t i = m_selection_start, j = 1; i <= m_selection_end; i++, j++) {
|
||||
for (size_t i = m_selection_start, j = 1; i < m_selection_end; i++, j++) {
|
||||
output_string_builder.appendff("{:#02X}", m_document->get(i).value);
|
||||
if (i != m_selection_end)
|
||||
output_string_builder.append(", ");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue