flat assembler
Message board for the users of flat assembler.

Index > Main > Sorry. But i not found examples how using FEDIT.DLL

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 16 Dec 2020, 20:11
How get selected text from FEDIT window ?
I mean somthing like as WM_GETTEXT, but only selected text(not all text)


I think using WM_COPY, but its sometimes not handful solution.
Post 16 Dec 2020, 20:11
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 27 Dec 2020, 10:37
How select all text in FEDIT window ?
I try do FEM_SETPOS but not text selected.

invoke SendMessage,[FEDIThwnd],FEM_SETPOS,pSelAllTxt,0
pSelAllTxt dd 1,1,1,-1


Last edited by Roman on 27 Dec 2020, 10:57; edited 1 time in total
Post 27 Dec 2020, 10:37
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 27 Dec 2020, 10:52
Roman wrote:
How select all text in FEDIT window ?
I try do FEM_SETPOS but not text selected.
See how it is implemented in fasmw's source:
Code:
  select_all:
        mov     [fepos.selectionLine],1
        mov     [fepos.selectionPosition],1
        mov     [fepos.caretLine],-1
        mov     [fepos.caretPosition],1
        invoke  SendMessage,ebx,FEM_SETPOS,fepos,0
        invoke  SendMessage,ebx,FEM_GETPOS,fepos,0
        invoke  SendMessage,ebx,FEM_GETLINELENGTH,[fepos.caretLine],0
        inc     eax
        mov     [fepos.caretPosition],eax
        invoke  SendMessage,ebx,FEM_SETPOS,fepos,0
        jmp     finish    
Post 27 Dec 2020, 10:52
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 27 Dec 2020, 11:05
Thanks Tomasz.
Problem when i select my window all selection in FEDIT
disappears.

I press on my window button 'Selec All Text'.
And not see selection in FEDIT


Last edited by Roman on 27 Dec 2020, 11:21; edited 2 times in total
Post 27 Dec 2020, 11:05
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 27 Dec 2020, 11:13
I found need ES_NOHIDESEL when createWindowEx 'FEDIT'
Post 27 Dec 2020, 11:13
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 30 Dec 2020, 10:35
I load my text in MyTxtBuffer
And set text to FEDIT window:
invoke SendMessage,[FEDIT],WM_SETTEXT,0,MyTxtBuffer

How do first undo when i load text in FEDIT window ?


My problem.
I load text in FEDIT window.
Then i write word 'hi'
Press undo but nothings happens.
Then i write second word ' all'
Press undo and FEDIT window deleted word ' all'.
https://www.youtube.com/watch?v=F9MqJUBtpZ8&feature=youtu.be&ab_channel=Roman8139
Post 30 Dec 2020, 10:35
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 31 Dec 2020, 13:34
This is right ?
Code:
invoke  SendMessage,[FEDITHwnd],WM_SETTEXT,0,MyTxtBuffer  
invoke  SendMessage,[FEDITHwnd],FEM_ISUNMODIFIED,0,0
invoke  SendMessage,[FEDITHwnd],FEM_SETMODE,0,0
invoke  SendMessage,[FEDITHwnd],EM_EMPTYUNDOBUFFER,0,0
    
Post 31 Dec 2020, 13:34
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 01 Jan 2021, 16:30
Tomasz how colorize some words ?
For example invoke draw yellow.

I try do colorize but get strange result.
Last char 'e' was yellow, but 'invok' another color.
When i press space and delete space all word 'invoke' was yellow and all next chars too(in this text line).
Code:
macro myColoriz4 chWord,ofst {local l1
      sub al,al
      cmp dword [esi+ofst],chWord
      jnz l1
      inc al
l1:
      }
macro myColoriz2 chWord,ofst {local l1
      sub al,al
      cmp word [esi+ofst],chWord
      jnz l1
      inc al
l1:
      }
macro  SetClrTxt chClr { local u1
       test al,al
       jz   u1
       movd eax,xmm1
       ;sub  dword [eax],
       add  dword [eax+8],24
       invoke  SetTextColor,ebx,chClr
u1:
       }
color_ok:       
        mov     ecx,[esp]
        mov     eax,[font_width]
        mul     ecx
        add     eax,[rect.left]
        mov     [rect.right],eax
        lea     eax,[rect]
        push eax ecx
        movd  xmm1,eax
        myColoriz4 'invo',0
        myColoriz2 'ke',4
        SetClrTxt  0xFFEE00
        pop ecx eax        
        invoke  DrawText,ebx,esi,ecx,eax,DT_LEFT+DT_NOPREFIX+DT_SINGLELINE 
    
Post 01 Jan 2021, 16:30
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 01 Jan 2021, 17:04
Roman wrote:
Tomasz how colorize some words ?
For example invoke draw yellow.
Do you ask how to do it with FEDIT control? Because there you would need to set up syntax highlighting routines, but the code snippets that you provided have nothing to do with FEDIT.
Post 01 Jan 2021, 17:04
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 01 Jan 2021, 19:29
Its part of code from fedit.inc
I see syntax_colors.
Code:
syntax_color:
        movzx   eax,al
        mov     edx,[syntax_colors]
        or      edx,edx
        jz      default_color
        mov     eax,[edx+(eax-1)*4]
        invoke  SetTextColor,ebx,eax
        jmp     color_ok
    


Code:
wm_paint:
        lea     eax,[rect]
        invoke  GetUpdateRect,[hwnd],eax,FALSE
        or      eax,eax
        jz      finish_wndproc
        cmp     [screen_base],0
        je      finish_wndproc
        lea     eax,[ps]
        invoke  BeginPaint,[hwnd],eax
        mov     ebx,eax
        invoke  CreateSolidBrush,[background_color]
        mov     [background_brush],eax
        invoke  CreateSolidBrush,[selection_background]
        mov     [selection_brush],eax
        invoke  SelectObject,ebx,[editor_font]
        mov     esi,[screen_base]
        add     esi,[screen_offset]
        mov     eax,[screen_width]
        mul     [screen_height]
        lea     edi,[esi+eax]
        mov     [rect.top],0
        mov     eax,[font_height]
        mov     [rect.bottom],eax
        mov     ecx,[screen_height]
    paint_screen:
        push    ecx
        mov     [rect.left],0
        mov     ecx,[screen_width]
    paint_line:
        cmp     byte [esi],0
        je      paint_empty_block
        mov     edx,1
        mov     al,[edi]
    get_characters_block:
        cmp     edx,ecx
        je      get_color
        cmp     al,[edi+edx]
        jne     get_color
        cmp     byte [esi+edx],0
        je      get_color
        inc     edx
        jmp     get_characters_block
    paint_empty_block:
        mov     edx,1
        test    byte [edi],80h
        jnz     get_empty_selection
    get_empty_block:
        cmp     edx,ecx
        je      fill_empty_block
        cmp     byte [esi+edx],0
        jne     fill_empty_block
        test    byte [edi+edx],80h
        jnz     fill_empty_block
        inc     edx
        jmp     get_empty_block
    fill_empty_block:
        push    ecx edx
        mov     eax,[font_width]
        mul     edx
        add     eax,[rect.left]
        mov     [rect.right],eax
        lea     eax,[rect]
        invoke  FillRect,ebx,eax,[background_brush]
        jmp     paint_next_block
    get_empty_selection:
        cmp     edx,ecx
        je      fill_empty_selection
        cmp     byte [esi+edx],0
        jne     fill_empty_selection
        test    byte [edi+edx],80h
        jz      fill_empty_selection
        inc     edx
        jmp     get_empty_selection
    fill_empty_selection:
        push    ecx edx
        mov     eax,[font_width]
        mul     edx
        add     eax,[rect.left]
        mov     [rect.right],eax
        lea     eax,[rect]
        invoke  FillRect,ebx,eax,[selection_brush]
        jmp     paint_next_block
    get_color:
        push    ecx edx
        test    byte [edi],80h
        jnz     highlight_color
        invoke  SetBkColor,ebx,[background_color]
        mov     al,[edi]
       ; invoke  SetTextColor,ebx,0x00ff00
       ; jmp     color_ok
        or      al,al
        jnz     syntax_color
    default_color:
        invoke  SetTextColor,ebx,[text_color]
        jmp     color_ok
    syntax_color:
        movzx   eax,al
        mov     edx,[syntax_colors]
        or      edx,edx
        jz      default_color
        mov     eax,[edx+(eax-1)*4]
        invoke  SetTextColor,ebx,eax
        jmp     color_ok
    highlight_color:
        invoke  SetBkColor,ebx,[selection_background]
        invoke  SetTextColor,ebx,[selection_text]
    color_ok:
        ;myColoriz4 'invo',0
        ;myColoriz2 'ke',4
        ;SetClrTxt  0xff0000
        mov     ecx,[esp]
        mov     eax,[font_width]
        mul     ecx
        add     eax,[rect.left]
        mov     [rect.right],eax
        lea     eax,[rect]
    ;    push eax ecx
    ;    movd  xmm1,eax
    ;    myColoriz4 'invo',0
    ;    myColoriz2 'ke',4
    ;    SetClrTxt  0xff0000
    ;    pop ecx eax
        ;mov  eax,myRctColor
        invoke  DrawText,ebx,esi,ecx,eax,DT_LEFT+DT_NOPREFIX+DT_SINGLELINE
    paint_next_block:
        pop     edx ecx
        sub     ecx,edx
        add     esi,edx
        add     edi,edx
        mov     eax,[rect.right]
        mov     [rect.left],eax
        or      ecx,ecx
        jnz     paint_line
        mov     eax,[font_height]
        add     [rect.top],eax
        add     [rect.bottom],eax
        pop     ecx
        dec     ecx
        jnz     paint_screen
        invoke  DeleteObject,[background_brush]
        invoke  DeleteObject,[selection_brush]
        lea     eax,[ps]
        invoke  EndPaint,[hwnd],eax
        xor     eax,eax
        jmp     finish_wndproc
    
Post 01 Jan 2021, 19:29
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 01 Jan 2021, 20:09
The implementation of WM_PAINT is such that it updates only the portions of the window that have been invalidated (with InvalidateRect), and it is done in the "refresh_line" loop, where the updated text is compared to the previous snapshot in order to detect which letters have changed and need to be redrawn.

Note that the content of the window, which is checked for changes, is kept in a format similar to DOS text mode (in fact, in case of fasm's IDE for DOS, which is also based on fedit, it translates directly to the text mode video memory), each character is two bytes, one for ASCII code and the next one for color (as assigned by the syntax highlighting procedure). If neither of them changes, the character does not become a part of invalidated (and therefore redrawn by WM_PAINT) region.

To alter the color of the text, you should use customized syntax highlighting procedure (set up with FEM_SETSYNTAXHIGHLIGHT message), not change WM_PAINT code.
Post 01 Jan 2021, 20:09
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 02 Jan 2021, 06:38
Ok.
I found:
Code:
;FEDIT.inc this.
proc SyntaxProc lpLine,uChars,lpColors
        ret
endp
    


But how colorize word 'invoke' to yellow color ?
Because i don't want changed others colors. For example i don`t change color word 'mov' or word 'call'
And don`t change color for []\,.; and digits 'string ' and simple text.

I found this example. But not understooded how do colorize only for word 'invoke'
Code:
invoke  SendMessage,[hwnd],FEM_SETSYNTAXHIGHLIGHT,asm_syntax_colors,fasm_syntax
proc fasm_syntax lpLine,uChars,lpColors
        push    ebx esi edi
        mov     esi,[lpLine]
        mov     edi,[lpColors]
        mov     ebx,characters
        mov     ecx,[uChars]
        xor     edx,edx
  .scan_syntax:
        lodsb
  .check_character:
        cmp     al,20h
        je      .syntax_space
        cmp     al,3Bh
        je      .syntax_comment
        mov     ah,al
        xlatb
        or      al,al
        jz      .syntax_symbol
        or      edx,edx
        jnz     .syntax_neutral
        cmp     ah,27h
        je      .syntax_string
        cmp     ah,22h
        je      .syntax_string
        cmp     ah,24h
        je      .syntax_pascal_hex
        cmp     ah,39h
        ja      .syntax_neutral
        cmp     ah,30h
        jae     .syntax_number
  .syntax_neutral:
        or      edx,-1
        inc     edi
        loop    .scan_syntax
        jmp     .done
  .syntax_space:
        xor     edx,edx
        inc     edi
        loop    .scan_syntax
        jmp     .done
  .syntax_symbol:
        mov     al,1
        stosb
        xor     edx,edx
        loop    .scan_syntax
        jmp     .done
  .syntax_pascal_hex:
        cmp     ecx,1
        je      .syntax_neutral
        mov     al,[esi]
        mov     ah,al
        xlatb
        or      al,al
        jz      .syntax_neutral
        cmp     ah,24h
        jne     .syntax_number
        cmp     ecx,2
        je      .syntax_neutral
        mov     al,[esi+1]
        xlatb
        or      al,al
        jz      .syntax_neutral
  .syntax_number:
        mov     al,2
        stosb
        loop    .number_character
        jmp     .done
  .number_character:
        lodsb
        mov     ah,al
        xlatb
        xchg    al,ah
        or      ah,ah
        jz      .check_character
        cmp     al,20h
        je      .check_character
        cmp     al,3Bh
        je      .check_character
        mov     al,2
        stosb
        loop    .number_character
        jmp     .done
  .syntax_string:
        mov     al,3
        stosb
        dec     ecx
        jz      .done
        lodsb
        cmp     al,ah
        jne     .syntax_string
        mov     al,3
        stosb
        dec     ecx
        jz      .done
        lodsb
        cmp     al,ah
        je      .syntax_string
        xor     edx,edx
        jmp     .check_character
  .process_comment:
        lodsb
        cmp     al,20h
        jne     .syntax_comment
        inc     edi
        loop    .process_comment
        jmp     .done
  .syntax_comment:
        mov     al,4
        stosb
        loop    .process_comment
  .done:
        pop     edi esi ebx
        ret
endp
    
Post 02 Jan 2021, 06:38
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 02 Jan 2021, 09:27
I try do this. And get colorize for word 'invoke' but next chars in this line have not correct colors !
Code:
proc fasm_syntax lpLine,uChars,lpColors
        push    ebx esi edi
        mov     esi,[lpLine]         ;line text
        mov     edi,[lpColors]
        mov     ebx,characters
        mov     ecx,[uChars]         ;line len
        xor     edx,edx
;my invoke
        ;mov     ebx,[lpLine]    ;kazduu line texta obrabotaet !
        cmp     dword [esi],'invo'
        jnz     .scan_syntax
        cmp     word [esi+4],'ke'
        jnz     .scan_syntax
        mov     al,5
        stosb
        stosb
        stosb
        stosb
        stosb
        stosb
        jmp    .syntax_space

  .scan_syntax:
        lodsb
  .check_character:
        cmp     al,20h
        je      .syntax_space
        cmp     al,3Bh
        je      .syntax_comment
        mov     ah,al
        xlatb
        or      al,al
        jz      .syntax_symbol
        or      edx,edx
        jnz     .syntax_neutral
        cmp     ah,27h
        je      .syntax_string
        cmp     ah,22h
        je      .syntax_string
        cmp     ah,24h
        je      .syntax_pascal_hex
        cmp     ah,39h
        ja      .syntax_neutral
        cmp     ah,30h
        jae     .syntax_number
  .syntax_neutral:
        or      edx,-1
        inc     edi
        loop    .scan_syntax
        jmp     .done
  .syntax_space:
        xor     edx,edx
        inc     edi
        loop    .scan_syntax
        jmp     .done
  .syntax_symbol:
        mov     al,1
        stosb
        xor     edx,edx
        loop    .scan_syntax
        jmp     .done
  .syntax_pascal_hex:
        cmp     ecx,1
        je      .syntax_neutral
        mov     al,[esi]
        mov     ah,al
        xlatb
        or      al,al
        jz      .syntax_neutral
        cmp     ah,24h
        jne     .syntax_number
        cmp     ecx,2
        je      .syntax_neutral
        mov     al,[esi+1]
        xlatb
        or      al,al
        jz      .syntax_neutral
  .syntax_number:
        mov     al,2
        stosb
        loop    .number_character
        jmp     .done
  .number_character:
        lodsb
        mov     ah,al
        xlatb
        xchg    al,ah
        or      ah,ah
        jz      .check_character
        cmp     al,20h
        je      .check_character
        cmp     al,3Bh
        je      .check_character
        mov     al,2
        stosb
        loop    .number_character
        jmp     .done
  .syntax_string:
        mov     al,3
        stosb
        dec     ecx
        jz      .done
        lodsb
        cmp     al,ah
        jne     .syntax_string
        mov     al,3
        stosb
        dec     ecx
        jz      .done
        lodsb
        cmp     al,ah
        je      .syntax_string
        xor     edx,edx
        jmp     .check_character
  .process_comment:
        lodsb
        cmp     al,20h
        jne     .syntax_comment
        inc     edi
        loop    .process_comment
        jmp     .done
  .syntax_comment:
        mov     al,4           ;v al nomer cveta iz tablici cvetov
        stosb                  ;esli >4 to nado v tablici cvetov dobavit eshe !
        loop    .process_comment
  .done:
        pop     edi esi ebx
        ret
endp                         
    
Post 02 Jan 2021, 09:27
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 02 Jan 2021, 09:51
I do this. Perhaps maybe all looks fine for word 'invoke' Smile
Code:
cmp     dword [esi],'invo'
        jnz     .scan_syntax
        cmp     word [esi+4],'ke'
        jnz     .scan_syntax
        mov     al,5
        stosb
        stosb
        stosb
        stosb
        stosb
        stosb
        sub    ecx,7
        add    esi,7
        mov    al,20h
        sub    ah,ah
        jmp    .check_character
    

Yes ! I done.
https://www.youtube.com/watch?v=oNRvlp4PQyg
Post 02 Jan 2021, 09:51
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 04 Jan 2021, 21:06
Tomasz its right ?
I mean select all chars in current line:
Code:
xorps   xmm1,xmm1
movups dqword    [fepos],xmm1
mov     [fepos.selectionPosition],1        
invoke  SendMessage,[hwnd],FEM_GETLINELENGTH,[fepos.caretLine],0
inc     eax
mov     [fepos.caretPosition],eax
invoke  SendMessage,[hwnd],FEM_SETPOS,fepos,0 
    
Post 04 Jan 2021, 21:06
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.