News:

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

Main Menu

Try RichEditCtrl and syntaxhighlight

Started by minor28, June 11, 2014, 06:22:49 AM

Previous topic - Next topic

minor28

jj2007,

Quote
, but still, while building succeeds then, the dialog does not show up under WinXP SP3.
Your original exe works, though.
Now I have reinstalled WinXP and for me the dialog is showing up. This is odd.

I have not been able to stop working with the program before it works reasonably. Now it works also when typing and pasting text. The comment keyword was tricky.

guga

Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

Gunther

Hi Gustavo,

you've changed your signature and personal text. Cool.  :icon_cool:

Gunther
You have to know the facts before you can distort them.

guga

Hi Gunther, many tks  :bgrin:

I had forgotten to change it before.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

minor28

I have added tab marker lines. My problem is that the lines are not visible when a file is opened but only after scrolling. These are the functions for this.

The subclassed richedit process

.if uMsg==WM_PAINT
invoke HideCaret,hWin
invoke GetUpdateRect,hWin,addr rect,FALSE
mov eax,margin
sub eax,5
.if rect.left<eax
mov rect.right,eax
invoke ValidateRect,hWin,addr rect
.endif
invoke DrawLineNumbers
invoke ShowCaret,hWin


and


DrawLineNumbers proc
LOCAL hDC:dword
LOCAL mDC:dword
LOCAL hBitmapObj:dword
LOCAL hFontObj:dword
LOCAL buffer[32]:BYTE
LOCAL hBitmap:dword
local rect:RECT
local h:dword
local linecount:dword

;----------------------------
local linebuf[256]:byte
local rect2:RECT
LOCAL stride:dword
local ppTabLine:dword
local ppGraphics:dword
local fValue:real4
LOCAL ppBrush:dword
local ppPen:dword
LOCAL rectF:RECTF
local ppTabLineBitmap:dword
;----------------------------

;Touching the stack frame
mov eax,ebp
.while eax>esp
dec eax
mov byte ptr [eax],0
.endw

invoke GetClientRect,hRED1,addr rect
mov eax,margin
mov rect.right,eax
mov eax,rect.bottom
add eax,codeFontHeight
mov h,eax

invoke GetDC,hRED1
mov hDC,eax
invoke CreateCompatibleDC,hDC
mov mDC,eax
invoke CreateCompatibleBitmap,hDC,rect.right,rect.bottom
mov hBitmap,eax
invoke SelectObject,mDC,hBitmap
mov hBitmapObj,eax

invoke CreateFontIndirect,offset NumFont
invoke SelectObject,mDC,eax
mov hFontObj,eax

invoke CreateSolidBrush,numBKcolor
push eax
invoke FillRect,mDC,addr rect,eax
sub rect.right,5
pop eax
invoke DeleteObject,eax

invoke SetBkMode,mDC,TRANSPARENT
invoke SetTextColor,mDC,numTXTcolor

;----------------------------
;Draw indent lines
invoke SendMessage,hRED1,EM_GETRECT,0,addr rect2
mov eax,rect2.right
shl eax,2
mov stride,eax
mov eax,rect2.right
sub eax,rect2.left
mov edx,rect2.bottom
sub edx,rect2.top
invoke GdipCreateBitmapFromScan0,rect2.right,rect2.bottom,stride,PixelFormat32bppARGB,0,addr ppTabLineBitmap
.if eax==0
invoke GdipGetImageGraphicsContext,ppTabLineBitmap,addr ppGraphics
invoke GdipSetSmoothingMode,ppGraphics,SmoothingModeAntiAlias
invoke GdipCreateSolidFill,_ARGB(0,0,0,0),addr ppBrush
invoke GdipFillRectangleI,ppGraphics,ppBrush,0,0,rect2.right,rect2.bottom
invoke GdipSetSolidFillColor,ppBrush,_ARGB(255,255,150,150)
finit
pushd 1
fild dword ptr [esp]
fst fValue
add esp,4
invoke GdipCreatePen2,ppBrush,fValue,UnitPixel,addr ppPen
invoke GdipSetPenDashArray,ppPen,offset dashArray,2
invoke GdipSetPenDashStyle,ppPen,DashStyleCustom
.endif
;----------------------------

sub rect.right,5
invoke SendMessage,hRED1,EM_GETLINECOUNT,0,0
mov linecount,eax
invoke SendMessage,hRED1,EM_GETFIRSTVISIBLELINE,0,0
inc eax
xor ecx,ecx
.while eax<=linecount
push ecx
push eax
push ecx
;----------------------
push eax
;----------------------
push eax

;Draw line number
invoke wsprintf,addr buffer,ASTR("%d"),eax
pop eax
dec eax
invoke SendMessage,hRED1,EM_LINEINDEX,eax,0
invoke SendMessage,hRED1,EM_POSFROMCHAR,addr rect,eax
mov rect.left,0
invoke DrawText,mDC,addr buffer,-1,addr rect,DT_RIGHT
mov numLineHeight,eax

;----------------------------------
;Draw indent lines
pop eax
dec eax
lea edi,linebuf
mov word ptr [edi],sizeof linebuf
invoke SendMessage,hRED1,EM_GETLINE,eax,edi
.if eax
mov eax,1
.while byte ptr [edi]==9 && (byte ptr [edi + 1]==9 || byte ptr [edi + 1]==13 || \
byte ptr [edi + 1]==0)
add eax,TabSize
add eax,TabSize
push eax
mov ecx,rect.top
mov edx,ecx
add edx,codeLineHeight
invoke GdipDrawLineI,ppGraphics,ppPen,eax,ecx,eax,edx
pop eax
inc edi
.endw
.endif
;-------------------------------------

pop eax
mul numLineHeight
.if sdword ptr eax>h
add esp,8
.break
.endif

pop eax
inc eax
pop ecx
inc ecx
.endw

invoke GetClientRect,hRED1,addr rect
mov eax,margin
sub eax,5
mov rect.right,eax
mov edi,eax
dec edi
invoke MoveToEx,mDC,edi,rect.top,0
invoke LineTo,mDC,edi,rect.bottom
invoke BitBlt,hDC,0,0,rect.right,rect.bottom,mDC,0,0,SRCCOPY

;-------------------------
invoke GdipCreateFromHWND,hRED1,addr ppTabLine
invoke GdipDrawImageI,ppTabLine,ppTabLineBitmap,margin,1
;-------------------------

;numbers font
invoke SelectObject,mDC,hFontObj
invoke DeleteObject,eax
invoke DeleteObject,hBitmapObj
invoke DeleteObject,hBitmap
invoke DeleteDC,mDC

;--------------------------
;gdiplus
invoke GdipDeleteBrush,ppBrush
invoke GdipDeletePen,ppPen
invoke GdipDeleteGraphics,ppGraphics
invoke GdipDisposeImage,ppTabLineBitmap
invoke GdipDeleteGraphics,ppTabLine
;--------------------------

invoke ReleaseDC,hRED1,hDC

ret

DrawLineNumbers endp


What should I do to make the lines visible all the time? Any suggestions?

I attach the exe.

minor28

If I draw the line numbers in WM_PAINT message and the tab marker lines in WM_PRINTCLIENT it works fairly will. Some flickering though.

minor28

Without having any real goal, I continue with the project. If anyone is interested in following the project, I will from time to tim update my website regularly (http://minor28.divdev.se).

Gunther

Hi minor28,

Quote from: minor28 on October 06, 2014, 07:14:25 AM
Without having any real goal, I continue with the project. If anyone is interested in following the project, I will from time to tim update my website regularly (http://minor28.divdev.se).

interesting web site. You're a hard working man.  :t

Gunther
You have to know the facts before you can distort them.

minor28


Gunther

You have to know the facts before you can distort them.

jj2007

Quote from: minor28 on December 17, 2014, 08:36:05 PM
Now I have added outlinings to the editor  (http://minor28.divdev.se).

What do you mean with outlinings?

Apparently, you don't process all paint messages. Try the following:
- go to the end of a very long line
- press arrow right to advance to the start of the next line
- you'll probably see something like this:

minor28

QuoteWhat do you mean with outlinings?

Outlining is hiding/showing certain codelines.

The richedit doesn't trigger the WM_HSCROLL when scrolling with arrow keys but ENM_SCROLL to main window does. The EN_HSCROLL notification may do the invalidation instead.

About big files as windows.inc I have done nothing yet.