mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-31 08:37:26 +00:00
Some HexdumpWidget fixes
This commit is contained in:
parent
1bb9eb42dd
commit
689cb06ff2
@ -287,8 +287,10 @@ void HexdumpWidget::refresh(RVA addr)
|
|||||||
addr = Core()->getOffset();
|
addr = Core()->getOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
RCoreLocked lcore = Core()->core();
|
cols = Core()->getConfigi("hex.cols");
|
||||||
int cols = lcore->print->cols;
|
// Avoid divison by 0
|
||||||
|
if (cols == 0)
|
||||||
|
cols = 16;
|
||||||
|
|
||||||
// Align addr to cols
|
// Align addr to cols
|
||||||
addr -= addr % cols;
|
addr -= addr % cols;
|
||||||
@ -385,9 +387,6 @@ void HexdumpWidget::initParsing()
|
|||||||
|
|
||||||
std::array<QString, 3> HexdumpWidget::fetchHexdump(RVA addr, int lines)
|
std::array<QString, 3> HexdumpWidget::fetchHexdump(RVA addr, int lines)
|
||||||
{
|
{
|
||||||
RCoreLocked lcore = Core()->core();
|
|
||||||
int cols = lcore->print->cols;
|
|
||||||
|
|
||||||
// Main bytes to fetch:
|
// Main bytes to fetch:
|
||||||
int bytes = cols * lines;
|
int bytes = cols * lines;
|
||||||
|
|
||||||
@ -753,9 +752,6 @@ RVA HexdumpWidget::hexPositionToAddress(int position)
|
|||||||
|
|
||||||
RVA HexdumpWidget::asciiPositionToAddress(int position)
|
RVA HexdumpWidget::asciiPositionToAddress(int position)
|
||||||
{
|
{
|
||||||
RCoreLocked lcore = Core()->core();
|
|
||||||
int cols = lcore->print->cols;
|
|
||||||
|
|
||||||
// Each row adds one byte (because of the newline), so cols + 1 gets rid of that offset
|
// Each row adds one byte (because of the newline), so cols + 1 gets rid of that offset
|
||||||
return first_loaded_address + (position - (position / (cols + 1)));
|
return first_loaded_address + (position - (position / (cols + 1)));
|
||||||
}
|
}
|
||||||
@ -776,8 +772,6 @@ int HexdumpWidget::hexAddressToPosition(RVA address)
|
|||||||
|
|
||||||
int HexdumpWidget::asciiAddressToPosition(RVA address)
|
int HexdumpWidget::asciiAddressToPosition(RVA address)
|
||||||
{
|
{
|
||||||
RCoreLocked lcore = Core()->core();
|
|
||||||
int cols = lcore->print->cols;
|
|
||||||
RVA local_address = address - first_loaded_address;
|
RVA local_address = address - first_loaded_address;
|
||||||
int position = local_address + (local_address / cols);
|
int position = local_address + (local_address / cols);
|
||||||
return position;
|
return position;
|
||||||
@ -873,8 +867,6 @@ void HexdumpWidget::appendWithoutScroll(QTextEdit *textEdit, QString text)
|
|||||||
void HexdumpWidget::scrollChanged()
|
void HexdumpWidget::scrollChanged()
|
||||||
{
|
{
|
||||||
connectScroll(true);
|
connectScroll(true);
|
||||||
RCoreLocked lcore = Core()->core();
|
|
||||||
int cols = lcore->print->cols;
|
|
||||||
|
|
||||||
int firstLine = getDisplayedLined(ui->hexHexText);
|
int firstLine = getDisplayedLined(ui->hexHexText);
|
||||||
if(firstLine < (bufferLines/2))
|
if(firstLine < (bufferLines/2))
|
||||||
|
@ -102,6 +102,7 @@ private:
|
|||||||
void clearParseWindow();
|
void clearParseWindow();
|
||||||
|
|
||||||
int bufferLines;
|
int bufferLines;
|
||||||
|
int cols;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_seekChanged(RVA addr);
|
void on_seekChanged(RVA addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user