Explorar o código

upd hex viewer

MX %!s(int64=2) %!d(string=hai) anos
pai
achega
ff57803740

+ 16 - 0
base_pack/hex_viewer/README.md

@@ -0,0 +1,16 @@
+# #️⃣ Hex Viewer
+
+Hex Viewer application for Flipper Zero!  
+The app allows you to view various files as HEX
+
+**Some facts**:
+- Written with pure C in a very simple and effective manner
+- Tested on files up to 16Mb
+- Very effective: calls `canvas_draw_str` 8 times during repaint and that's almost it
+- Can also view text representation of bytes (makes it kinda poor man's text viewer)
+- Has "Scroll to ..." feature which allows you to jump to any percent of file
+
+Feel free to send PRs! 
+
+App URL: https://lab.flipper.net/apps/hex_viewer
+Catalog's manifest: [flipper-application-catalog/applications/Tools/hex_viewer/manifest.yml](https://github.com/flipperdevices/flipper-application-catalog/blob/main/applications/Tools/hex_viewer/manifest.yml)

+ 2 - 3
base_pack/hex_viewer/application.fam

@@ -8,11 +8,10 @@ App(
         "dialogs",
     ],
     stack_size=2 * 1024,
-    order=20,
-    fap_icon="icons/hex_10px.png",
+    fap_icon="icons/hex_10px.bmp",
     fap_icon_assets="icons",
     fap_category="Tools",
     fap_author="@QtRoS",
     fap_version="2.0",
-    fap_description="App allows to view various files as HEX.",
+    fap_description="App allows to view various files as HEX",
 )

BIN=BIN
base_pack/hex_viewer/icons/hex_10px.bmp


+ 1 - 1
base_pack/hex_viewer/scenes/hex_viewer_scene_scroll.c

@@ -13,7 +13,7 @@ void hex_viewer_scene_scroll_on_enter(void* context) {
 
     TextInput* text_input = app->text_input;
 
-    text_input_set_header_text(text_input, "Scroll to percent (0..100)");
+    text_input_set_header_text(text_input, "Scroll to percentage (0..100)");
     text_input_set_result_callback(
         text_input,
         hex_viewer_scene_scroll_callback,

+ 6 - 3
base_pack/hex_viewer/views/hex_viewer_startscreen.c

@@ -69,6 +69,9 @@ void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* mode
         uint32_t row_iters = model->file_read_bytes / HEX_VIEWER_BYTES_PER_LINE;
         if(model->file_read_bytes % HEX_VIEWER_BYTES_PER_LINE != 0) row_iters += 1;
 
+        // For the rest of drawing.
+        canvas_set_font(canvas, FontKeyboard);
+
         for(uint32_t i = 0; i < row_iters; ++i) {
             uint32_t bytes_left_per_row = model->file_read_bytes - i * HEX_VIEWER_BYTES_PER_LINE;
             bytes_left_per_row = MIN(bytes_left_per_row, HEX_VIEWER_BYTES_PER_LINE);
@@ -79,13 +82,13 @@ void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* mode
                 for(uint32_t j = 0; j < bytes_left_per_row; ++j)
                     if(!isprint((int)temp_buf[j])) temp_buf[j] = '.';
 
-                canvas_set_font(canvas, FontKeyboard);
+                //canvas_set_font(canvas, FontKeyboard);
                 canvas_draw_str(canvas, LEFT_OFFSET, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
             } else {
                 uint32_t addr = model->file_offset + i * HEX_VIEWER_BYTES_PER_LINE;
                 snprintf(temp_buf, 32, "%04lX", addr);
 
-                canvas_set_font(canvas, FontKeyboard);
+                //canvas_set_font(canvas, FontKeyboard);
                 canvas_draw_str(canvas, LEFT_OFFSET, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
             }
 
@@ -93,7 +96,7 @@ void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* mode
             for(uint32_t j = 0; j < bytes_left_per_row; ++j)
                 p += snprintf(p, 32, "%02X ", model->file_bytes[i][j]);
 
-            canvas_set_font(canvas, FontKeyboard);
+            //canvas_set_font(canvas, FontKeyboard);
             canvas_draw_str(canvas, LEFT_OFFSET + 41, TOP_OFFSET + i * ROW_HEIGHT, temp_buf);
         }