Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void pane_hexview_select_byte(hexview_t* hv, uint64_t byte) {
- int selected_row;
- int selected_col;
- if(byte < hv->data_offset)
- _throwerr("Trying to select byte outside of hexview. Byte: %llu, hexview data offset: %llu", byte, hv->data_offset);
- if(byte > hv->last_byte)
- _throwerr("Trying to select byte outside of hexview. Byte: %llu, hexview last byte: %llu", byte, hv->last_byte);
- cursor_move(hv->pane.row, hv->pane.col);
- printc("0x%0*llX", SHADE, -1, hv->offset_display_digits, byte);
- if(hv->highlight) {
- /* If different columns, repaint the column specifier */
- if(hv->selected_byte % 0x10 != byte % 0x10) {
- int col;
- /* Repaint the old column specifier */
- col = hv->pane.col + hv->offset_display_width + ( ( hv->selected_byte - hv->offset_alignment ) % 0x10 ) * 4;
- cursor_move(hv->pane.row, col);
- printc("%02X", SHADE, -1, hv->offset_alignment + ( hv->selected_byte - hv->offset_alignment ) % 0x10);
- /* Paint the new column specifier */
- col = hv->pane.col + hv->offset_display_width + ( ( byte - hv->offset_alignment ) % 0x10 ) * 4;
- cursor_move(hv->pane.row, col);
- printc("%02X", TINT, -1, hv->offset_alignment + ( byte - hv->offset_alignment ) % 0x10);
- }
- /* If different rows, repaint the row specifier */
- if( (hv->selected_byte - hv->offset_alignment) / 0x10 != (byte - hv->offset_alignment) / 0x10) {
- int row;
- /* Repaint the old row specifier */
- row = hv->pane.row + 2 + ( hv->selected_byte - hv->data_offset ) / 0x10;
- cursor_move(row, hv->pane.col);
- printc("0x%0*llX", SHADE, -1, hv->offset_display_digits, hv->data_offset + (( hv->selected_byte - hv->data_offset ) & ~0xF));
- /* Paint the new row specifier */
- row = hv->pane.row + 2 + ( byte - hv->data_offset ) / 0x10;
- cursor_move(row, hv->pane.col);
- printc("0x%0*llX", TINT, -1, hv->offset_display_digits, hv->data_offset + (( byte - hv->data_offset ) & ~0xF));
- }
- }
- /* Repaint the old selected byte */
- int color = (hv->selected_byte - hv->offset_alignment) % 2 ? TINT : -1;
- int byte_index = hv->selected_byte - hv->data_offset;
- selected_row = hv->pane.row + 2 + byte_index / 16;
- selected_col = hv->pane.col + hv->offset_display_width + (byte_index % 0x10) * 4;
- cursor_move(selected_row, selected_col);
- printc("%02X", color, -1, hv->file->data[hv->selected_byte]);
- /* Paint the new selected byte */
- color = (byte - hv->offset_alignment) % 2 ? TINT : -1;
- byte_index = byte - hv->data_offset;
- selected_row = hv->pane.row + 2 + byte_index / 16;
- selected_col = hv->pane.col + hv->offset_display_width + (byte_index % 0x10) * 4;
- cursor_move(selected_row, selected_col);
- printc("%02X", color, HOVER_COLOR, hv->file->data[byte]);
- hv->selected_byte = byte;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement