Line Draw with Ansi and Oem characters

Home Forums Multi-Edit User Created Macros Line Draw with Ansi and Oem characters

This topic contains 1 reply, has 1,728 voices, and was last updated by  vawheeler63 5 years, 12 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2951

    Clay Martin
    Keymaster

    Victor Wheeler submitted this modification to LineDraw.s so that it works with OEM and ANSI fonts

    macro_file LineDraw;
    /******************************************************************************
    Multi-Edit Macro File

    Function: Macros to Generate linedrawing boxes in the text

    $Header: /Me91/Src/Linedraw.s 20 10/23/03 7:10p Reids $

    Copyright (C) 2002-2003 by Multi Edit Software, Inc.
    ******************************************************************************/

    #include Win32.sh
    #include Messages.sh

    #ifdef _MeSAS_
    #include MeLSLib.sh
    #endif

    #ifdef _MeLite_
    #include MeLiteLib.sh
    #endif

    #ifdef _Mew32_
    #include MeLib.sh
    #endif

    #include Dialog.sh
    #include LineDraw.sh

    #define wm_LdInit 0x2000

    void LineDraw( ) trans
    /*******************************************************************************
    MULTI-EDIT MACRO

    Name: LINEDRAW

    Description: This macro allows the user to draw the single and double line
    characters using the arrow keys to create lines and boxes etc.

    Copyright (C) 2002-2003 by Multi Edit Software, Inc.
    *******************************************************************************/
    {
    if ( g_Ld_hDlg != 0 ) {
    // don’t allow multiple occurances, switch to currently active notebook
    SendMessage( g_Ld_Hdlg, wm_SysCommand, sc_Close, 0 );
    return ( );
    }

    /*
    Here is a list of all of the linedrawing characters:
    ³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚ
    */

    struct tRect rect;

    // int main_dlg = Create_Mew_DlgEx ("", WS_POPUP, 1, 1, frame_handle, DLG_NOSIZE | DLG_NOCENTER | DLG_NOPARDISABLE | DLG_MODELESS);
    int main_dlg = Create_Mew_Dlg ("LineDraw", "", frame_handle, DLG_NOSIZE | DLG_NOCENTER | DLG_NOPARDISABLE | DLG_MODELESS);
    int ldb = Create_MEW_Ctrl( "BUTTON", "Single",
    bs_autoradiobutton,
    1, 1, 60, 20,
    main_dlg,101,
    app_handle, 0
    );
    int ldb = Create_MEW_Ctrl( "BUTTON", "Double",
    bs_autoradiobutton,
    61, 1, 60, 20,
    main_dlg,102,
    app_handle, 0
    );
    int ldb = Create_MEW_Ctrl( "BUTTON", "Erase",
    bs_autoradiobutton,
    121, 1, 60, 20,
    main_dlg,103,
    app_handle, 0
    );
    SubClass_With_Macro( main_dlg, "LinedrawProc", "" );

    SendDlgItemMessage(main_dlg, 101, BM_SETCHECK, 1, 0);
    Auto_Size_Mew_Dlg (main_dlg, 100, 100);
    struct tpoint pt;
    if ( g_Ld_MovedPosX || g_Ld_MovedPosY )
    {
    pt.x = g_Ld_MovedPosX;
    pt.y = g_Ld_MovedPosY;
    }
    else
    {
    GetWindowRect (client_handle, &rect);
    pt.x = rect.right;
    pt.y = rect.top;

    GetWindowRect (main_dlg, &rect);
    pt.x -= (rect.right – rect.left) + 1;
    if ( SendMessage(client_handle, WM_MDIGETACTIVE, 0, 0) & 0xFFFF0000)
    {
    pt.x -= GetSystemMetrics(SM_CXVSCROLL) – 1;
    }
    }
    SetWindowPos ( main_dlg, 0, pt.x, pt.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
    ShowWindow( main_dlg, sw_shownormal );
    BringWindowToTop( main_dlg );
    PostMessage(main_dlg, WM_LDINIT, 0, 0);

    int blarg, k1, k2;
    str tst, tst1;
    if( Wcmd_Find( 0, global_int(‘~LD_WCMD_ID’), blarg, k1, k2, tst, tst1)){
    tst = ”;
    if ( k2 )
    {
    tst = Make_Key_Name(k2) + ‘ OR ‘;
    }
    tst += Make_Key_Name(k1) + ‘ to toggle mode.’;
    make_message(tst);
    }
    } // LineDraw

    int LineDrawProc(
    int &RetVal,
    int Window,
    int Message,
    int WParam,
    int LParam,
    str Parms
    ) trans2 no_break
    /******************************************************************************
    Multi-Edit Macro
    04-Jan-01 12:40

    Copyright (C) 2002-2003 by Multi Edit Software, Inc.
    *******************************************************************( ldh )***/
    {
    int Rv = 0;

    switch ( Message ) {

    case wm_Activate :
    {
    if ( !WParam ) {
    g_Ld_HDlg = Window;
    if ( SendDlgItemMessage( Window, 101, bm_GetCheck, 0, 0 ) ) {
    g_Ld_Stat = 1;
    }
    else if (SendDlgItemMessage( Window, 102, bm_GetCheck, 0, 0 ) ) {
    g_Ld_Stat = 2;
    }
    else if ( SendDlgItemMessage( Window, 103, bm_GetCheck, 0, 0 ) ) {
    g_Ld_Stat = 3;
    }
    }
    else {
    g_Ld_EditWindow = ( LParam & 0x0000FFFF );
    }
    break;
    }

    case wm_Command :
    {
    switch ( WParam ) {

    case 101 :
    case 102 :
    case 103 :
    if ( ( LParam >> 16 ) == bn_Clicked ) {
    SetActiveWindow( g_Ld_EditWindow );
    }
    }
    break;
    }

    case wm_LdInit :
    {
    SetActiveWindow( g_Ld_EditWindow );
    break;
    }

    case wm_Destroy :
    {
    struct TRect Rect;

    GetWindowRect( Window, &Rect );
    g_Ld_MovedPosX = Rect.Left;
    g_Ld_MovedPosY = Rect.Top;
    g_Ld_hDlg = 0;
    g_Ld_Stat = 0;
    Make_Message( "" );
    break;
    }
    }
    RetVal = 0;
    return ( Rv );

    } // LineDrawProc

    void LdToggle( ) trans2
    /******************************************************************************
    Multi-Edit Macro
    04-Jan-01 12:37

    Copyright (C) 2002-2003 by Multi Edit Software, Inc.
    *******************************************************************( ldh )***/
    {
    int Jx = g_Ld_Stat;

    if ( Jx ) {
    ++g_Ld_Stat;
    if ( g_Ld_Stat > 3 ) {
    g_Ld_Stat = 1;
    }
    SendDlgItemMessage( g_Ld_hDlg, 100 + Jx, bm_SetCheck, 0, 0 );
    SendDlgItemMessage( g_Ld_hDlg, 100 + g_Ld_Stat, bm_SetCheck, 1, 0 );
    RedrawWindow( g_Ld_hDlg, 0, 0, rdw_Invalidate | rdw_UpdateNow );
    }
    } // LdToggle

    void LineDrawKey( ) trans2 no_break
    /******************************************************************************
    Multi-Edit Macro
    04-Jan-01 12:18

    Copyright (C) 2002-2003 by Multi Edit Software, Inc.
    *
    * Revision History
    * v2.0 28-Aug-2012 09:16 vw – Made to work with ANSI characters as opposed
    * to OEM characters. (Windows uses ANSI.)
    *******************************************************************( ldh )***/
    {
    int K1 = Key1,
    K2 = Key2,
    Need_Redraw = false,
    A_Left = 1,
    A_Right = 2,
    A_Up = 3,
    A_Down = 4,
    L_Mode,
    R_Mode,
    U_Mode,
    D_Mode,
    Same_Direction = 0,
    Ti = 0,
    OIm = Insert_Mode,
    Tr = Refresh;

    char L_Char;
    char R_Char;
    char U_Char;
    char D_Char;

    int liIsOemMode; /* 1 = OEM, 0 = ANSI */

    Insert_Mode = false;

    /*———————————————————————–
    * 28-Aug-2012 09:23 vw ANSI mode IF block added: places OEM switch
    * block in the TRUE part of the IF block, and ANSI (new) switch block
    * in the FALSE part of the IF block.
    *———————————————————————–*/
    liIsOemMode = Get_OEM_ANSI(Cur_Window);

    if (liIsOemMode) {
    /*———————————————————————
    * OEM Mode
    *———————————————————————*/
    switch ( K1 ) {

    case vk_Down :
    if ( g_Ld_Stat == 3 ) {
    Text( " " );
    Left;
    Down;
    g_Ld_Direction = 0;
    break;
    }
    Same_Direction = ( g_Ld_Direction == A_Down);
    if (Same_Direction) {
    /* If we were previously going a different direction, then insert char
    at current cusror position. Otherwise, insert char in the next down
    position */
    Down;
    }
    g_Ld_Direction = A_Down;
    call LookAroundOEM;

    Ti = XPos( U_Char, "Ù¾½¼ÀÓÔÈÁÏÊÐ", 1 );
    if ( Ti && Same_Direction ) {
    /* We’re going down. If char above is not connected, then we need to change it to be connected. */
    Up;
    Text( Copy( "´µ´µÃÃÆÆÅØØŹ¹¶¹ÌÇÌÌÎÎÎ×",( ( g_Ld_Stat – 1 ) * 12 ) + Ti, 1 ) );
    Left;
    break;
    }
    if ( ( U_Mode > 0 ) && ( ( R_Mode + D_Mode + L_Mode ) == 0 ) ) {
    Text( Copy( "³º", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( ( L_Mode == 1 ) && ( R_Mode == 1 ) ) {
    Text( Copy( "ÂÒÂÒÒËÂÒÁÊÅÎÁÊÂÒÐÐÂÐ×Î", ( U_Mode * 8 ) + ( D_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( ( L_Mode == 2 ) && ( R_Mode == 2 ) ) {
    Text( Copy( "ÑËÑËÑËÑËÏÊØÎÏËÑËÁÊÁÊÅÎ", ( U_Mode * 8 ) + ( D_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( L_Mode == 1 ) {
    Text( Copy( "¿·¿·¿·¿·Ù¼´¹Ù¼¿·Ù½¿½´¶", ( U_Mode * 8 ) + ( D_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( L_Mode == 2 ) {
    Text( Copy( "¸»¸»¸»¸»¾¼µ¹¾¼¸»¾¼¸¼µ¹", ( U_Mode * 8 ) + ( D_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( R_Mode == 2 ) {
    Text( Copy( "ÕÉÕÉÕÉÕÉÔÈÆÌÔÈÕÉÔÈÕÈÆÌ", ( U_Mode * 8 ) + ( D_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( R_Mode == 1 ) {
    Text( Copy( "ÚÖÚÖÚÖÚÖÀÈÃÌÀÈÚÖÀÓÚÓÃÇ", ( U_Mode * 8 ) + ( D_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    /* If no other condition exists… */
    Text( Copy( "³º", g_Ld_Stat, 1 ) );
    Left;
    break;

    case vk_Right :
    if ( g_Ld_Stat == 3 ) {
    Text( " " );
    g_Ld_Direction = 0;
    break;
    }
    Same_Direction = ( g_Ld_Direction == A_Right );
    if ( Same_Direction ) {
    /* If we were previously going a different direction, then insert char
    at current cusror position. Otherwise, insert char in the next right
    position */
    Right;
    }
    g_Ld_Direction = A_Right;
    call LookAroundOEM;

    Ti = XPos( L_Char, "¿·¸»Ù¾½¼´¶¹µ", 1 );
    if ( Ti && Same_Direction ) {
    /* We’re going right. If char to left is not connected, then we need to change it to be connected. */
    Left;
    Text( Copy( "ÂÒÂÒÁÁÐÐÅ××ÅËËÑËÊÏÊÊÎÎÎØ", ( ( g_Ld_Stat – 1 ) * 12 ) + Ti, 1 ) );
    Left;
    break;
    }
    if ( (L_Mode > 0 ) && ( ( D_Mode + U_Mode + R_Mode ) == 0 ) ) {
    Text( Copy( "ÄÍ", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( ( D_Mode == 1 ) && ( U_Mode == 1 ) ) {
    Text( Copy( "ÃÆÃÆÆÌÃÆ´¹Åδ¹ÃƵµµµØÎ", ( L_Mode * 8 ) + ( R_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( ( D_Mode == 2 ) && ( U_Mode == 2 ) ) {
    Text( Copy( "ÇÌÇÌÇÌÇ̶¹×ζÌÇÌ´¹´¹ÅÎ", ( L_Mode * 8 ) + ( R_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( D_Mode == 1 ) {
    Text( Copy( "ÚÕÚÕ¿¸ÚÕ¿»ÂË¿»ÚÕ¿¸Ú¸ÂÑ", ( L_Mode * 8 ) + ( R_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }

    if ( D_Mode == 2 ) {
    Text( Copy( "ÖÉÖÉÖÉÖÉ·»ÒË·»ÖÉ·»Ö»ÒË", ( L_Mode * 8 ) + ( R_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }

    if ( U_Mode == 2 ) {
    Text( Copy( "ÓÈÓÈÓÈÓȽ¼Ðʽ¼ÓȽ¼Ó¼ÐÊ", ( L_Mode * 8 ) + ( R_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( U_Mode == 1 ) {
    Text( Copy( "ÀÔÀÔÙ¾ÀÔÙ¼ÁÊÙ¼ÀÔÙ¾À¾ÁÏ", ( L_Mode * 8 ) + ( R_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    /* If no other condition exists… */
    Text( Copy( "ÄÍ", g_Ld_Stat, 1 ) );
    Left;
    break;

    case vk_Up :
    if ( g_Ld_Stat == 3 ) {
    Text( " " );
    Left;
    Up;
    g_Ld_Direction = 0;
    break;
    }
    Same_Direction = ( g_Ld_Direction == A_Up );
    if ( Same_Direction ) {
    /* If we were previously going a different direction, then insert char
    at current cusror position. Otherwise, insert char in the next up
    position */
    Up;
    }
    g_Ld_Direction = A_Up;
    call LookAroundOEM;

    Ti = XPos(D_Char,’¿¸·»ÚÖÕÉÂÑËÒ’,1);
    if ((Ti) && (Same_Direction)) {
    Down;
    Text(Copy(‘´µ´µÃÃÆÆÅØØŹ¹¶¹ÌÇÌÌÎÎÎ×’,((g_Ld_Stat – 1) * 12) + Ti,1));
    LEFT;
    break;
    }

    if( ((D_Mode > 0) & ((R_Mode + U_Mode + L_Mode) == 0)) ) {
    Text(Copy(‘³º’,g_Ld_Stat,1));
    LEFT;
    break;
    }

    if( ((L_Mode == 1) & (R_Mode == 1)) ) {
    Text(Copy(‘ÁÐÂËÒÒÁÐÁÐÅÎÁÒÁÐÐÊÂË×Î’,((U_Mode * 8) + (D_Mode * 2)) + g_Ld_Stat,1));
    LEFT;
    break;
    }

    if( ((L_Mode == 2) & (R_Mode == 2)) ) {
    Text(Copy(‘ÏÊÑËÂËÏÊÏÊØÎÂËÏÊÏÊÑÊÅÎ’,((U_Mode * 8) + (D_Mode * 2)) + g_Ld_Stat,1));
    LEFT;
    break;
    }

    if( (L_Mode == 1) ) {
    Text(Copy(‘Ù½¿»¿·Ù½Ù½´¹Ù·Ù½Ù½¿»´¶’,((U_Mode * 8) + (D_Mode * 2)) + g_Ld_Stat,1));
    LEFT;
    break;
    }

    if( (L_Mode == 2) ) {
    Text(Copy(‘¾¼¸»¸»¾¼¾¼µ¹¾»¾¼¾¼¸»µ¹’,((U_Mode * 8) + (D_Mode * 2)) + g_Ld_Stat,1));
    LEFT;
    break;
    }

    if( (R_Mode == 2) ) {
    Text(Copy(‘ÔÈÕÉÕÉÔÈÔÈÆÌÔÉÔÈÔÈÕÉÆÌ’,((U_Mode * 8) + (D_Mode * 2)) + g_Ld_Stat,1));
    LEFT;
    break;
    }

    if( (R_Mode == 1) ) {
    Text(Copy(‘ÀÓÚÉÚÖÀÓÀÓÃÌÀÖÀÓÀÓÚÉÃÇ’,((U_Mode * 8) + (D_Mode * 2)) + g_Ld_Stat,1));
    LEFT;
    break;
    }

    /* If no other condition exists… */
    Text(Copy(‘³º’,g_Ld_Stat,1));
    LEFT;
    break;

    case vk_Left :
    if( (g_Ld_Stat == 3) ) {
    Text(‘ ‘);
    Left;
    Left;
    g_Ld_Direction = 0;
    break;
    }
    Same_Direction = (g_Ld_Direction == A_Left);
    if (Same_Direction) {
    /* If we were previously going a different direction, then insert char
    at current cusror position. Otherwise, insert char in the next left
    position */
    Left;
    }
    g_Ld_Direction = A_Left;
    call LookAroundOEM;

    Ti = XPos( R_Char, "ÚÖÕÉÀÔÓÈÃÇÌÆ", 1 );
    if ( Ti && Same_Direction ) {
    Right;
    Text( Copy( "ÂÒÂÒÁÁÐÐÅ××ÅËËÑËÊÏÊÊÎÎÎØ", ( ( g_Ld_Stat – 1 ) * 12 ) + Ti, 1 ) );
    Left;
    break;
    }
    if ( (R_Mode > 0 ) && ( ( D_Mode + U_Mode + L_Mode ) == 0 ) ) {
    Text( Copy( "ÄÍ", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( ( D_Mode == 1 ) && ( U_Mode == 1 ) ) {
    Text( Copy( "´µÃÌÆÆ´µ´µÅδƴµµ¹ÃÌØÎ", ( L_Mode * 8 ) + ( R_Mode * 2 ) + g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if( ((D_Mode == 2) & (U_Mode == 2)) ) {
    Text(Copy(‘¶¹ÇÌÃ̶¹¶¹×ÎÃ̶¹¶¹Ç¹ÅÎ’,((L_Mode * 8) + (R_Mode * 2)) + g_Ld_Stat,1));
    Left;
    break;
    }
    if( (D_Mode == 1) ) {
    Text(Copy(‘¿¸ÚÉÚÕ¿¸¿¸ÂË¿Õ¿¸ÚÕÚÉÂÑ’,((L_Mode * 8) + (R_Mode * 2)) + g_Ld_Stat,1));
    Left;
    break;
    }
    if ( D_Mode == 2 ) {
    Text(Copy(‘·»ÖÉÖÉ·»·»ÒË·É·»·»ÖÉÒË’,((L_Mode * 8) + (R_Mode * 2)) + g_Ld_Stat,1));
    Left;
    break;
    }
    if ( U_Mode == 2 ) {
    Text(Copy(‘½¼ÓÈÓȽ¼½¼ÐʽȽ¼½¼ÓÈÐÊ’,((L_Mode * 8) + (R_Mode * 2)) + g_Ld_Stat,1));
    Left;
    break;
    }
    if ( U_Mode == 1 ) {
    Text(Copy(‘Ù¾ÀÈÀÔپپÁÊÙÔپپÀÈÁÏ’,((L_Mode * 8) + (R_Mode * 2)) + g_Ld_Stat,1));
    Left;
    break;
    }
    /* If no other condition exists… */
    Text( Copy( "ÄÍ", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    } else {
    /*———————————————————————
    * ANSI Mode
    *———————————————————————*/
    /*
    Here is a list of all of the linedrawing characters:
    ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú
    *
    * Plan:
    * Part of the problem is in ANSI, we HAVE line-draw characters, but the are
    * unfortunately in different positions in the character map, and are so high
    * up (e.g. Courier New font has them in the Unicode 0x2052 (9700) range.
    * While it would be great to just do a 1-to-1 substituion, since the compilers
    * don’t choke on this, the EDITORS (both Multi-edit and MPLAB IDE) don’t know
    * what to do with this code range. So we’re going to have to substitute regular
    * type-able characters instead. This will look okay in both OEM and ANSI
    * editor fonts.
    *
    * To do this, we need to establish a policy about what to do for vertical and
    * horizontal line meetings, and note that the results are going to be more crude
    * than the original (beautiful) OEM line-draw characters. Thus, the policy is
    * set here:
    *
    * 1. Non-intersecting lines:
    * a. Single vertical line replaced by ‘|’.
    * b. Single horizontal line replaced by ‘-‘.
    * c. Clean double-vertical line replaced by ‘#’
    * d. Clean double-horizontal line replaced by ‘=’.
    * 2. Intersecting lines:
    * a. Clean single-line intersection of all types replaced by ‘+’.
    * b. All others (with at least one double-line in it) replaced by ‘#’.
    * c. Exceptions to 2.b above:
    * 1) Double-horizontal-single-vertical (whether only up-side, down-side or both, and corners as well)
    * |
    * ===+===
    * |
    *
    * OEM => ANSI
    * ³ |
    * ´ +
    * µ +
    * ¶ #
    * · #
    * ¸ +
    * ¹ #
    * º #
    * » #
    * ¼ #
    * ½ #
    * ¾ +
    * ¿ +
    * À +
    * Á +
    * Â +
    * Ã +
    * Ä –
    * Å +
    * Æ +
    * Ç #
    * È #
    * É #
    * Ê #
    * Ë #
    * Ì #
    * Í =
    * Î #
    * Ï +
    * Ð #
    * Ñ +
    * Ò #
    * Ó #
    * Ô +
    * Õ +
    * Ö #
    * × # |
    * Ø + ===+===
    * Ù +
    * Ú +
    *
    * List of chars we are using: | – + = #
    */
    switch ( K1 ) {

    case vk_Down :
    if ( g_Ld_Stat == 3 ) {
    Text( " " );
    Left;
    Down;
    g_Ld_Direction = 0;
    break;
    }
    Same_Direction = ( g_Ld_Direction == A_Down);
    if (Same_Direction) {
    /* If we were previously going a different direction, then insert char
    at current cusror position. Otherwise, insert char in the next down
    position */
    Down;
    }
    g_Ld_Direction = A_Down;
    call LookAroundANSI;

    /* List of chars we are using: | – + = # */

    Ti = XPos( U_Char, "-=", 1 );
    if ( Ti && Same_Direction ) {
    /* We’re going down. If char above is not connected, then we need to change it to be connected. */
    /* g_Ld_Stat = which radio button is selected? 1=single, 2=double, 3=erase.
    * Since we are drawing a VERTICAL line (which has priority over horizontal lines) priority is
    * given to the line draw mode as to which connecting character we use. */
    Up;
    Text( Copy( "+#", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( ( U_Mode > 0 ) && ( ( R_Mode + D_Mode + L_Mode ) == 0 ) ) {
    Text( Copy( "|#", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    /* Since we are drawing a vertical line, if we are drawing a DOUBLE-vertical line, the only choice is ‘#’.
    * If we are drawing a SINGLE-vertical line, then we NEVER draw a ‘#’, but only ‘|’ except if either
    * a SINGLE- or DOUBLE-horizontal line is on either side, then we draw a ‘+’. */
    if (g_Ld_Stat == 2) {
    Text( ‘#’ );
    Left;
    break;
    } else {
    /* If any type of line-draw char is on left or right, then ‘+’. */
    if ( (L_Mode > 0) || (R_Mode > 0) ) {
    Text( ‘+’ );
    Left;
    break;
    }
    }
    /* If no other condition exists… */
    Text( Copy( "|#", g_Ld_Stat, 1 ) );
    Left;
    break;

    case vk_Right :
    if ( g_Ld_Stat == 3 ) {
    Text( " " );
    g_Ld_Direction = 0;
    break;
    }
    Same_Direction = ( g_Ld_Direction == A_Right );
    if ( Same_Direction ) {
    /* If we were previously going a different direction, then insert char
    at current cusror position. Otherwise, insert char in the next right
    position */
    Right;
    }
    g_Ld_Direction = A_Right;
    call LookAroundANSI;

    /* List of chars we are using: | – + = # */

    Ti = XPos( L_Char, "|", 1 );
    if ( Ti && Same_Direction ) {
    /* We’re going right. If char to left is not connected, then we need to change it to be connected.
    * The sole choice here is a ‘+’ since we assume L_Char is connected to a single-vertical line. */
    Left;
    Text( ‘+’ );
    Left;
    break;
    }
    if ( (L_Mode > 0 ) && ( ( D_Mode + U_Mode + R_Mode ) == 0 ) ) {
    /* Line-draw char on left, but nowhere else. Priority is given to draw mode (single or double). */
    Text( Copy( "-=", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    /* If there is a single-vertical line above or below us, then this is given priority over any
    * double-vertical line, and the only choice is a ‘+’. Otherwise, if there is a double-vertical
    * on EITHER side, then meet it with a ‘#’. */
    if ( ( D_Mode == 1 ) || ( U_Mode == 1 ) ) {
    /* Single-vertical either above or below or both. Priority is given to single-vertical line. Only choice is ‘+’. */
    Text( ‘+’ );
    Left;
    break;
    } else {
    if ((D_Mode == 2) || (U_Mode == 2)) {
    /* Double-vertical either above or below or both. Meet it with a ‘#’. */
    Text( ‘#’ );
    Left;
    break;
    }
    }
    /* If no other condition exists… */
    Text( Copy( "-=", g_Ld_Stat, 1 ) );
    Left;
    break;

    case vk_Up :
    if ( g_Ld_Stat == 3 ) {
    Text( " " );
    Left;
    Up;
    g_Ld_Direction = 0;
    break;
    }
    Same_Direction = ( g_Ld_Direction == A_Up );
    if ( Same_Direction ) {
    /* If we were previously going a different direction, then insert char
    at current cusror position. Otherwise, insert char in the next up
    position */
    Up;
    }
    g_Ld_Direction = A_Up;
    call LookAroundANSI;

    /* List of chars we are using: | – + = # */

    Ti = XPos( D_Char, "-=", 1 );
    if ( Ti && Same_Direction ) {
    /* We’re going up. If char below is not connected, then we need to change it to be connected. */
    /* g_Ld_Stat = which radio button is selected? 1=single, 2=double, 3=erase.
    * Since we are drawing a VERTICAL line (which has priority over horizontal lines) priority is
    * given to the line draw mode as to which connecting character we use. */
    Down; /* Go back to not-connected char behind us. */
    Text( Copy( "+#", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    if ( ( D_Mode > 0 ) && ( ( R_Mode + U_Mode + L_Mode ) == 0 ) ) {
    /* Char behind us is a line-draw char, but no others around, then just draw the vertical line per the mode. */
    Text( Copy( "|#", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    /* Since we are drawing a vertical line, if we are drawing a DOUBLE-vertical line, the only choice is ‘#’.
    * If we are drawing a SINGLE-vertical line, then we NEVER draw a ‘#’, but only ‘|’ except if either
    * a SINGLE- or DOUBLE-horizontal line is on either side, then we draw a ‘+’. */
    if (g_Ld_Stat == 2) {
    Text( ‘#’ );
    Left;
    break;
    } else {
    /* If any type of line-draw char is on left or right, then ‘+’. */
    if ( (L_Mode > 0) || (R_Mode > 0) ) {
    Text( ‘+’ );
    Left;
    break;
    }
    }
    /* If no other condition exists… */
    Text( Copy( "|#", g_Ld_Stat, 1 ) );
    Left;
    break;

    case vk_Left :
    if( (g_Ld_Stat == 3) ) {
    Text(‘ ‘);
    Left;
    Left;
    g_Ld_Direction = 0;
    break;
    }
    Same_Direction = (g_Ld_Direction == A_Left);
    if (Same_Direction) {
    /* If we were previously going a different direction, then insert char
    at current cusror position. Otherwise, insert char in the next left
    position */
    Left;
    }
    g_Ld_Direction = A_Left;
    call LookAroundANSI;

    /* List of chars we are using: | – + = # */

    Ti = XPos( R_Char, "|", 1 );
    if ( Ti && Same_Direction ) {
    /* We’re going Left. If char to right is not connected, then we need to change it to be connected.
    * The sole choice here is a ‘+’ since we assume R_Char is connected to a single-vertical line. */
    Right;
    Text( ‘+’ );
    Left;
    break;
    }
    if ( (R_Mode > 0 ) && ( ( D_Mode + U_Mode + L_Mode ) == 0 ) ) {
    /* Line-draw char on right, but nowhere else. Priority is given to draw mode (single or double). */
    Text( Copy( "-=", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    /* If there is a single-vertical line above or below us, then this is given priority over any
    * double-vertical line, and the only choice is a ‘+’. Otherwise, if there is a double-vertical
    * on EITHER side, then meet it with a ‘#’. */
    if ( ( D_Mode == 1 ) || ( U_Mode == 1 ) ) {
    /* Single-vertical either above or below or both. Priority is given to single-vertical line. Only choice is ‘+’. */
    Text( ‘+’ );
    Left;
    break;
    } else {
    if ( (D_Mode == 2) || (U_Mode == 2) ) {
    /* Double-vertical either above or below or both. Meet it with a ‘#’. */
    Text( ‘#’ );
    Left;
    break;
    }
    }
    /* If no other condition exists… */
    Text( Copy( "-=", g_Ld_Stat, 1 ) );
    Left;
    break;
    }
    }

    Insert_Mode = OIm;
    return ( );

    LookAroundOEM:
    /* This subroutine looks at all chars surrounding CUR_CHAR and stores
    special values into variables based on what it finds */

    Undo_Stat = false;
    Refresh = false;
    HideCaret( Window_Handle );

    if ( C_Line > 1 ) {
    Up;
    U_Char = Cur_Char;
    Right;
    Down;
    }
    else {
    U_Char = ‘|0’;
    Right;
    }
    R_Char = Cur_Char;
    Down;
    Left;
    D_Char = Cur_Char;
    if ( C_Col > 1 ) {
    Left;
    Up;
    L_Char = Cur_Char;
    Right;
    }
    else {
    L_Char = ‘|0’;
    Up;
    }
    D_Mode = XPos( D_Char, "³´µ¾ÀÁÃÅÆÔØÙ϶¹º¼½ÇÈÊÌÎÐÓ×", 1 );
    /* ^ 14th char */
    D_Mode = ( D_Mode > 0 ) + ( D_Mode > 13 );
    /* D_Mode: 0=not a line-draw char, 1=single-vertical line involved, 2=double-vertical line involved. */

    U_Mode = XPos( U_Char, "³´µ¸¿ÂÃÅÆÑÕØÚ¶·¹º»ÇÉËÌÎÒÖ×", 1 );
    U_Mode = ( U_Mode > 0 ) + ( U_Mode > 13 );
    /* U_Mode: 0=not a line-draw char, 1=single-vertical line involved, 2=double-vertical line involved. */

    L_Mode = XPos( L_Char, "ÀÁÂÃÄÅÇÐÒÓÖ×ÚÆÈÉÊËÌÍÎÏÑÔÕØ", 1 );
    L_Mode = ( L_Mode > 0 ) + ( L_Mode > 13 );
    /* L_Mode: 0=not a line-draw char, 1=single-horizontal line involved, 2=double-horozontal line involved. */

    R_Mode = XPos( R_Char, "´¶·½¿ÁÂÄÅÐÒ×Ùµ¸¹»¼¾ÊËÍÎÏÑØ", 1 );
    R_Mode = ( R_Mode > 0 ) + ( R_Mode > 13 );
    /* R_Mode: 0=not a line-draw char, 1=single-horizontal line involved, 2=double-horozontal line involved. */

    ShowCaret( Window_Handle );
    Refresh = true;
    Undo_Stat = true;
    ret;

    /*————————————————————————-
    * 28-Aug-2012 09:21 vw ADDED FOR ANSI MODE
    *————————————————————————-*/
    LookAroundANSI:
    /* This subroutine looks at all chars surrounding CUR_CHAR and stores
    special values into variables based on what it finds */

    Undo_Stat = false;
    Refresh = false;
    HideCaret( Window_Handle );

    if ( C_Line > 1 ) {
    Up;
    U_Char = Cur_Char;
    Right;
    Down;
    }
    else {
    U_Char = ‘|0’;
    Right;
    }
    R_Char = Cur_Char;
    Down;
    Left;
    D_Char = Cur_Char;
    if ( C_Col > 1 ) {
    Left;
    Up;
    L_Char = Cur_Char;
    Right;
    }
    else {
    L_Char = ‘|0’;
    Up;
    }

    D_Mode = XPos( D_Char, "|+#", 1 );
    D_Mode = ( D_Mode > 0 ) + ( D_Mode > 2 );
    /* D_Mode: 0=not a line-draw char, 1=single-vertical line involved, 2=double-vertical line involved. */

    U_Mode = XPos( U_Char, "|+#", 1 );
    U_Mode = ( U_Mode > 0 ) + ( U_Mode > 2 );
    /* U_Mode: 0=not a line-draw char, 1=single-vertical line involved, 2=double-vertical line involved. */

    L_Mode = XPos( L_Char, "+-#=", 1 );
    L_Mode = ( L_Mode > 0 ) + ( L_Mode > 2 );
    /* L_Mode: 0=not a line-draw char, 1=single-horizontal line involved, 2=double-horozontal line involved. */

    R_Mode = XPos( R_Char, "+-#=", 1 );
    R_Mode = ( R_Mode > 0 ) + ( R_Mode > 2 );
    /* R_Mode: 0=not a line-draw char, 1=single-horizontal line involved, 2=double-horozontal line involved. */

    ShowCaret( Window_Handle );
    Refresh = true;
    Undo_Stat = true;
    ret;

    } // LineDrawKey

    #9524

    vawheeler63
    Participant

    Thank you for posting this, Clay!

    This is the ENTIRE contents of my <Multi-Edit Root directory>\Src\LineDraw.s file.

    Suggested use:

    1. Save original LineDraw.s file either in source-code management or by making a copy of it and renaming it to something like LineDraw_orig.s.

    2. Replace entire contents of LineDraw.s with the above. Note that for OEM fonts, the original logic is entirely preserved. Copy/pasting from this HTML is safe. I tested it myself, and all significant characters are preserved.

    3. The HTML above loses 2 consecutive cosmetic space characters when it is PASTED into the file. If you want, fix this by:
    Line 115: Change
    tst = Make_Key_Name( k2 ) + ‘ OR ‘;
    to
    tst = Make_Key_Name( k2 ) + ‘ OR ‘;
    (The change is adding 1 space to either side of the ‘OR’ string being appended.)
    Line 117: Change
    tst += Make_Key_Name( k1 ) + ‘ to toggle mode.’;
    to
    tst += Make_Key_Name( k1 ) + ‘ to toggle mode.’;
    (The change is adding 1 more space at the beginning of the string being appended.)

    4. Because pasting from the above HTML loses the line indenting, I recommend:
    a. If you haven’t already configured PolyStyle for CMac macro files, do so now by:
    Tools > Config Code Formatter
    b. from within Multi-Edit while editing this file, execute the following command:
    Tools > Format Code

    This will restore indents and make the code much more readable.

    5. Rebuild the Macro Library. Note that compiling this .S file alone is not enough. And rebuilding the library alone is not enough. These are the steps are required to make it work:
    a. Exit Multi-Edit.
    b. Start > Programs > Multi-Edit 2008 > Recompile Macro Source
    c. Start > Programs > Multi-Edit 2008 > Rebuild Macro Library

    Then in Multi-Edit 2008 (also works in ME 2006): Tools > LineDraw will now self-adapt to whichever font you are using: ANSI or OEM.

    Note that I used a limited character set universal to all ANSI fonts that I am aware of so as to be compatible with several compilers that I use.

    Enjoy!

    Kind regards,
    Victor Wheeler

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.