Author Topic: Code Editor Line number?  (Read 4853 times)

caraveiro

  • Regular Member
  • *
  • Posts: 17
  • Quam olim da capo.
Code Editor Line number?
« on: April 02, 2014, 02:12:55 PM »
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

  • Member
  • ****
  • Posts: 610
Re: Code Editor Line number?
« Reply #1 on: April 03, 2014, 02:44:28 AM »
Is not easy i use for my project RaEditLib from Radasm Project :t

caraveiro

  • Regular Member
  • *
  • Posts: 17
  • Quam olim da capo.
Re: Code Editor Line number?
« Reply #2 on: April 04, 2014, 02:39:56 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

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Code Editor Line number?
« Reply #3 on: April 04, 2014, 02:52:23 AM »
richedit controls and smoking grass probably don't go together well   :lol:

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: Code Editor Line number?
« Reply #4 on: April 04, 2014, 04:18:08 AM »
Maybe 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:
Code: [Select]
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

  • Regular Member
  • *
  • Posts: 17
  • Quam olim da capo.
Re: Code Editor Line number?
« Reply #5 on: April 04, 2014, 07:03:05 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

  • Regular Member
  • *
  • Posts: 10
Re: Code Editor Line number?
« Reply #6 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

jj2007

  • Member
  • *****
  • Posts: 10318
  • Assembler is fun ;-)
    • MasmBasic
Re: Code Editor Line number?
« Reply #7 on: February 15, 2020, 02:56:11 AM »
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

  • Regular Member
  • *
  • Posts: 10
Re: Code Editor Line number?
« Reply #8 on: February 15, 2020, 03:19:16 AM »
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

  • Member
  • *****
  • Posts: 10318
  • Assembler is fun ;-)
    • MasmBasic
Re: Code Editor Line number?
« Reply #9 on: February 15, 2020, 03:32:27 AM »
edit2; 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

  • Member
  • ***
  • Posts: 462
Re: Code Editor Line number?
« Reply #10 on: February 15, 2020, 03:34:12 AM »
I'm confused.
What is it you are looking for exactly?

aurel

  • Regular Member
  • *
  • Posts: 10
Re: Code Editor Line number?
« Reply #11 on: February 15, 2020, 03:59:02 AM »
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

  • Regular Member
  • *
  • Posts: 10
Re: Code Editor Line number?
« Reply #12 on: February 15, 2020, 04:01:16 AM »
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

  • Member
  • *****
  • Posts: 10318
  • Assembler is fun ;-)
    • MasmBasic
Re: Code Editor Line number?
« Reply #13 on: February 15, 2020, 04:03:15 AM »
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

  • Member
  • ***
  • Posts: 462
Re: Code Editor Line number?
« Reply #14 on: February 15, 2020, 04:24:32 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?