Просмотр исходного кода

Squashed 'hex_editor/' changes from 31cc9c420..2f2649283

2f2649283 fix catalog versions
9218d8c0d Proper fap_descriptions
74ac9a4ef categories part 1
6b56cef06 more manifestos, xbox controller and videopoker ufbt fixes
fcce08afd Add Screenshots
1ed741487 API 31 / unzip sources
REVERT: 31cc9c420 clean up comments
REVERT: efb3032c5 add github workflows
REVERT: 77fb83ab7 small interface improvements
REVERT: 9b260273c add README
REVERT: 31cbc576b first commit

git-subtree-dir: hex_editor
git-subtree-split: 2f2649283170357577ec9a616374c13eeff6587f
Willy-JL 2 лет назад
Родитель
Сommit
5d6585a34c
5 измененных файлов с 50 добавлено и 24 удалено
  1. 0 19
      .github/workflows/build_dev.yml
  2. 3 0
      README-catalog.md
  3. 6 2
      application.fam
  4. 41 3
      hex_editor.c
  5. BIN
      img/1.png

+ 0 - 19
.github/workflows/build_dev.yml

@@ -1,19 +0,0 @@
-name: Build main
-
-on:
-  push:
-    branches:
-      - main
-
-jobs:
-  build_dev:
-    runs-on: ubuntu-latest
-
-    steps:
-      - name: Checkout
-        uses: actions/checkout@v3
-
-      - name: Build
-        uses: oleksiikutuzov/flipperzero-ufbt-action@v1
-        with:
-          channel: dev

+ 3 - 0
README-catalog.md

@@ -0,0 +1,3 @@
+The HEX Editor app allows you to edit files directly on your Flipper Zero without connecting using your computer or smartphone. This app might be very useful for editing NFC files, similar to the Edit Dump feature.
+
+Run the app on your Flipper Zero and select the file you want to edit. The app displays the first line of the text file. To select the desired character, use the Left and Right buttons. To replace the character, press the Ok button. To navigate through lines, use the Up and Down buttons.

+ 6 - 2
application.fam

@@ -1,6 +1,6 @@
 App(
     appid="hex_editor",
-    name="Hex Editor",
+    name="HEX Editor",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="hex_editor_app",
     cdefines=["APP_HEX_EDITOR"],
@@ -11,6 +11,10 @@ App(
     stack_size=2 * 1024,
     order=20,
     fap_icon="icons/edit_10px.png",
-    fap_category="Misc",
+    fap_category="Tools",
     fap_icon_assets="icons",
+    fap_author="@dunaevai135",
+    fap_weburl="https://github.com/dunaevai135/flipper-zero-hex_editor",
+    fap_version="1.2",
+    fap_description="Read text files line by line and edit them without a computer or smartphone.",
 )

+ 41 - 3
hex_editor.c

@@ -17,13 +17,14 @@
 #define TAG "HexEditor"
 
 typedef struct {
+    // uint8_t file_bytes[HEX_editor_LINES_ON_SCREEN][HEX_editor_BYTES_PER_LINE];
     uint32_t file_offset;
     uint32_t file_read_bytes;
     uint32_t file_size;
     uint8_t string_offset;
     char editable_char;
     Stream* stream;
-    bool mode;
+    bool mode; // Print address or content
 } HexEditorModel;
 
 typedef struct {
@@ -40,13 +41,15 @@ typedef struct {
 } HexEditor;
 
 static void draw_callback(Canvas* canvas, void* ctx) {
+    // UNUSED(ctx);
     HexEditor* hex_editor = ctx;
 
     canvas_clear(canvas);
     canvas_set_font(canvas, FontPrimary);
     canvas_draw_str(canvas, 0, 10, "Line and mode:");
+    // elements_button_right(canvas, "Info");
 
-
+    // // elements_string_fit_width(canvas, buffer, 100);
     canvas_set_font(canvas, FontSecondary);
 
     canvas_draw_str_aligned(
@@ -56,7 +59,10 @@ static void draw_callback(Canvas* canvas, void* ctx) {
         AlignLeft,
         AlignBottom,
         furi_string_get_cstr(hex_editor->buffer) + hex_editor->model->string_offset);
+    // elements_scrollable_text_line(
+    //     canvas, 0, 20, 128, hex_editor->buffer, hex_editor->model->string_offset, false);
 
+    // canvas_draw_line(canvas, 3, 20, 5, 30);
 
     canvas_draw_icon(canvas, 0, 20, &I_Pin_arrow_up_7x9);
 
@@ -147,6 +153,31 @@ static bool hex_editor_open_file(HexEditor* hex_editor, const char* file_path) {
     return isOk;
 }
 
+// static bool hex_editor_read_file(HexEditor* hex_editor) {
+//     furi_assert(hex_editor);
+//     furi_assert(hex_editor->model->stream);
+//     // furi_assert(hex_editor->model->file_offset % hex_editor_BYTES_PER_LINE == 0);
+
+//     memset(hex_editor->model->file_bytes, 0x0, hex_editor_BUF_SIZE);
+//     bool isOk = true;
+
+//     do {
+//         uint32_t offset = hex_editor->model->file_offset;
+//         if(!stream_seek(hex_editor->model->stream, offset, true)) {
+//             FURI_LOG_E(TAG, "Unable to seek stream");
+//             isOk = false;
+//             break;
+//         }
+
+//         hex_editor->model->file_read_bytes = stream_read(
+//             hex_editor->model->stream,
+//             (uint8_t*)hex_editor->model->file_bytes,
+//             hex_editor_BUF_SIZE);
+//     } while(false);
+
+//     return isOk;
+// }
+
 int32_t hex_editor_app(void* p) {
     UNUSED(p);
 
@@ -155,6 +186,10 @@ int32_t hex_editor_app(void* p) {
     FuriString* file_path;
     file_path = furi_string_alloc();
 
+    // furi_string_printf(
+    //     hex_editor->buffer,
+    //     "qqqqq1231231232343454565676urtfgsdfascesc\nasdqwe\new ra sssssssssssssssssssssssssqqqqqqqqqqq1231231232343454565676urtfgsdfascesc\nq2e");
+
     do {
         if(p && strlen(p)) {
             furi_string_set(file_path, (const char*)p);
@@ -234,7 +269,10 @@ int32_t hex_editor_app(void* p) {
                         stream_seek_to_char(
                             hex_editor->model->stream, '\n', StreamDirectionBackward);
 
-
+                        // if(!stream_seek(hex_editor->model->stream, -1, StreamOffsetFromCurrent)) {
+                        //     FURI_LOG_E(TAG, "Unable to seek stream");
+                        //     break;
+                        // }
                         if(!stream_seek_to_char(
                                hex_editor->model->stream, '\n', StreamDirectionBackward)) {
                             stream_rewind(hex_editor->model->stream);