ScalpiEditor

Check-in [01a565dd63]
Login

Check-in [01a565dd63]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:oops fixed ctrl_down in treemode
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 01a565dd63ddeed269415f404bb31540ee2488278d3387f2ee3459548fdfe299
User & Date: Scalpi 2025-05-12 14:37:33.329
Context
2025-05-12
15:37
oops fixed __Buffer_removeIndent__ check-in: 5b1ffa55f9 user: Scalpi tags: trunk
14:37
oops fixed ctrl_down in treemode check-in: 01a565dd63 user: Scalpi tags: trunk
08:10
moved __AppEditorLine__ to C check-in: 09e095dc1f user: Scalpi tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to se.c.
226
227
228
229
230
231
232


233

234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
            // alt_spec
                #define __Scalpi_Console_ansi_input_Key_alt_comma__          (',' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_dot__            ('.' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_open_bracket__   ('[' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_close_bracket__  (']' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_semicolon__      (';' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_apostrophe__     ('`' + __Scalpi_Console_ansi_input_Key_alt__)


// settings

    // #define __target_os__ __TargetOs_
        #ifndef __target_os__
            #ifdef _WIN32
                #define __target_os__           __TargetOs_windows__
            #elif defined(__linux__)
                #define __target_os__           __TargetOs_linux__
            #endif
        #endif
        
        #if __target_os__ == __TargetOs_windows__
        #elif __target_os__ == __TargetOs_linux__
        #else
            #error "__target_os__ not implemented"
        #endif
        
    #define __target_memory_type__        __TargetMemoryType_endiansLittle__
    #define __with_network__              0
    #define __OsFilePathLen_max__         1024
    #define __ScalpiTerminalInput_size__  32
    
    // App
        #define __AppEditorLineLen_max__  (1024 * 8)
        #define App_expected_fps          30
// imports
    // libC







>
>

>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
            // alt_spec
                #define __Scalpi_Console_ansi_input_Key_alt_comma__          (',' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_dot__            ('.' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_open_bracket__   ('[' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_close_bracket__  (']' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_semicolon__      (';' + __Scalpi_Console_ansi_input_Key_alt__)
                #define __Scalpi_Console_ansi_input_Key_alt_apostrophe__     ('`' + __Scalpi_Console_ansi_input_Key_alt__)
    // websocket
        #define __ScalpiNetworkTcpHttpWebSocketHandShake_encoded_text_len__ 28
// settings
    // platform
        // #define __target_os__ __TargetOs_
            #ifndef __target_os__
                #ifdef _WIN32
                    #define __target_os__           __TargetOs_windows__
                #elif defined(__linux__)
                    #define __target_os__           __TargetOs_linux__
                #endif
            #endif
            
            #if __target_os__ == __TargetOs_windows__
            #elif __target_os__ == __TargetOs_linux__
            #else
                #error "__target_os__ not implemented"
            #endif
            
        #define __target_memory_type__        __TargetMemoryType_endiansLittle__
        #define __with_network__              0
        #define __OsFilePathLen_max__         1024
    #define __ScalpiTerminalInput_size__  32
    
    // App
        #define __AppEditorLineLen_max__  (1024 * 8)
        #define App_expected_fps          30
// imports
    // libC
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326

327
328
329
330
331
332
333
334
335
336
337
        #include <uchar.h>
        #include <wchar.h>
        #include <wctype.h>
    
    #if __target_os__ == __TargetOs_windows__
        // posix
            #include <fcntl.h>
        
        // Windows
            #include <windef.h>
            #include <windows.h>
            #include <winuser.h>
            #include <commctrl.h>
            #include <io.h>
            #include <conio.h>
            
            // HACK for zig 0.14
            #define INVALID_HANDLE_VALUE  (HANDLE)0xFFFFFFFF
        
        #if __with_network__
            #include <ws2tcpip.h>
            #include <winsock2.h>
        #endif
    
    #elif __target_os__ == __TargetOs_linux__
        #include <fcntl.h>
        #include <sys/ioctl.h>
        #include <sys/stat.h>
        #include <termios.h>
        #include <unistd.h>
        #include <time.h>
        
        #if __with_network__
            #include <arpa/inet.h>
            #include <netinet/in.h>
            #include <netinet/ip.h>
            #include <sys/socket.h>
        #endif
    
    #endif
// strings
    #define Scalpi_Text_CharsDecFromU64_MAX_LEN  TEXT_LEN("18446744073709551615")
    // Scalpi_Console_ansi
        #define Scalpi_Console_ansi_esc                          "\x1B"
        #define __ScalpiConsoleAnsi_control__                      Scalpi_Console_ansi_esc "["

        #define Scalpi_Console_ansi_output_clear_to_end_line     __ScalpiConsoleAnsi_control__ "0K"
        #define Scalpi_Console_ansi_output_clear_to_start_line   __ScalpiConsoleAnsi_control__ "1K"
        #define Scalpi_Console_ansi_output_clear_line            __ScalpiConsoleAnsi_control__ "2K"
        
        // cursor
            #define Scalpi_Console_ansi_output_cursor_hide                     __ScalpiConsoleAnsi_control__ "?25l"
            #define Scalpi_Console_ansi_output_cursor_show                     __ScalpiConsoleAnsi_control__ "?25h"
            
            #define __ScalpiConsoleAnsiOutputCursorStyle_reset__              __ScalpiConsoleAnsi_control__ "0 q"
            #define Scalpi_Console_ansi_output_cursor_style_blinking_block     __ScalpiConsoleAnsi_control__ "1 q"
            #define Scalpi_Console_ansi_output_cursor_style_steady_block       __ScalpiConsoleAnsi_control__ "2 q"







<















<














<


|



>
|
|
|
|







285
286
287
288
289
290
291

292
293
294
295
296
297
298
299
300
301
302
303
304
305
306

307
308
309
310
311
312
313
314
315
316
317
318
319
320

321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
        #include <uchar.h>
        #include <wchar.h>
        #include <wctype.h>
    
    #if __target_os__ == __TargetOs_windows__
        // posix
            #include <fcntl.h>

        // Windows
            #include <windef.h>
            #include <windows.h>
            #include <winuser.h>
            #include <commctrl.h>
            #include <io.h>
            #include <conio.h>
            
            // HACK for zig 0.14
            #define INVALID_HANDLE_VALUE  (HANDLE)0xFFFFFFFF
        
        #if __with_network__
            #include <ws2tcpip.h>
            #include <winsock2.h>
        #endif

    #elif __target_os__ == __TargetOs_linux__
        #include <fcntl.h>
        #include <sys/ioctl.h>
        #include <sys/stat.h>
        #include <termios.h>
        #include <unistd.h>
        #include <time.h>
        
        #if __with_network__
            #include <arpa/inet.h>
            #include <netinet/in.h>
            #include <netinet/ip.h>
            #include <sys/socket.h>
        #endif

    #endif
// strings
    #define Scalpi_Text_CharsDecFromU64_MAX_LEN  __CTextLen__("18446744073709551615")
    // Scalpi_Console_ansi
        #define Scalpi_Console_ansi_esc                          "\x1B"
        #define __ScalpiConsoleAnsi_control__                      Scalpi_Console_ansi_esc "["
        // clear_output
            #define Scalpi_Console_ansi_output_clear_to_end_line     __ScalpiConsoleAnsi_control__ "0K"
            #define Scalpi_Console_ansi_output_clear_to_start_line   __ScalpiConsoleAnsi_control__ "1K"
            #define Scalpi_Console_ansi_output_clear_line            __ScalpiConsoleAnsi_control__ "2K"
            
        // cursor
            #define Scalpi_Console_ansi_output_cursor_hide                     __ScalpiConsoleAnsi_control__ "?25l"
            #define Scalpi_Console_ansi_output_cursor_show                     __ScalpiConsoleAnsi_control__ "?25h"
            
            #define __ScalpiConsoleAnsiOutputCursorStyle_reset__              __ScalpiConsoleAnsi_control__ "0 q"
            #define Scalpi_Console_ansi_output_cursor_style_blinking_block     __ScalpiConsoleAnsi_control__ "1 q"
            #define Scalpi_Console_ansi_output_cursor_style_steady_block       __ScalpiConsoleAnsi_control__ "2 q"
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
            
            #define Scalpi_Console_ansi_output_FontStyle_start                 __ScalpiConsoleAnsi_control__
            #define __ScalpiConsoleAnsiOutputFontStyle_reset__                 Scalpi_Console_ansi_output_FontStyle_start Scalpi_Console_ansi_output_FontStyle_reset Scalpi_Console_ansi_output_FontStyle_end
        
        // mouse
            #define Scalpi_ansi_input_mouse_release  __ScalpiConsoleAnsi_control__  "?1000l"
            #define Scalpi_ansi_input_mouse_grab     __ScalpiConsoleAnsi_control__  "?1000h"
        
        #define __ScalpiConsoleAnsiOutputSettings_enableLineWrap__   __ScalpiConsoleAnsi_control__ "?7h"
        #define __ScalpiConsoleAnsiOutputSettings_disableLineWrap__  __ScalpiConsoleAnsi_control__ "?7l"
    // __OsFilePath_separator__
        #if __target_os__ == __TargetOs_windows__
            #define __OsFilePath_separator__ "\\"
        
        #elif __target_os__ == __TargetOs_linux__
            #define __OsFilePath_separator__ "/"
        







|
|
|







395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
            
            #define Scalpi_Console_ansi_output_FontStyle_start                 __ScalpiConsoleAnsi_control__
            #define __ScalpiConsoleAnsiOutputFontStyle_reset__                 Scalpi_Console_ansi_output_FontStyle_start Scalpi_Console_ansi_output_FontStyle_reset Scalpi_Console_ansi_output_FontStyle_end
        
        // mouse
            #define Scalpi_ansi_input_mouse_release  __ScalpiConsoleAnsi_control__  "?1000l"
            #define Scalpi_ansi_input_mouse_grab     __ScalpiConsoleAnsi_control__  "?1000h"
        // settings
            #define __ScalpiConsoleAnsiOutputSettings_enableLineWrap__   __ScalpiConsoleAnsi_control__ "?7h"
            #define __ScalpiConsoleAnsiOutputSettings_disableLineWrap__  __ScalpiConsoleAnsi_control__ "?7l"
    // __OsFilePath_separator__
        #if __target_os__ == __TargetOs_windows__
            #define __OsFilePath_separator__ "\\"
        
        #elif __target_os__ == __TargetOs_linux__
            #define __OsFilePath_separator__ "/"
        
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478

479
480
481
482
483
484
485
486
487
488
489
            #elif __target_os__ == __TargetOs_linux__
                typedef int __OsNetworkTcpHandle__;
            #else
                #error "__target_os__ not implemented"
            #endif
// macroses
    // c
        #define or  ||
        #define and &&
        #define toAddr(ptr) ((uintptr_t)(ptr))
        #define ptrFromInt(type, number) ((type*)number)
        #define getPtr(obj, field) (&((obj)->field))
        #define getField(ptr, offset, type) (* (*type) ( toAddr(ptr) + offset ) )
        #define OFFSETOF(type, field) (toAddr(getPtr(ptrFromInt(type, 0), field))
        #define FIELD_PARENT_PTR(type, field, instance) ((type *)(toAddr(instance) - OFFSETOF(type, field)))
        #define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
        #define TEXT_LEN(str) (ARRAY_LEN(str) - 1)
    // text

        #define SLICE_TEXT(text) {.ptr=text, .len=TEXT_LEN(text)}
        #define TEXT_PTR(text) (char(*)[TEXT_LEN(text)]) text
        #define DEF_TEXT_PTR(name, text) char(*name)[TEXT_LEN(text)] = TEXT_PTR(text)
        #define DEF_SLICE_TEXT(name, text) struct Slice name = SLICE_TEXT(text)
    // crypto
        #define Sha1_block_size 64
        #define Sha1_digest_length 20
    // Network
        
        #define max_allowed_listen_port 49151
        #define PRISOCK "%llx"







|
|
|
|
|
|
|
|
|
<

>
|
|
|
|







462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477

478
479
480
481
482
483
484
485
486
487
488
489
490
            #elif __target_os__ == __TargetOs_linux__
                typedef int __OsNetworkTcpHandle__;
            #else
                #error "__target_os__ not implemented"
            #endif
// macroses
    // c
        #define or   ||
        #define and  &&
        #define __addrFromPtr__(ptr)               ((uintptr_t)(ptr))
        #define __ptrFromInt__(type, number)       ((type*)number)
        #define __getFieldPtr__(obj, field)        (&((obj)->field))
        #define __getField__(ptr, offset, type)    (* (*type) ( __addrFromPtr__(ptr) + offset ) )
        #define __alignOf__(type)                  (offsetof(struct { char c; type member; }, member))
        #define __fieldParentPtr__(type, field, instance)  ((type *)(__addrFromPtr__(instance) - offsetof(type, field)))
        #define __arrayLen__(array)                (sizeof(array) / sizeof(array[0]))

    // text
        #define __CTextLen__(str)                  (__arrayLen__(str) - 1)
        #define __Slice_fromCText__(text)          {.ptr=text, .len=__CTextLen__(text)}
        #define __CTextPtr_fromCText__(text)       ((char(*)[__CTextLen__(text)]) text)
        #define __CTextPtr_lvalue__(name, text)    (char(*name)[__CTextLen__(text)])
        #define __CTextPtr_declare__(name, text)   __CTextPtr_lvalue__(name, text) = __CTextPtr_fromCText__(text)
    // crypto
        #define Sha1_block_size 64
        #define Sha1_digest_length 20
    // Network
        
        #define max_allowed_listen_port 49151
        #define PRISOCK "%llx"
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_medium_header (Scalpi_network_tcp_http_WebSocket_Header_Size_small_header + Scalpi_network_tcp_http_WebSocket_Header_Size_medium_extended_payload_len_size)
            
            // 10 bytes header for sizes more than 65535
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_long 2
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_long_flag 127
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_long_extended_payload_len_size 8
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_long_header (Scalpi_network_tcp_http_WebSocket_Header_Size_small_header + Scalpi_network_tcp_http_WebSocket_Header_Size_long_extended_payload_len_size)
    // App
        #define App_delay_to_start_frame_target (Scalpi_time_ms_per_s / App_expected_fps)
// structs
    // core
        // memory
            // __AlignedPtr__
                // is pointer to data. but after data placed offset to origingal allocated pointer
                //          | data_size |   u8               |
                // original |    data   |   offsetToOriginal |







<
<







519
520
521
522
523
524
525


526
527
528
529
530
531
532
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_medium_header (Scalpi_network_tcp_http_WebSocket_Header_Size_small_header + Scalpi_network_tcp_http_WebSocket_Header_Size_medium_extended_payload_len_size)
            
            // 10 bytes header for sizes more than 65535
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_long 2
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_long_flag 127
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_long_extended_payload_len_size 8
                #define Scalpi_network_tcp_http_WebSocket_Header_Size_long_header (Scalpi_network_tcp_http_WebSocket_Header_Size_small_header + Scalpi_network_tcp_http_WebSocket_Header_Size_long_extended_payload_len_size)


// structs
    // core
        // memory
            // __AlignedPtr__
                // is pointer to data. but after data placed offset to origingal allocated pointer
                //          | data_size |   u8               |
                // original |    data   |   offsetToOriginal |
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
                    /// 127.  0.  0.  1:27015
                    ///   0.  0.  0.  1:    0
                    char buffer[25];
                    size_t len;
                };
                
            #if __with_network__
            struct Scalpi_network_tcp_Visitor {
                __OsNetworkTcpHandle__        socket_handle;
                struct Scalpi_network_tcp_Ip  ip;
                struct sockaddr_in            addr;
            };
            #endif
            
            struct Scalpi_network_tcp_Server {
                bool                    ready;
                __OsNetworkTcpHandle__  socket_handle;
                size_t                  max_waiting_clients;
                uint16_t                port;







|
|
|
|
|







726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
                    /// 127.  0.  0.  1:27015
                    ///   0.  0.  0.  1:    0
                    char buffer[25];
                    size_t len;
                };
                
            #if __with_network__
                struct Scalpi_network_tcp_Visitor {
                    __OsNetworkTcpHandle__        socket_handle;
                    struct Scalpi_network_tcp_Ip  ip;
                    struct sockaddr_in            addr;
                };
            #endif
            
            struct Scalpi_network_tcp_Server {
                bool                    ready;
                __OsNetworkTcpHandle__  socket_handle;
                size_t                  max_waiting_clients;
                uint16_t                port;
1604
1605
1606
1607
1608
1609
1610

1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655

1656



1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
                            
                            #endif
                            
                        return ok;
                    }
                
            // ConsoleIntput

                bool __OsConsoleInput_readByte__(struct __OsConsoleInput__* t, char* byte) {
                    bool ok = true;
                        #if __target_os__ == __TargetOs_windows__
                            INPUT_RECORD key;
                            DWORD picked = 0;
                            if ( ReadConsoleInputA(t->handle, &key, 1, &picked) ) {
                                if (picked != 0) {
                                    if (key.EventType == KEY_EVENT) {
                                        KEY_EVENT_RECORD *event = &key.Event.KeyEvent;
                                        if (event->bKeyDown != 0) {
                                            if (event->uChar.AsciiChar != 0) {
                                                *byte = event->uChar.AsciiChar;
                                            } else {ok = false;}
                                        } else {ok = false;}
                                    } else {ok = false;}
                                } else {ok = false;}
                            } else {ok = false;}
                        #elif __target_os__ == __TargetOs_linux__
                            ssize_t result = read(t->fileno, byte, 1);
                            if (result != 1) {ok = false;}
                        #else
                            #error "__target_os__ not implemented"
                        #endif
                    return ok;
                }
                
                bool __OsConsoleInput_getCountOfUnreaded__(struct __OsConsoleInput__*  t, size_t *ret_unreaded) {
                    bool ok = true;
                        #if __target_os__ == __TargetOs_windows__
                            DWORD unreaded = 0;
                            if ( GetNumberOfConsoleInputEvents(t->handle, &unreaded) ) {
                                *ret_unreaded += unreaded;
                            } else {
                                ok = false;
                            }
                        #elif __target_os__ == __TargetOs_linux__
                            int unreaded = 0;
                            int result = ioctl(t->fileno, FIONREAD, &unreaded);
                            *ret_unreaded += unreaded;
                        #else
                            #error "__target_os__ not implemented"
                        #endif
                    return ok;
                }
                

                void __OsConsoleInput_init__(struct __OsConsoleInput__* t, __OsConsoleInputHandle__ input_hanle) {



                    #if __target_os__ == __TargetOs_windows__
                        t->handle = input_hanle;
                    #elif __target_os__ == __TargetOs_linux__
                        t->handle = input_hanle;
                        t->fileno = fileno(t->handle);
                    #else
                        #error "__target_os__ not implemented"
                    #endif
                }
                
            // Flags
                uint32_t __ScalpiBitsU32_enable__(uint32_t value, uint32_t mask) {
                    return value | mask;
                }
                
                uint32_t __ScalpiBitsU32_disable__(uint32_t value, uint32_t mask) {







>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

>
|
>
>
>
|
|
|
|
|
|
|
|
|







1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
                            
                            #endif
                            
                        return ok;
                    }
                
            // ConsoleIntput
                // var __OsConsoleInput_readByte__
                    bool __OsConsoleInput_readByte__(struct __OsConsoleInput__* t, char* byte) {
                        bool ok = true;
                            #if __target_os__ == __TargetOs_windows__
                                INPUT_RECORD key;
                                DWORD picked = 0;
                                if ( ReadConsoleInputA(t->handle, &key, 1, &picked) ) {
                                    if (picked != 0) {
                                        if (key.EventType == KEY_EVENT) {
                                            KEY_EVENT_RECORD *event = &key.Event.KeyEvent;
                                            if (event->bKeyDown != 0) {
                                                if (event->uChar.AsciiChar != 0) {
                                                    *byte = event->uChar.AsciiChar;
                                                } else {ok = false;}
                                            } else {ok = false;}
                                        } else {ok = false;}
                                    } else {ok = false;}
                                } else {ok = false;}
                            #elif __target_os__ == __TargetOs_linux__
                                ssize_t result = read(t->fileno, byte, 1);
                                if (result != 1) {ok = false;}
                            #else
                                #error "__target_os__ not implemented"
                            #endif
                        return ok;
                    }
                // var __OsConsoleInput_getCountOfUnreaded__
                    bool __OsConsoleInput_getCountOfUnreaded__(struct __OsConsoleInput__*  t, size_t *ret_unreaded) {
                        bool ok = true;
                            #if __target_os__ == __TargetOs_windows__
                                DWORD unreaded = 0;
                                if ( GetNumberOfConsoleInputEvents(t->handle, &unreaded) ) {
                                    *ret_unreaded += unreaded;
                                } else {
                                    ok = false;
                                }
                            #elif __target_os__ == __TargetOs_linux__
                                int unreaded = 0;
                                int result = ioctl(t->fileno, FIONREAD, &unreaded);
                                *ret_unreaded += unreaded;
                            #else
                                #error "__target_os__ not implemented"
                            #endif
                        return ok;
                    }
                
                // var __OsConsoleInput_init__
                    void __OsConsoleInput_init__(
                        struct __OsConsoleInput__* t,
                        __OsConsoleInputHandle__ input_hanle
                    ) {
                        #if __target_os__ == __TargetOs_windows__
                            t->handle = input_hanle;
                        #elif __target_os__ == __TargetOs_linux__
                            t->handle = input_hanle;
                            t->fileno = fileno(t->handle);
                        #else
                            #error "__target_os__ not implemented"
                        #endif
                    }
                
            // Flags
                uint32_t __ScalpiBitsU32_enable__(uint32_t value, uint32_t mask) {
                    return value | mask;
                }
                
                uint32_t __ScalpiBitsU32_disable__(uint32_t value, uint32_t mask) {
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
                #elif __target_os__ == __TargetOs_linux__
                    // nothing to do
                #else
                    #error "__target_os__ not implemented"
                #endif
            }
    // Scalpi
        // mem
            // var __Text_countIndent__
                size_t
                __Text_countIndent__(
                    char*   text,
                    size_t  text_len, // can be 0
                    size_t  tab_size
                ) {







|







1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
                #elif __target_os__ == __TargetOs_linux__
                    // nothing to do
                #else
                    #error "__target_os__ not implemented"
                #endif
            }
    // Scalpi
        // text
            // var __Text_countIndent__
                size_t
                __Text_countIndent__(
                    char*   text,
                    size_t  text_len, // can be 0
                    size_t  tab_size
                ) {
1928
1929
1930
1931
1932
1933
1934

1935
1936
1937
1938
1939
1940
1941
                        } else {
                            break;
                        }
                        pos = pos + 1;
                    }
                    return counted;
                }

            // var __Buffer_push__
                void __Buffer_push__(
                    char    *buffer,
                    size_t  *buffer_used,   // expected < allocated
                    size_t  pos,            // expected < allocated
                    char    item
                ) {







>







1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
                        } else {
                            break;
                        }
                        pos = pos + 1;
                    }
                    return counted;
                }
        // Buffer
            // var __Buffer_push__
                void __Buffer_push__(
                    char    *buffer,
                    size_t  *buffer_used,   // expected < allocated
                    size_t  pos,            // expected < allocated
                    char    item
                ) {
2121
2122
2123
2124
2125
2126
2127


























2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150










2151
2152
2153
2154
2155
2156
2157
                        item->prev  = 0;
                    }
                    before->prev = item;
                    item->next   = before;
                    item->list   = list;
                    list->count += 1;
                }


























        // Scalpi_Logger
            void Scalpi_Logger_init (struct Scalpi_Logger* t) {
                for (int i = 0; i < ARRAY_LEN(t->writers); i++) {
                    struct __Scalpi_Writer__* w = &t->writers[i];
                    w->context = 0;
                    w->write = 0;
                }
            }
            
            void __ScalpiLogger_writeToSelf__(struct Scalpi_Logger* t, const char bytes[], size_t len) {
                for (size_t i = 0; i < ARRAY_LEN(t->writers); i++) {
                    struct __Scalpi_Writer__* w = &t->writers[i];
                    if (w->write) {
                        size_t writed = w->write(w->context, bytes, len);
                    }
                }
            }
        // __ScalpiTerminalOutput_CursorPos__
            void __ScalpiTerminalOutputCursorPos_init__(__ScalpiTerminalOutput_CursorPos__ *cursor_pos) {
                cursor_pos->x = 0;
                cursor_pos->y = 0;
            }
    // App










        // struct App
            bool App_init(struct App* t) {
                bool ok = true;
                    Scalpi_Logger_init(&t->logger); // preinit console output for debug
                    
                    if (__OsHelper_init__(&t->__App_osHelper__)) {
                        t->tick = __os_getTick__();







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|







|












>
>
>
>
>
>
>
>
>
>







2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
                        item->prev  = 0;
                    }
                    before->prev = item;
                    item->next   = before;
                    item->list   = list;
                    list->count += 1;
                }
            char Scalpi_crypto_sumBytes(char* data, size_t data_len) {
                char ret = 0;
                for (size_t pos = 0; pos < data_len; pos++) {
                    ret += data[pos];
                }
                return ret;
            }
            
            char Scalpi_crypto_xorBytes(char* data, size_t data_len) {
                char ret = 0;
                for (size_t pos = 0; pos < data_len; pos++) {
                    ret ^= data[pos];
                }
                return ret;
            }
            
            void Scalpi_crypto_xorCyclic(char* dest, char* a, size_t dest_len, char* b, size_t b_len) {
                // expected dest_len == a.len
                size_t ci = 0; // cyclical iterator
                for (size_t pos = 0; pos < dest_len; pos++) {
                    dest[pos] = a[pos] ^ b[ci];
                    ci += 1;
                    if (ci == b_len) ci = 0;
                }
            }
            
        // Scalpi_Logger
            void Scalpi_Logger_init (struct Scalpi_Logger* t) {
                for (int i = 0; i < __arrayLen__(t->writers); i++) {
                    struct __Scalpi_Writer__* w = &t->writers[i];
                    w->context = 0;
                    w->write = 0;
                }
            }
            
            void __ScalpiLogger_writeToSelf__(struct Scalpi_Logger* t, const char bytes[], size_t len) {
                for (size_t i = 0; i < __arrayLen__(t->writers); i++) {
                    struct __Scalpi_Writer__* w = &t->writers[i];
                    if (w->write) {
                        size_t writed = w->write(w->context, bytes, len);
                    }
                }
            }
        // __ScalpiTerminalOutput_CursorPos__
            void __ScalpiTerminalOutputCursorPos_init__(__ScalpiTerminalOutput_CursorPos__ *cursor_pos) {
                cursor_pos->x = 0;
                cursor_pos->y = 0;
            }
    // App
        bool __AppEditorHistoryNote_alloc__(
            struct __AppEditorHistoryNote__* *ptr
        ) {
            return __AlignedPtr_alloc__( 
                ptr,
                __alignOf__(struct __AppEditorHistoryNote__),
                sizeof(struct __AppEditorHistoryNote__)
            );
        }
        
        // struct App
            bool App_init(struct App* t) {
                bool ok = true;
                    Scalpi_Logger_init(&t->logger); // preinit console output for debug
                    
                    if (__OsHelper_init__(&t->__App_osHelper__)) {
                        t->tick = __os_getTick__();
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
            bool App_process(struct App* t) {
                bool ok = true;
                    __OsHelper_process__(&t->__App_osHelper__);
                return ok;
            }
            
            void App_waitToNextFrame(struct App* t) {
                uint64_t expected_frame_end_time = t->tick + App_delay_to_start_frame_target;
                uint64_t resulting_frame_end_time = __os_getTick__();
                if (resulting_frame_end_time > expected_frame_end_time + 120) {
                    uint64_t delta = resulting_frame_end_time - expected_frame_end_time;
                    printf("%d \t  hitch detection: %zu delta: %zu ms \r\n", __LINE__, t->tick, delta);
                }
                uint64_t delay_sleep = 1;
                if (resulting_frame_end_time < expected_frame_end_time) {







|







2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
            bool App_process(struct App* t) {
                bool ok = true;
                    __OsHelper_process__(&t->__App_osHelper__);
                return ok;
            }
            
            void App_waitToNextFrame(struct App* t) {
                uint64_t expected_frame_end_time = t->tick + Scalpi_time_ms_per_s / App_expected_fps;
                uint64_t resulting_frame_end_time = __os_getTick__();
                if (resulting_frame_end_time > expected_frame_end_time + 120) {
                    uint64_t delta = resulting_frame_end_time - expected_frame_end_time;
                    printf("%d \t  hitch detection: %zu delta: %zu ms \r\n", __LINE__, t->tick, delta);
                }
                uint64_t delay_sleep = 1;
                if (resulting_frame_end_time < expected_frame_end_time) {
Changes to se.zig.
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
                                        t.bakup_line.text_len = t.line.text_len;
                                        c.__ScalpiMem_copy__(&t.bakup_line.text[0], &t.line.text[0], t.line.text_len);
                                    }
                                }
                                
                                fn restore(t: *@This()) !void {
                                    var text: []u8 = "";
                                    if (t.bakup_line.text_len > 0) text = t.bakup_line.text[0 .. t.line.text_len];
                                    __AppEditorLine_setText__(t.line, text.ptr, text.len);
                                    t.need_redraw = true;
                                }
                            // change view
                                fn setAsView(t: *@This()) !void {
                                    global_app.editor.do_ptr = &@This().do;
                                    global_app.editor.onKey_ptr = &@This().onKey;







|







287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
                                        t.bakup_line.text_len = t.line.text_len;
                                        c.__ScalpiMem_copy__(&t.bakup_line.text[0], &t.line.text[0], t.line.text_len);
                                    }
                                }
                                
                                fn restore(t: *@This()) !void {
                                    var text: []u8 = "";
                                    if (t.bakup_line.text_len > 0) text = t.bakup_line.text[0 .. t.bakup_line.text_len];
                                    __AppEditorLine_setText__(t.line, text.ptr, text.len);
                                    t.need_redraw = true;
                                }
                            // change view
                                fn setAsView(t: *@This()) !void {
                                    global_app.editor.do_ptr = &@This().do;
                                    global_app.editor.onKey_ptr = &@This().onKey;
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
                                fn onKey(ctx: ?*anyopaque, cik: c.__ScalpiConsoleAnsiInputKey__) void {
                                    onkeyWrap(ctx, cik) catch {};
                                }
                                
                                fn onkeyWrap(ctx: ?*anyopaque, cik: c.__ScalpiConsoleAnsiInputKey__) !void {
                                    const t: *@This() = @ptrCast(@alignCast(ctx));
                                    switch (cik) {
                                        c.__Scalpi_Console_ansi_input_Key_escape__ => t.goToOut(),
                                        c.__Scalpi_Console_ansi_input_Key_tab__ => t.goToIn(),
                                        
                                        // modes
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_e__ => try t.unFold(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_q__ => try global_app.editor.stop(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_s__ => t.save() catch {},
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_j__ => try t.joinLines(),
                                        c.__Scalpi_Console_ansi_input_Key_enter__ => t.divide() catch {},
                                        c.__Scalpi_Console_ansi_input_Key_back_space__ => try t.deletePrevSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_bs__ => try t.deletePrevSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_d__ => try t.duplicate(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_x__ => try t.cut(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_c__ => try t.duplicateAndCut(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_v__ => t.pasteLine() catch {},
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_t__ => t.insertSymbol('\t') catch {},
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_w__ => try t.deleteWord(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_z__ => try t.restore(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_f__ => t.toFind() catch {},
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_g__ => t.toGoTo(),
                                        c.__Scalpi_Console_ansi_input_Key_up__ => t.goToPrevLine(),
                                        c.__Scalpi_Console_ansi_input_Key_down__ => t.goToNextLine(),
                                        c.__Scalpi_Console_ansi_input_Key_left__ => t.goToPrevSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_right__ => t.goToNextSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_shift_left__ => t.CtrlShiftLeft(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_shift_right__ => t.CtrlShiftRight(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_left__ => t.ctrlLeft(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_right__ => t.ctrlRight(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_up__ => t.goToFirstLine(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_down__ => t.goToLastLine(),
                                        
                                        // alternative navigation
                                        c.__Scalpi_Console_ansi_input_Key_alt_w__ => t.goToPrevLine(),
                                        c.__Scalpi_Console_ansi_input_Key_alt_s__ => t.goToNextLine(),
                                        c.__Scalpi_Console_ansi_input_Key_alt_a__ => t.goToPrevSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_alt_d__ => t.goToNextSymbol(),
                                        







|
|


|
|
|
|
|


|
|
|
|
|
|
|
|
|
|
|
|
|
|

|

|
|







3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
                                fn onKey(ctx: ?*anyopaque, cik: c.__ScalpiConsoleAnsiInputKey__) void {
                                    onkeyWrap(ctx, cik) catch {};
                                }
                                
                                fn onkeyWrap(ctx: ?*anyopaque, cik: c.__ScalpiConsoleAnsiInputKey__) !void {
                                    const t: *@This() = @ptrCast(@alignCast(ctx));
                                    switch (cik) {
                                        c.__Scalpi_Console_ansi_input_Key_escape__  => t.goToOut(),
                                        c.__Scalpi_Console_ansi_input_Key_tab__     => t.goToIn(),
                                        
                                        // modes
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_e__  => try t.unFold(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_q__  => try global_app.editor.stop(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_s__  => t.save() catch {},
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_j__  => try t.joinLines(),
                                        c.__Scalpi_Console_ansi_input_Key_enter__   => t.divide() catch {},
                                        c.__Scalpi_Console_ansi_input_Key_back_space__ => try t.deletePrevSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_bs__ => try t.deletePrevSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_d__  => try t.duplicate(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_x__  => try t.cut(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_c__  => try t.duplicateAndCut(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_v__  => t.pasteLine() catch {},
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_t__  => t.insertSymbol('\t') catch {},
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_w__  => try t.deleteWord(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_z__  => try t.restore(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_f__  => t.toFind() catch {},
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_g__  => t.toGoTo(),
                                        c.__Scalpi_Console_ansi_input_Key_up__      => t.goToPrevLine(),
                                        c.__Scalpi_Console_ansi_input_Key_down__    => t.goToNextLine(),
                                        c.__Scalpi_Console_ansi_input_Key_left__    => t.goToPrevSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_right__   => t.goToNextSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_shift_left__  => t.CtrlShiftLeft(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_shift_right__ => t.CtrlShiftRight(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_left__  => t.ctrlLeft(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_right__ => t.ctrlRight(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_up__    => t.goToFirstLine(),
                                        c.__Scalpi_Console_ansi_input_Key_ctrl_down__  => t.goToLastLine(),
                                        
                                        // alternative navigation
                                        c.__Scalpi_Console_ansi_input_Key_alt_w__ => t.goToPrevLine(),
                                        c.__Scalpi_Console_ansi_input_Key_alt_s__ => t.goToNextLine(),
                                        c.__Scalpi_Console_ansi_input_Key_alt_a__ => t.goToPrevSymbol(),
                                        c.__Scalpi_Console_ansi_input_Key_alt_d__ => t.goToNextSymbol(),
                                        
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
                                            t.need_redraw = true;
                                            t.bakup();
                                        }
                                    }
                                    
                                    fn goToLastLine(t: *@This()) void {
                                        const current = &t.line.tree;
                                        if (@intFromPtr(current.parent) == @intFromPtr(c.NULL)) {
                                            const parent: *c.__ScalpiMemTree__       = @ptrCast(current.parent);
                                            const list:   *c.__ScalpiMemList__     = &parent.childs;
                                            const link:   *c.__ScalpiMemListLink__ = list.last orelse unreachable;
                                            const tree:   *c.__ScalpiMemTree__       = @fieldParentPtr("link", link);
                                            const line:   *c.__AppEditorLine__       = @fieldParentPtr("tree", tree);
                                            
                                            t.line = line;
                                            t.goToStartOfText();
                                            t.offset.y = (global_app.terminal.output.size.y >> 1) + (global_app.terminal.output.size.y >> 2);
                                            t.need_redraw = true;







|

|
|







3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
                                            t.need_redraw = true;
                                            t.bakup();
                                        }
                                    }
                                    
                                    fn goToLastLine(t: *@This()) void {
                                        const current = &t.line.tree;
                                        if (@intFromPtr(current.parent) != @intFromPtr(c.NULL)) {
                                            const parent: *c.__ScalpiMemTree__       = @ptrCast(current.parent);
                                            const list:   *c.__ScalpiMemList__       = &parent.childs;
                                            const link:   *c.__ScalpiMemListLink__   = list.last orelse unreachable;
                                            const tree:   *c.__ScalpiMemTree__       = @fieldParentPtr("link", link);
                                            const line:   *c.__AppEditorLine__       = @fieldParentPtr("tree", tree);
                                            
                                            t.line = line;
                                            t.goToStartOfText();
                                            t.offset.y = (global_app.terminal.output.size.y >> 1) + (global_app.terminal.output.size.y >> 2);
                                            t.need_redraw = true;
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
                                            t.goToSymbol(t.symbol + indent);
                                            t.need_redraw = true;
                                            return;
                                        }
                                        t.goToSymbol(Scalpi.Text.findBreakOfWord(text) + t.symbol + 1);
                                        t.need_redraw = true;
                                    }
                                
                                // over symbols
                                    fn goToSymbol(t: *@This(), pos: usize) void {
                                        t.symbol = pos;
                                        if (t.symbol > global_app.terminal.output.size.x - 3) {
                                            t.offset.x = 8;
                                        } else {
                                            t.offset.x = t.symbol;







<







3570
3571
3572
3573
3574
3575
3576

3577
3578
3579
3580
3581
3582
3583
                                            t.goToSymbol(t.symbol + indent);
                                            t.need_redraw = true;
                                            return;
                                        }
                                        t.goToSymbol(Scalpi.Text.findBreakOfWord(text) + t.symbol + 1);
                                        t.need_redraw = true;
                                    }

                                // over symbols
                                    fn goToSymbol(t: *@This(), pos: usize) void {
                                        t.symbol = pos;
                                        if (t.symbol > global_app.terminal.output.size.x - 3) {
                                            t.offset.x = 8;
                                        } else {
                                            t.offset.x = t.symbol;
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
                        ok = false;
                    }
                if (!ok) return error.NotOk;
            }
            
            // var parse_text_to_lines
                fn parse_text_to_lines(
                    t:     *@This(),
                    list:  *c.__ScalpiMemList__, // list of c.__AppEditorLine__.link
                    text:  []const u8
                ) !void {
                    var ok:       bool   = true;
                    var line_num: usize  = 1;
                    var lines            = Scalpi.Text.Splitter.init(text, "\n");
                    while (ok) {
                        var line_text = lines.next() orelse break;
                        if (line_text.len < c.__AppEditorLineLen_max__) {
                            if (line_text.len > 0 and line_text[line_text.len - 1] == '\r') {
                                t.end_line = text_rn;
                                line_text = line_text[0 .. line_text.len - 1];
                            }
                            var line: *c.__AppEditorLine__ = undefined;
                            if ( __AppEditorLine_alloc__(&line) ) {
                                try __AppEditorLine_init__(line);
                                line.text_len = line_text.len;
                                c.__ScalpiMem_copy__(&line.text[0], line_text.ptr, line_text.len);







|










|







5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
                        ok = false;
                    }
                if (!ok) return error.NotOk;
            }
            
            // var parse_text_to_lines
                fn parse_text_to_lines(
                    t:     *App_Editor,
                    list:  *c.__ScalpiMemList__, // list of c.__AppEditorLine__.link
                    text:  []const u8
                ) !void {
                    var ok:       bool   = true;
                    var line_num: usize  = 1;
                    var lines            = Scalpi.Text.Splitter.init(text, "\n");
                    while (ok) {
                        var line_text = lines.next() orelse break;
                        if (line_text.len < c.__AppEditorLineLen_max__) {
                            if (line_text.len > 0 and line_text[line_text.len - 1] == '\r') {
                                t.end_line = "\r\n";
                                line_text = line_text[0 .. line_text.len - 1];
                            }
                            var line: *c.__AppEditorLine__ = undefined;
                            if ( __AppEditorLine_alloc__(&line) ) {
                                try __AppEditorLine_init__(line);
                                line.text_len = line_text.len;
                                c.__ScalpiMem_copy__(&line.text[0], line_text.ptr, line_text.len);
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
                            const line: *c.__AppEditorLine__       = @fieldParentPtr("link", link);
                            __AppEditorLine_free__(line);
                        }
                    }
                    
                    if (!ok) return error.Unexpected; // return ok
                }
            
            const text_rn = "\r\n";
            const text_n = "\n";
        };
        
        const App = struct {
            os_helper: c.__OsHelper__,
            console: c.__ScalpiConsole__,
            terminal: c.__ScalpiTerminal__,
            editor: App_Editor,







<
<
<







5528
5529
5530
5531
5532
5533
5534



5535
5536
5537
5538
5539
5540
5541
                            const line: *c.__AppEditorLine__       = @fieldParentPtr("link", link);
                            __AppEditorLine_free__(line);
                        }
                    }
                    
                    if (!ok) return error.Unexpected; // return ok
                }



        };
        
        const App = struct {
            os_helper: c.__OsHelper__,
            console: c.__ScalpiConsole__,
            terminal: c.__ScalpiTerminal__,
            editor: App_Editor,
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
            fn App_Editor_init(t: *App_Editor) !void {
                t.views              = .{};
                t.do_ptr             = null;
                t.onKey_ptr          = null;
                t.current_ctx        = &t.views.flat;
                t.current_vtable     = &App_Editor.Views.Flat.vtable.table;
                t.working            = true;
                t.end_line           = App_Editor.text_n;
                
                t.lines_drawing = 0;
                __ScalpiMemList_init__(&t.history);
                t.start_record_link   = @alignCast(@ptrCast(c.NULL));
                t.stop_record_link    = @alignCast(@ptrCast(c.NULL));
                t.recording_macro     = false;
                
                try t.updatePathToClipboard();
                t.inited = true;
                
            }
            
            fn App_Editor_deinit(t: *App_Editor) void {
                if (t.inited == false) return;
                t.views.deinit();
            }
        







|









<







8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523

8524
8525
8526
8527
8528
8529
8530
            fn App_Editor_init(t: *App_Editor) !void {
                t.views              = .{};
                t.do_ptr             = null;
                t.onKey_ptr          = null;
                t.current_ctx        = &t.views.flat;
                t.current_vtable     = &App_Editor.Views.Flat.vtable.table;
                t.working            = true;
                t.end_line           = "\n";
                
                t.lines_drawing = 0;
                __ScalpiMemList_init__(&t.history);
                t.start_record_link   = @alignCast(@ptrCast(c.NULL));
                t.stop_record_link    = @alignCast(@ptrCast(c.NULL));
                t.recording_macro     = false;
                
                try t.updatePathToClipboard();
                t.inited = true;

            }
            
            fn App_Editor_deinit(t: *App_Editor) void {
                if (t.inited == false) return;
                t.views.deinit();
            }
        
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
                    }
                }
                
                const editor_result = try app.editor.do();
                if (editor_result != true) break;
                
                // sleep to next frame
                const expected_frame_end_time = app.tick + c.App_delay_to_start_frame_target;
                const resulting_frame_end_time = std.time.milliTimestamp();
                const delay_sleep = if (resulting_frame_end_time < expected_frame_end_time) expected_frame_end_time - resulting_frame_end_time else 1;
                std.time.sleep(@intCast(delay_sleep * std.time.ns_per_ms));
                app.tick = resulting_frame_end_time + delay_sleep;
            }
        }
    // main
        // var real_main
            fn real_main() bool {







|

|







8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
                    }
                }
                
                const editor_result = try app.editor.do();
                if (editor_result != true) break;
                
                // sleep to next frame
                const expected_frame_end_time  = app.tick + c.Scalpi_time_ms_per_s / c.App_expected_fps;
                const resulting_frame_end_time = std.time.milliTimestamp();
                const delay_sleep              = if (resulting_frame_end_time < expected_frame_end_time) expected_frame_end_time - resulting_frame_end_time else 1;
                std.time.sleep(@intCast(delay_sleep * std.time.ns_per_ms));
                app.tick = resulting_frame_end_time + delay_sleep;
            }
        }
    // main
        // var real_main
            fn real_main() bool {