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

jj2007

#15
Aurel,
The solution posted by Xusinboy Bekchanov works but is limited to the first 32768 (apparently) lines, then it restarts at zero under certain idiosyncratic circumstances:


Actually, it's much buggier than that, but I don't want to indulge in details here. Line numbers are 20th Century :biggrin:

The PARAFORMAT2 struct is described here at M$ docs. Note that they mention the wNumbering member, but it's not listed in the PARAFORMAT2 STRUCT; you would have to go back to PARAFORMAT, but the link is broken (apparently, nobody has ever used this feature, otherwise people would have complained, right?). But you can find it here.

To illustrate the mess, attached a little testbed. Press + to increase the wNumbering value, - to decrease it (see the status bar). Values<0 and >=7 produce nonsense, but #5 and #6 look very, very nice. Ideal for a code editor, actually :bgrin:

aurel

#16
Hello jj and others...of course
Well i am not master for this assembler stuff but i know very well how windows win32 api functions works.
First time when i see this qWord assembly code i have feeling that must work.
Hey jj , line numbers is not just 20c things they are very useful for me at last.
After downloading ...never using EasyCode IDE ..then VisualMasm - which looks very nice but always require Project
offering Visual Designer...what is not bad in general i download another one called SASM IDE..
and voila this small (not very small but looks to me simply enough). i use it to compile qWord program.
You can screenshot ...it work ...and much important ...work properly!  :thumbsup:
, i will spend some time to explore more masm examples.
JJ ...maybe you ask yourself...what that freak cooking this time...????
answer is simple..
This time i will try to create standalone code editor with my new interpreter without need for scintilla.
Yes scintilla is great control ,and i like it a lot...but it is one more separate .dll which always require adjusting,etc..etc...
well ..i really talking too much ...but ahh
i am glad that this assembly code work !

screenshot:
https://aurelsoft.ucoz.com/SASM_IDE_RichEditLineNumbers.png

aurel

Also i have a question.
Is this control subcassed in this qWord program?
thanks

jj2007

I don't think so. I can't tell you with certainty because I don't have the source.

aurel

well JJ , i really don't know about what source code you talking, source code is under qWord post in code box.
and that is all, another thing is , it looks to me that you simply don't like it
I always like someone else code if i find it useful...in this case it is
all best... :smiley:

hutch--

aurel,

Tread carefully here, this forum is not a free code ordering facility and giving lip to members who have tried to help you will get you kicked out of here like a rocket. If you want an editor written in assembler, feel free to write your own. First and last warning.

Mikl__

#21
Quoteis there a compiled 32 bit version of this program?
Hi, aurel!
It is a compiled 64 bit version of qWord program
asm-file; GUI #
include win64a.inc
IDC_EDIT    equ 100
IDD_DLG1    equ 101
IDC_ICON1   equ 10
MARGIN_X    equ 30
.code
WinMain proc
local dummy:qword

mov ecx,offset LibFileName
        invoke LoadLibrary
invoke LoadIcon,IMAGE_BASE,IDC_ICON1
mov hIcon,rax
mov r9d,offset DlgProc
invoke DialogBoxParam,IMAGE_BASE,IDD_DLG1,0,,rax
    invoke RtlExitUserProcess,NULL
WinMain endp

DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov hWnd,rcx

        cmp edx, WM_INITDIALOG
jz wmINITDIALOG
        cmp edx, WM_CLOSE
jz wmCLOSE
wmdefault:xor eax, eax
jmp wmBYE
wmINITDIALOG:
invoke SendMessage,,WM_SETICON,0,hIcon
invoke SendDlgItemMessage,hWnd,IDC_EDIT,EM_SETMARGINS,\
EC_LEFTMARGIN,MARGIN_X
invoke GetDlgItem,hWnd,IDC_EDIT
mov r8d,offset WndProc
invoke SetWindowLongPtr,eax,GWL_WNDPROC
mov g_pOrgWndProc,rax
jmp wmdefault
wmCLOSE:invoke EndDialog,,0
wmBYE: leave
retn
DlgProc endp

WndProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
local pt:POINT
local sz[6]:BYTE
local lc:dword
local rect:RECT
local rgn:qword
local old_rsi:qword

mov hWnd,rcx
mov uMsg,edx
mov old_rsi,rsi

mov [rsp+20h],r9;lParam
mov r9,r8;wParam
mov r8,rdx;uMsg
mov edx,ecx;hWnd
        invoke CallWindowProc,g_pOrgWndProc
cmp uMsg,WM_PAINT
jnz wmBYE
wmPAINT:invoke SendMessage,hWnd,EM_GETLINECOUNT,0,0
mov lc, eax
or eax, eax
jz wmBYE
invoke GetDC,hWnd
mov hDC,rax
lea edx,rect
invoke GetClientRect,hWnd
invoke CreateRectRgn,rect.left,rect.top,rect.right,rect.bottom
mov rgn,rax ;rgn
invoke SelectClipRgn,hDC,eax
invoke BitBlt,hDC,0,0,MARGIN_X,rect.bottom,hDC,0,0,PATCOPY
invoke SendMessage,hWnd,EM_GETFIRSTVISIBLELINE,0,0
mov esi,eax;lineNo
;.while esi <= lc
@@: invoke SendMessage,hWnd,EM_LINEINDEX,esi,0
inc eax;eax = -1?
jz break
lea r9d,[rax-1]
lea r8d,pt
invoke SendMessage,hWnd,EM_POSFROMCHAR
mov eax,pt.y
cmp eax,rect.bottom
ja break;.break .if eax > rect.bottom
inc esi;lineNo+
lea ecx,sz
mov edx,offset aLu  ; "%lu"
invoke wsprintf,,,esi
lea r9d,sz
mov r8d,pt.y
invoke TextOut,hDC,0,,,eax
cmp esi,lc
jbe @b;.endw
break: invoke DeleteObject,rgn
invoke SelectClipRgn,hDC,0
invoke ReleaseDC,hWnd,hDC
wmBYE: mov rsi,old_rsi
leave
retn
WndProc endp
.data
aLu db '%lu',0
LibFileName db 'msftedit.dll',0
g_pOrgWndProc dq ?
hDC dq ?
hIcon dq ?
end
rc-file#include "resource.h"
#define IDC_EDIT 100
#define IDD_DLG1 101
#define IDC_ICON1 10

IDC_ICON1 ICON DISCARDABLE "br_Fox1.ico"

IDD_DLG1 DIALOGEX 10,10,100,100
CAPTION "test"
FONT 12,"MS Sans Serif",0,0,0
STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER
BEGIN
CONTROL "",IDC_EDIT,"RichEdit50W",WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_WANTRETURN|ES_AUTOHSCROLL|ES_AUTOVSCROLL,0,0,90,50
END
There are asm-/rc-/ico-/exe-files in temp.zip attachment

aurel

QuoteTread carefully here, this forum is not a free code ordering facility and giving lip to members who have tried to help you will get you kicked out of here like a rocket. If you want an editor written in assembler, feel free to write your own. First and last warning.

hello admin
I just ask for help abut given example by qWord and nothing else.
I really cannot understand what i do wrong.
thanks

jj2007

@Mikl: Molto bello :thumbsup:

@Aurel: I just realise that qWord's post does contain the full source. I had thought it was only a snippet... my apologies :sad:

So all you have to do is copy the source, paste it into a text file, name it RicheditLineNumbers.asm, and build it, either with \Masm32\qEditor.exe or with \Masm32\MasmBasic\Richmasm.exe in case you have that installed.

Mikl__

#24
Ciao, jj2007!
ci ho provato (я старался...)

aurel

Hi jj
Yes it is complete example and probably only one we can find out there.
Yes i do that , i first install masm32 sdk on my win7_32bit computer then setting IDE options and as you can see
program is compiled and work perfectly.
You know that i don't have experience with asseblers and i don't want to bother Charles with asmosphere assembler.
all best...

aurel

Sorry i forgot ti say
thank Mikl_ for your 64bit version , i see code is different and because i don't know is that
WASM i found in your signature..
thanks