News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Code Editor Line number?

Started by caraveiro, April 02, 2014, 02:12:55 PM

Previous topic - Next topic

caraveiro

Hi Buddies!

I want to make an application with a Edit Control to comparing text, but I want to color the dif. lines; It seems easy using a richedit control.

But I have no idea how to display the line number on the left side of the rows (line numbers same way that the code editor does).

Maybe having TWO edit controls wrapped: one for showing line number and the other to show the text. What do you think? 

Regards!
"knowledge is now free at last, everything should be free from now on, enjoy knowledge and life and work for everybody else"
+ORC

ragdog

Is not easy i use for my project RaEditLib from Radasm Project :t

caraveiro

Quote from: ragdog on April 03, 2014, 02:44:28 AM
Is not easy i use for my project RaEditLib from Radasm Project :t

Are you talking about this?

https://github.com/RaMMicHaeL/SimEd

and... yes, it seems that's not easy!  :dazzled:


But it seem a lot easier than what I was pretending to smoke,  some grass that goes by the name of InkEdit:

http://blogs.msdn.com/b/murrays/archive/2006/10/14/richedit-versions.aspx

Thank you!
"knowledge is now free at last, everything should be free from now on, enjoy knowledge and life and work for everybody else"
+ORC

dedndave

richedit controls and smoking grass probably don't go together well   :lol:

qWord

Quote from: caraveiro on April 02, 2014, 02:12:55 PMMaybe having TWO edit controls wrapped: one for showing line number and the other to show the text. What do you think? 
I would extend the left margin of the control and use that area to display the line numbers:
include \masm32\include\masm32rt.inc

DlgRichEdit MACRO dstyle,tx,ty,wd,ht,ctlID
    align_4 edi
    mov DWORD PTR [edi+0],  WS_VISIBLE or WS_CHILD or dstyle
    mov WORD  PTR [edi+8],  tx
    mov WORD  PTR [edi+10], ty
    mov WORD  PTR [edi+12], wd
    mov WORD  PTR [edi+14], ht
    mov WORD  PTR [edi+16], ctlID
    add edi, 18
    ustring "RichEdit20A"
    align_2 edi
    add edi, 2
ENDM

IDC_EDIT    EQU 100
MARGIN_X    EQU 30

.data?
    g_hInstance     HINSTANCE ?
    g_pOrgWndProc   WNDPROC ?
.code
WndProc  proc uses esi edi ebx hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL pt:POINT
LOCAL sz[16]:CHAR
LOCAL lc:DWORD
LOCAL rect:RECT,rgn:HRGN

    invoke CallWindowProc,g_pOrgWndProc,hWnd,uMsg,wParam,lParam
    .if uMsg == WM_PAINT
        push eax
        .if rvx(lc=SendMessage,hWnd,EM_GETLINECOUNT,0,0)
            fnx ebx = GetDC,hWnd

            fn SaveDC,ebx
            fn GetClientRect,hWnd,&rect
            fn SelectClipRgn,ebx,rvx(rgn = CreateRectRgn,rect.left,rect.top,rect.right,rect.bottom)
           
            ;fnx br = SelectObject,ebx,rv(CreateSolidBrush,bkColor)
            invoke BitBlt,ebx,0,0,MARGIN_X,rect.bottom,ebx,0,0,PATCOPY
            ;fn DeleteObject,rv(SelectObject,ebx,br)
           
            fnx esi=SendMessage,hWnd,EM_GETFIRSTVISIBLELINE,0,0
            .while esi <= lc
                .break .if rv(SendMessage,hWnd,EM_LINEINDEX,esi,0) == -1
                fn SendMessage,hWnd,EM_POSFROMCHAR,&pt,eax
                mov eax,pt.y
                .break .if SDWORD ptr eax > rect.bottom
                fn wsprintf,&sz,"%lu",&[esi+1]
                fn TextOut,ebx,0,pt.y,&sz,rv(lstrlen,&sz)
                add esi,1
            .endw
            fn RestoreDC,ebx,-1
            fn DeleteObject,rgn
            fn ReleaseDC,hWnd,ebx
        .endif
        pop eax
    .endif
    ret
   
WndProc endp

DlgProc proc uses esi edi ebx hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL rect:RECT

    .if uMsg == WM_INITDIALOG
        invoke SendDlgItemMessage,hWnd,IDC_EDIT,EM_SETMARGINS,EC_LEFTMARGIN,MARGIN_X
        fnx g_pOrgWndProc = SetWindowLong,rv(GetDlgItem,hWnd,IDC_EDIT),GWL_WNDPROC,WndProc
        xor eax,eax
    .elseif uMsg == WM_CLOSE
        fn EndDialog,hWnd,0
    .else
        xor eax,eax
    .endif
    ret
   
DlgProc endp

main proc
   
    fnx g_hInstance = GetModuleHandle,0
    fn LoadLibrary,"Riched20.dll"
   
    Dialog "test","MS Sans Serif",12,WS_OVERLAPPED or WS_SYSMENU or DS_CENTER,1,10,10,100,100,1024
    DlgRichEdit ES_MULTILINE or ES_WANTRETURN or ES_AUTOHSCROLL or ES_AUTOVSCROLL ,0,0,90,50,IDC_EDIT
    CallModalDialog g_hInstance,0,DlgProc,0
   
    exit
main endp
end main


EDIT: handle leak fixed
MREAL macros - when you need floating point arithmetic while assembling!

caraveiro

Quote from: qWord on April 04, 2014, 04:18:08 AM
I would extend the left margin of the control and use that area to display the line numbers:

Wow, wow!

Thank you.

;)

I someone need it; here are the best richedit reference I'd found.


http://www.jose.it-berater.org/richedit/iframe/index.htm

Bravo!
"knowledge is now free at last, everything should be free from now on, enjoy knowledge and life and work for everybody else"
+ORC

aurel

Hello
is there a compiled 32 bit version of this program?
I simply don't know how to compile this example because i don't know assembler
yes shame on me   :rolleyes:
thanks in advance

jj2007

Yep, shame on you, Aurel :biggrin:

Here is a quickie for you. But it won't help much, because there is no source around. Btw which proggie do you mean, the one by caraveiro or qWord's example?

aurel

Yes shame  on me .. :sad:

hI jj , well i am not sure , one which show line numbers in richedit margin

edit; yes that one from qWord do you can compile it ?

edit2; jj ..do you have line numbers in your MasMbasic editor ,sorry i forgot all that things...

jj2007

Quote from: aurel on February 15, 2020, 03:19:16 AMedit2; jj ..do you have line numbers in your MasMbasic editor ,sorry i forgot all that things...

Kind of, yes: If text is selected, then you get in the upper right corner, for example:
L1200 C3+4 73d 49 6E 69 74h meaning
line 1200
column 3 + 4 characters selected
73d is the decimal code of the first selected character
49 6E 69 74h are the hex codes of the four selected characters (Init)



If no text is selected, you get the absolute line number plus the line inside the current proc or macro:

jimg

I'm confused.
What is it you are looking for exactly?

aurel

Hello
Yes looking confusing but not .
I asking is there anyone who can compile this above source code to 32bit exe  and zip it that i can try how work.
I simply don't have a clue how to do that , or i must download somewhere masm32 ?
i download Jwasm but there is no any include in that sourceforge pack.

aurel

jj ...well as i can remember and see it  looks that you dont have it,i dont know how is that possible
because you have all that interesting things in it ,even i don't get it what is what ,
sorry but i am too stupid ,or to slow .. :rolleyes:

jj2007

Apparently Aurel wants something like this, from qWord's example:



Which is fine but not that useful if the editor jumps to the error line anyway:



@Aurel: Step by step installation instructions are here. Re "is there anyone who can compile this above source code to 32bit exe", no, because there is no source code...

jimg

Quote from: aurel on February 15, 2020, 01:55:05 AM
Hello
is there a compiled 32 bit version of this program?
I simply don't know how to compile this example because i don't know assembler
yes shame on me   :rolleyes:
thanks in advance

I can't see what you are referring to.  Which program is  "this"  program?