ScalpiEditor

Diff
Login

Diff

Differences From Artifact [2f5f174c5d]:

To Artifact [cfa5aeb03d]:


1320
1321
1322
1323
1324
1325
1326
1327

1328
1329

1330
1331

1332
1333

1334
1335

1336
1337

1338
1339

1340
1341

1342
1343

1344
1345

1346
1347

1348












1349

1350
1351

1352
1353

1354
1355

1356
1357

1358
1359

1360
1361

1362
1363

1364
1365

1366
1367

1368
1369

1370
1371

1372
1373

1374
1375

1376
1377

1378
1379

1380
1381

1382
1383

1384
1385

1386
1387

1388
1389

1390
1391

1392
1393

1394
1395

1396
1397

1398
1399

1400
1401

1402
1403

1404
1405

1406
1407

1408
1409

1410
1411

1412
1413

1414
1415

1416
1417

1418
1419

1420
1421

1422
1423

1424
1425

1426
1427

1428
1429

1430
1431

1432
1433

1434
1435

1436
1437

1438
1439

1440
1441

1442
1443

1444
1445

1446
1447

1448
1449

1450
1451

1452
1453

1454
1455

1456
1457

1458
1459

1460
1461

1462
1463

1464
1465

1466
1467

1468
1469

1470
1471

1472
1473

1474
1475

1476
1477

1478
1479

1480
1481
1482
1483
1484
1485
1486
1320
1321
1322
1323
1324
1325
1326

1327
1328

1329
1330

1331
1332

1333
1334

1335
1336

1337
1338

1339
1340

1341
1342

1343
1344

1345
1346

1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360

1361
1362

1363
1364

1365
1366

1367
1368

1369
1370

1371
1372

1373
1374

1375
1376

1377
1378

1379
1380

1381
1382

1383
1384

1385
1386

1387
1388

1389
1390

1391
1392

1393
1394

1395
1396

1397
1398

1399
1400

1401
1402

1403
1404

1405
1406

1407
1408

1409
1410

1411
1412

1413
1414

1415
1416

1417
1418

1419
1420

1421
1422

1423
1424

1425
1426

1427
1428

1429
1430

1431
1432

1433
1434

1435
1436

1437
1438

1439
1440

1441
1442

1443
1444

1445
1446

1447
1448

1449
1450

1451
1452

1453
1454

1455
1456

1457
1458

1459
1460

1461
1462

1463
1464

1465
1466

1467
1468

1469
1470

1471
1472

1473
1474

1475
1476

1477
1478

1479
1480

1481
1482

1483
1484

1485
1486

1487
1488

1489
1490

1491
1492
1493
1494
1495
1496
1497
1498







-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

+
+
+
+
+
+
+
+
+
+
+
+
-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+







                struct __Terminal__  terminal;
                struct __AppEditor__ editor;
                int64_t              tick; // time ms
                bool                 working;
            };
// typedef to fn_ptrs
// function prototypes
    // # __Ap_fromNibble__
    // @ __Ap_fromNibble__
        uint8_t             __Ap_fromNibble__                    (char data);
    // # __Buffer_push__
    // @ __Buffer_push__
        void                __Buffer_push__                      ( char *buffer, size_t *buffer_used, size_t pos, char item);
    // # __Buffer_setIndent__
    // @ __Buffer_setIndent__
        bool                __Buffer_setIndent__                 ( char *buffer, size_t *buffer_used, size_t buffer_max, size_t new_indent);
    // # __ConsoleOutput_cursorHide__
    // @ __ConsoleOutput_cursorHide__
        void                __ConsoleOutput_cursorHide__         ( struct __OsConsoleOutput__* console_output);
    // # __Console_showCursor__
    // @ __Console_showCursor__
        void                __Console_showCursor__               ( struct __Console__ *console);
    // # __CryptoScalpiHash_do__
    // @ __CryptoScalpiHash_do__
        void                __CryptoScalpiHash_do__              ( struct __CryptoScalpiHash__ *t, const char *src, size_t src_size, char *dest, size_t dest_size);
    // # __CryptoScalpiHash_reset__
    // @ __CryptoScalpiHash_reset__
        void                __CryptoScalpiHash_reset__           ( struct __CryptoScalpiHash__ *t);
    // # __CryptoScalpiHash_swapTwoBit__
    // @ __CryptoScalpiHash_swapTwoBit__
        void                __CryptoScalpiHash_swapTwoBit__      ( struct __CryptoScalpiHash__ *t);
    // # __Crypto_sumBytes__
    // @ __Crypto_sumBytes__
        uint8_t             __Crypto_sumBytes__                  ( const char *data, size_t data_len);
    // # __Crypto_xorBytes__
    // @ __Crypto_xorBytes__
        uint8_t             __Crypto_xorBytes__                  ( const char *data, size_t data_len);
    // # __Crypto_xorCyclic__
    // @ __Crypto_xorCyclic__
        void                __Crypto_xorCyclic__                 ( char *dest, const char  *a, size_t dest_len, const char  *b, size_t b_len);
    // @ __FileComplete_clear__
        bool __FileComplete_clear__(
            const char*  file_name, 
            size_t       file_name_len
        );
    // @ __FileComplete_write__
        bool __FileComplete_write__(
            const char*  file_name, 
            size_t       file_name_len,
            const char*  bytes,
            size_t       bytes_len
        );
    // # __HexCapital_fromNibble__
    // @ __HexCapital_fromNibble__
        char                __HexCapital_fromNibble__            ( char data);
    // # __Hex_fromByte__
    // @ __Hex_fromByte__
        void                __Hex_fromByte__                     ( char *buffer, uint8_t data);
    // # __Hex_fromNibble__
    // @ __Hex_fromNibble__
        char                __Hex_fromNibble__                   ( uint8_t data);
    // # __Logger_init__
    // @ __Logger_init__
        void                __Logger_init__                      (struct __Logger__* t);
    // # __Math_ceilDiv32__
    // @ __Math_ceilDiv32__
        uint32_t            __Math_ceilDiv32__                   ( uint32_t a, uint32_t b);
    // # __MemListLink_init__
    // @ __MemListLink_init__
        void                __MemListLink_init__                 ( struct __MemListLink__* link);
    // # __MemListLink_resetLinks__
    // @ __MemListLink_resetLinks__
        void                __MemListLink_resetLinks__           ( struct __MemListLink__* link);
    // # __MemList_init__
    // @ __MemList_init__
        void                __MemList_init__                     ( struct __MemList__* list);
    // # __MemList_pushLast__
    // @ __MemList_pushLast__
        void                __MemList_pushLast__                 ( struct __MemList__ *list, struct __MemListLink__ *item);
    // # __MemTree_fix_counts__
    // @ __MemTree_fix_counts__
        void                __MemTree_fix_counts__               ( struct __MemTree__ *t, size_t delta_count, char action);
    // # __MemTree_fix_nested__
    // @ __MemTree_fix_nested__
        void                __MemTree_fix_nested__               ( struct __MemTree__ *t, size_t nested_delta, char action);
    // # __MemTree_getParentOrNull__
    // @ __MemTree_getParentOrNull__
        struct __MemTree__* __MemTree_getParentOrNull__          ( struct __MemTree__ *tree);
    // # __MemTree_getParent__
    // @ __MemTree_getParent__
        void                __MemTree_getParent__                ( struct __MemTree__ **ret, struct __MemTree__ *tree);
    // # __MemTree_init__
    // @ __MemTree_init__
        void                __MemTree_init__                     ( struct __MemTree__ *t);
    // # __MemTree_popFirstChild__
    // @ __MemTree_popFirstChild__
        struct __MemTree__* __MemTree_popFirstChild__            ( struct __MemTree__  *tree);
    // # __MemTree_pushNext__
    // @ __MemTree_pushNext__
        void                __MemTree_pushNext__                 ( struct __MemTree__ *t, struct __MemTree__ *item);
    // # __MemTree_traverse__
    // @ __MemTree_traverse__
        struct __MemTree__* __MemTree_traverse__                 ( struct __MemTree__ *tree);
    // # __Mem_copyBackward__
    // @ __Mem_copyBackward__
        void                __Mem_copyBackward__                 ( char* dest, const char* src, size_t size);
    // # __Mem_copy__
    // @ __Mem_copy__
        void                __Mem_copy__                         ( char *dest, const char *src, size_t size);
    // # __Mem_find__
    // @ __Mem_find__
        bool                __Mem_find__                         ( size_t *ret_pos, const char *data, size_t data_len, const char *desired, size_t desired_len);
    // # __Mem_isEql__
    // @ __Mem_isEql__
        bool                __Mem_isEql__                        ( const char a[], const char b[], size_t len);
    // # __Nibble_fromAp__
    // @ __Nibble_fromAp__
        uint8_t             __Nibble_fromAp__                    (char data);
    // # __Nibble_fromHexNibble__
    // @ __Nibble_fromHexNibble__
        char                __Nibble_fromHexNibble__             ( char nibble);
    // # __OsConsoleInput_init__
    // @ __OsConsoleInput_init__
        void                __OsConsoleInput_init__              ( struct __OsConsoleInput__* t, __OsConsoleInputHandle__ input_hanle);
    // # __OsConsoleOutput_init__
    // @ __OsConsoleOutput_init__
        void                __OsConsoleOutput_init__             ( struct __OsConsoleOutput__* output, __OsConsoleOutputHandle__ handle);
    // # __OsConsoleOutput_write__
    // @ __OsConsoleOutput_write__
        bool                __OsConsoleOutput_write__            ( struct __OsConsoleOutput__*  os_console_output, const char* data, size_t _len);
    // # __OsFallbackConsole_write__
    // @ __OsFallbackConsole_write__
        size_t              __OsFallbackConsole_write__          ( void* unused_ctx, char* data, size_t len);
    // # __OsFile_clear__
    // @ __OsFile_clear__
        void                __OsFile_clear__                     ( __OsFileHandle__ file);
    // # __OsFile_close__
    // @ __OsFile_close__
        void                __OsFile_close__                     ( __OsFileHandle__ file);
    // # __OsFile_create__
    // @ __OsFile_create__
        bool                __OsFile_create__                    ( __OsFileHandle__ *ret, const char file_name[], size_t file_name_len);
    // # __OsFile_exist__
    // @ __OsFile_exist__
        bool                __OsFile_exist__                     ( const char* file_name, size_t file_name_len);
    // # __OsFile_getSize__
    // @ __OsFile_getSize__
        size_t              __OsFile_getSize__                   ( __OsFileHandle__ file);
    // # __OsFile_open__
    // @ __OsFile_open__
        bool                __OsFile_open__                      (__OsFileHandle__ *ret, const char file_name[], size_t file_name_len);
    // # __OsFile_readToBuffer__
    // @ __OsFile_readToBuffer__
        bool                __OsFile_readToBuffer__              ( __OsFileHandle__ file, char *buffer, size_t buffer_len, size_t offset);
    // # __OsFile_setPos__
    // @ __OsFile_setPos__
        void                __OsFile_setPos__                    ( __OsFileHandle__ file, size_t pos);
    // # __OsFile_truncate__
    // @ __OsFile_truncate__
        void                __OsFile_truncate__                  ( __OsFileHandle__ file);
    // # __OsFile_write__
    // @ __OsFile_write__
        bool                __OsFile_write__                     ( __OsFileHandle__ file, const char* data, size_t data_len, size_t offset);
    // # __OsHelper_deinit__
    // @ __OsHelper_deinit__
        void                __OsHelper_deinit__                  ( struct __OsHelper__*t);
    // # __OsHelper_init__
    // @ __OsHelper_init__
        bool                __OsHelper_init__                    ( struct __OsHelper__* t);
    // # __OsHelper_process__
    // @ __OsHelper_process__
        void                __OsHelper_process__                 ( struct __OsHelper__* t);
    // # __OsMem_alloc__
    // @ __OsMem_alloc__
        bool                __OsMem_alloc__                      ( uintptr_t *ret_data_addr, size_t size);
    // # __OsMem_free__
    // @ __OsMem_free__
        void                __OsMem_free__                       ( uintptr_t ret_data_addr);
    // # __Os_getTick__
    // @ __Os_getTick__
        uint64_t            __Os_getTick__                       ();
    // # __Os_sleep__
    // @ __Os_sleep__
        void __Os_sleep__( uint64_t ms);
    // # __TerminalInput_shift__
    // @ __TerminalInput_shift__
        void                __TerminalInput_shift__              ( struct __TerminalInput__ *t, size_t val);
    // # __Terminal_Output_Cursor_shiftDown__
    // @ __Terminal_Output_Cursor_shiftDown__
        void __Terminal_Output_Cursor_shiftDown__(struct __Terminal__ *terminal, size_t delta);
    // # __Terminal_Output_Cursor_shiftLeft__
    // @ __Terminal_Output_Cursor_shiftLeft__
        void __Terminal_Output_Cursor_shiftLeft__(struct __Terminal__ *terminal, size_t delta);
    // # __Terminal_Output_Cursor_shiftRight__
    // @ __Terminal_Output_Cursor_shiftRight__
        void __Terminal_Output_Cursor_shiftRight__(struct __Terminal__ *terminal, size_t delta);
    // # __Terminal_Output_Cursor_shiftUp__
    // @ __Terminal_Output_Cursor_shiftUp__
        void __Terminal_Output_Cursor_shiftUp__(struct __Terminal__ *terminal, size_t delta);
    // # __Terminal_cursorMove__
    // @ __Terminal_cursorMove__
        void                __Terminal_cursorMove__              ( struct __Terminal__ *terminal, size_t pos_x, size_t pos_y);
    // # __Terminal_moveCursorToStartOfLine__
    // @ __Terminal_moveCursorToStartOfLine__
        void                __Terminal_moveCursorToStartOfLine__ ( struct __Terminal__ *terminal);
    // # __Terminal_resetColors__
    // @ __Terminal_resetColors__
        void                __Terminal_resetColors__             ( struct __Terminal__  *terminal);
    // # __Terminal_setFontStyle__
    // @ __Terminal_setFontStyle__
        void                __Terminal_setFontStyle__            ( struct __Terminal__  *terminal, const char* font_style, size_t font_style_len);
    // # __Terminal_updateOutputSize__
    // @ __Terminal_updateOutputSize__
        void                __Terminal_updateOutputSize__        ( struct __Terminal__ *terminal);
    // # __Terminal_writeToOutput__
    // @ __Terminal_writeToOutput__
        void                __Terminal_writeToOutput__           ( struct __Terminal__ *terminal, const char *bytes, size_t bytes_len);
    // # __Terminal_writeToOutput__
    // @ __Terminal_writeToOutput__
        void                __Terminal_writeToOutput__           ( struct __Terminal__ *terminal, const char *bytes, size_t bytes_len);
    // # __TextAsciiSymbol_isBreakWord__
    // @ __TextAsciiSymbol_isBreakWord__
        bool                __TextAsciiSymbol_isBreakWord__      ( char symbol);
    // # __TextAsciiSymbol_isWord__
    // @ __TextAsciiSymbol_isWord__
        bool                __TextAsciiSymbol_isWord__           ( char symbol);
    // # __TextAscii_countIndent__
    // @ __TextAscii_countIndent__
        size_t              __TextAscii_countIndent__            ( const char *text, size_t text_len, size_t tabsize);
    // # __TextAscii_isVisible__
    // @ __TextAscii_isVisible__
        bool                __TextAscii_isVisible__              ( char byte);
    // # __Text_countIndent__
    // @ __Text_countIndent__
        size_t              __Text_countIndent__                 ( char* text, size_t text_len, size_t tab_size);
    // # __Text_formatU64ToBuffer__
    // @ __Text_formatU64ToBuffer__
        size_t              __Text_formatU64ToBuffer__           ( char *buffer, uint64_t number, size_t min_width);
    // # __ZText_countLen__
    // @ __ZText_countLen__
        size_t              __ZText_countLen__                   ( const char text[]);
    // # print_trace_example
    // @ print_trace_example
        void                print_trace_example                  ( int anyarg, struct __Trace__* prev_trace);
    // # real_main
    // @ real_main
        bool real_main(int args_len, char** args_ptr);
    // # tests
    // @ tests
        bool                tests                                ();
// globals
    // # __AppEditorViewsEasyMotionHorizontalContext_vtable__
        const struct __AppEditorViewsVTable__* __AppEditorViewsEasyMotionHorizontalContext_vtable__;
    // # __AppEditorViewsEasyMotionHorizontal_context__
        void*                                  __AppEditorViewsEasyMotionHorizontal_context__;
    // # __AppEditorViewsEasyMotionVertical_context__
1784
1785
1786
1787
1788
1789
1790
















































































1791
1792
1793
1794
1795
1796
1797
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







        void __AppEditorLine_setText__ (
            struct __AppEditorLine__  *line,
            char                      *text_ptr,
            size_t                    text_len  // expected < __AppEditorLineLen_max__
        ) {
            line->text_len = text_len;
            __Mem_copy__(&line->text[0], text_ptr, text_len);
        }
    // # __AppEditorListOfLine_writeToFile__
        bool
        __AppEditorListOfLine_writeToFile__(
            struct __MemList__ *lines,
            const char* file_name,
            size_t file_name_len
        ) {
            bool ok = true;
                if (lines->count == 0) {
                    ok = __FileComplete_clear__(file_name, file_name_len);
                
                } else if (lines->count == 1) {
                    struct __MemListLink__* link   = lines->first;
                    struct __AppEditorLine__* line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
                    if (line->text_len > 0) {
                        ok = __FileComplete_write__(file_name, file_name_len, &line->text[0], line->text_len);
                    } else {
                        ok = __FileComplete_clear__(file_name, file_name_len);
                    }
                
                } else { // lines > 1
                    const char* end_line = __app__.editor.__AppEditor_endLine__;
                    size_t end_line_len  = __app__.editor.__AppEditor_endLine_len__;
                    size_t full_len      = 0; // garanty > 0 becouse lines > 1
                    { // count fill len
                        struct __MemListLink__*   link = lines->first;
                        struct __AppEditorLine__* line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
                        full_len += line->text_len;
                        
                        link = link->next;
                        while (link) {
                            struct __AppEditorLine__* line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
                            full_len += end_line_len + line->text_len;
                            link = link->next;
                        }
                    } 
                    
                    char* buffer;
                    if (__AlignedPtr_allocAny__(&buffer, 4, full_len)) { // use aligned just for speed
                        // save to buffer
                        size_t writed = 0;
                        { // convert lines to one buffer
                            struct __MemListLink__* link = lines->first; // garanty not null by lines > 1
                            
                            // write first line
                                struct __AppEditorLine__* first_line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
                                if (first_line->text_len > 0) { 
                                    __Mem_copy__(&buffer[writed], &first_line->text[0], first_line->text_len);
                                    writed += first_line->text_len;
                                }
                            link = link->next;
                            
                            // write other lines
                            while (link) {
                                __Mem_copy__(&buffer[writed], end_line, end_line_len);
                                writed += end_line_len;
                                
                                struct __AppEditorLine__* line = __TypedPtr_getParentPtrFromFieldPtr__(struct __AppEditorLine__, link, link);
                                if (line->text_len > 0) {
                                    __Mem_copy__(&buffer[writed], &line->text[0], line->text_len);
                                    writed += line->text_len;
                                }
                                
                                link = link->next;
                            }
                        }
                        
                        // write to file
                        if (__FileComplete_write__(file_name, file_name_len, buffer, writed)) {
                        } else { // file not rewrited
                            ok = false;
                        }
                        
                        __AlignedPtr_freeAny__(buffer, full_len);
                    } else { // memory not allocated
                        ok = false;
                    }
                }
            return ok;
        }
    // # __AppEditor_addKeyToHistory__
        bool __AppEditor_addKeyToHistory__(
            struct __AppEditor__ *editor,
            __ConsoleAnsiInputKey__ key
        ) {
            bool ok = true;
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007



4008
4009
4010
4011
4012
4013
4014
4015
4089
4090
4091
4092
4093
4094
4095




4096
4097
4098

4099
4100
4101
4102
4103
4104
4105







-
-
-
-
+
+
+
-







        }
    // # __Terminal_setFontStyle__
        void __Terminal_setFontStyle__(
            struct __Terminal__  *terminal,
            const char* font_style,
            size_t font_style_len
        ) {
            if (terminal->output.font_style != font_style) {
                terminal->output.font_style = font_style;
                terminal->output.__TerminalOutput_fontStyleLen__ = font_style_len;
                __OsConsoleOutput_write__(&terminal->console->output, font_style, font_style_len);
            terminal->output.font_style = font_style;
            terminal->output.__TerminalOutput_fontStyleLen__ = font_style_len;
            __OsConsoleOutput_write__(&terminal->console->output, font_style, font_style_len);
            }
        }
    // # __Terminal_updateInputBuffer__
        void __Terminal_updateInputBuffer__(
            struct __Terminal__ *terminal
        ) {
            struct __Console__ *console = terminal->console;
            size_t unreaded = 0;