FBR_IDE a lightweight basic FB IDE

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
Post Reply
ron77
Posts: 200
Joined: Feb 21, 2019 19:24
Location: Israel
Contact:

FBR_IDE a lightweight basic FB IDE

Post by ron77 »

hello i've started a project to attempt to code a notepad like text editor called FBR_WORD - the project is under GNU license and is developed in WinFBE for windows... currently i'm working on an early prototype - i would like to give here a small DEMO video if it would be possible...

i'll try at least...

update 11/4/2012: i've created a second version of the text editor which now is a lightweight basic FB IDE called FBR_IDE

it is FOSS under GNU license (v 3.0)

and you can now do with it as you wish...

here is the GitHub repository
https://github.com/ronblue/FBR_IDE

:) :D

ron77
Last edited by ron77 on Apr 11, 2021 18:19, edited 5 times in total.
ron77
Posts: 200
Joined: Feb 21, 2019 19:24
Location: Israel
Contact:

Re: FBR_WORD - a simple text-editor in Freebasic

Post by ron77 »

hello - i need some help with my program... it seems that when i open a file and the text is displayed on the text editor text box i cannot edit the text freely that is i cannot add new lines after the original message that was loaded from the text file ...

here is the code from frmMain.bas where all of the code is:

Code: Select all

dim shared as string text
'reDIM shared AS STRING buffer(0)
Const string1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Const string2 = "VsciBjedgrzyHalvXZKtUPumGfIwJxqOCFRApnDhQWobLkESYMTN"

SUB sAppend(arr() AS STRING , Item AS STRING)
	REDIM PRESERVE arr(LBOUND(arr) TO UBOUND(arr) + 1) AS STRING
	arr(UBOUND(arr)) = Item
END SUB

function encode(text AS STRING) as string
   Dim s As String
   Dim p As INTEGER
   Dim As String vector, key2
   
   vector = string1 : key2 = string2
   DIM currentChar AS INTEGER
   FOR i AS INTEGER = 0 TO len(text)
'      
      currentChar = ASC(MID(text, i, 1))

      IF (currentChar >= 65 AND currentChar <= 90) OR (currentChar >= 97 AND currentChar <= 122) THEN
        p = INSTR(vector, MID(text, i, 1))
        MID(text, i, 1) = MID(key2, p, 1)
      END IF
    
'       
      
   NEXT
   return text

   
END function

function decode(text AS STRING) as string
   Dim s As String
   Dim p As INTEGER
   Dim As String vector, key2
   
   vector = string2 : key2 = string1
   DIM currentChar AS INTEGER
   FOR i AS INTEGER = 0 TO len(text)
'      
      currentChar = ASC(MID(text, i, 1))

      IF (currentChar >= 65 AND currentChar <= 90) OR (currentChar >= 97 AND currentChar <= 122) THEN
        p = INSTR(vector, MID(text, i, 1))
        MID(text, i, 1) = MID(key2, p, 1)
      END IF
    
'       
      
   NEXT
   return text

   
END function


SUB txtfile(f AS STRING)
	
'	DIM AS STRING buffer
	DIM h AS LONG = FREEFILE()
	OPEN f FOR BINARY AS #h
'	buffer = SPACE(LOF(h))
	put #h ,  , text
	CLOSE #h
'	PRINT buffer
End SUB


function helpfile(lines as string) as string

    return lines & !"\r\n" '& !"\r\n"
'Dim As Long SelEnd = Len(Form1.Text1.Text) 
'    SendMessage(form1.text1.hWindow, EM_SETSEL, SelEnd, SelEnd)
'    SendMessage form1.text1.hWindow, EM_SCROLLCARET, 0, 0
end function



function txtfileopen(f AS string) as string
	
'	reDIM AS STRING buffer(0)
    dim as string buffer
	DIM h AS LONG = FREEFILE()
	OPEN f FOR binary AS #h
	buffer = SPACE(LOF(h))
'while eof(h)
	get #h , ,buffer
'    sappend(buffer(), r)
'    wend
	CLOSE #h
    return buffer
End function





''
''  Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(Form1)



''
''
Function Form1_MainMenu_Click( ByRef sender As wfxMenuItem, ByRef e As EventArgs ) As LRESULT
    Select Case UCase(sender.Name)
        Case "MNUFILE"
           
        Case "MNUSAVE"
             text =  Form1.Text1.Text
            dim s as HWND
            DIM wszFile AS WSTRING * 260 = "*.*"
            DIM wszInitialDir AS STRING * 260 = CURDIR
            DIM wszFilter AS WSTRING * 260 = "TXT files (*.TXT)|*.TXT|" & "All Files (*.*)|*.*|"
            DIM dwFlags AS DWORD = OFN_EXPLORER OR OFN_FILEMUSTEXIST OR OFN_HIDEREADONLY OR OFN_OVERWRITEPROMPT
            DIM cws AS CWSTR = AfxSaveFileDialog(s, "Save", wszFile, wszInitialDir, wszFilter, "TXT", @dwFlags)
            AfxMsg cws
            txtfile(cws)
        Case "MNUOPEN"
            redim text2(0) as string
            dim as string r 
            dim s as HWND
            DIM wszFile AS WSTRING * 260 = "*.*"
            DIM wszInitialDir AS STRING * 260 = CURDIR
            DIM wszFilter AS WSTRING * 260 = "TXT files (*.TXT)|*.TXT|" & "All Files (*.*)|*.*|"
            DIM dwFlags AS DWORD = OFN_EXPLORER OR OFN_FILEMUSTEXIST OR OFN_HIDEREADONLY
            DIM cws AS CWSTR = AfxOpenFileDialog(s, "", wszFile, wszInitialDir, wszFilter, "TXT", @dwFlags, NULL)
            MessageBoxW(s, cws, "Open", MB_OK)
            Form1.Text1.Text = txtfileopen(cws)
              
        Case "MNUENCRYPT"
            dim text1 as string = Form1.Text1.Text
            Form1.Text1.Text = ""
            
            Form1.Text1.Text = encode(text1)
        Case "MNUDECRYPT"
            dim text1 as string = Form1.Text1.Text
            Form1.Text1.Text = ""
            
            Form1.Text1.Text = decode(text1)
        Case Else
    End Select
    Function = 0
End Function

''
''
Function Form1_MainMenu_Popup( ByRef sender As wfxMenuItem, ByRef e As EventArgs ) As LRESULT
    Select Case UCase(sender.Name)
        Case "MNUFILE"
        Case Else
    End Select
    Function = 0
End Function

''
''
'Function Form1_Text1_TextChanged( ByRef sender As wfxTextBox, ByRef e As EventArgs ) As LRESULT
'    dim text4 as string = Form1.Text1.Text
'    if instr(text4, !"\r\n") then
'        Form1.Text1.Text = Form1.Text1.Text & !"\n"' & !"\r\n"
'    end if
    
'    Function = 0
'End Function

ron77
Posts: 200
Joined: Feb 21, 2019 19:24
Location: Israel
Contact:

Re: FBR_WORD - a simple text-editor in Freebasic

Post by ron77 »

well i changed the sub/functions for read and write to/from text files with out binary but the problem still persist

updated code of frmMain.bas

Code: Select all

dim shared as string text
'reDIM shared AS STRING buffer(0)
Const string1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Const string2 = "VsciBjedgrzyHalvXZKtUPumGfIwJxqOCFRApnDhQWobLkESYMTN"

SUB sAppend(arr() AS STRING , Item AS STRING)
	REDIM PRESERVE arr(LBOUND(arr) TO UBOUND(arr) + 1) AS STRING
	arr(UBOUND(arr)) = Item
END SUB

function encode(text AS STRING) as string
   Dim s As String
   Dim p As INTEGER
   Dim As String vector, key2
   
   vector = string1 : key2 = string2
   DIM currentChar AS INTEGER
   FOR i AS INTEGER = 0 TO len(text)
'      
      currentChar = ASC(MID(text, i, 1))

      IF (currentChar >= 65 AND currentChar <= 90) OR (currentChar >= 97 AND currentChar <= 122) THEN
        p = INSTR(vector, MID(text, i, 1))
        MID(text, i, 1) = MID(key2, p, 1)
      END IF
    
'       
      
   NEXT
   return text

   
END function

function decode(text AS STRING) as string
   Dim s As String
   Dim p As INTEGER
   Dim As String vector, key2
   
   vector = string2 : key2 = string1
   DIM currentChar AS INTEGER
   FOR i AS INTEGER = 0 TO len(text)
'      
      currentChar = ASC(MID(text, i, 1))

      IF (currentChar >= 65 AND currentChar <= 90) OR (currentChar >= 97 AND currentChar <= 122) THEN
        p = INSTR(vector, MID(text, i, 1))
        MID(text, i, 1) = MID(key2, p, 1)
      END IF
    
'       
      
   NEXT
   return text

   
END function


SUB txtfile(f AS STRING)
	
'	DIM AS STRING buffer
	DIM h AS LONG = FREEFILE()
	OPEN f FOR output AS #h
'	buffer = SPACE(LOF(h))
'while not eof(h)
'	put #h ,  , text
    print #h, text
'    buffer = buffer
	CLOSE #h
'	PRINT buffer
End SUB


function helpfile(lines as string) as string

    return lines & !"\r\n" '& !"\r\n"
'Dim As Long SelEnd = Len(Form1.Text1.Text) 
'    SendMessage(form1.text1.hWindow, EM_SETSEL, SelEnd, SelEnd)
'    SendMessage form1.text1.hWindow, EM_SCROLLCARET, 0, 0
end function



function txtfileopen(f AS string) as string
	
'	reDIM AS STRING buffer(0)
    dim as string buffer, r
	DIM h AS LONG = FREEFILE()
	OPEN f FOR input AS #h
'	buffer = SPACE(LOF(h))
while not eof(h)
	input #h, r
    buffer = buffer & r & !"\r\n"
'    sappend(buffer(), r)
    wend
	CLOSE #h
    return buffer
End function





''
''  Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(Form1)



''
''
Function Form1_MainMenu_Click( ByRef sender As wfxMenuItem, ByRef e As EventArgs ) As LRESULT
    Select Case UCase(sender.Name)
        Case "MNUFILE"
           
        Case "MNUSAVE"
             text =  Form1.Text1.Text
            dim s as HWND
            DIM wszFile AS WSTRING * 260 = "*.*"
            DIM wszInitialDir AS STRING * 260 = CURDIR
            DIM wszFilter AS WSTRING * 260 = "TXT files (*.TXT)|*.TXT|" & "All Files (*.*)|*.*|"
            DIM dwFlags AS DWORD = OFN_EXPLORER OR OFN_FILEMUSTEXIST OR OFN_HIDEREADONLY OR OFN_OVERWRITEPROMPT
            DIM cws AS CWSTR = AfxSaveFileDialog(s, "Save", wszFile, wszInitialDir, wszFilter, "TXT", @dwFlags)
            AfxMsg cws
            txtfile(cws)
        Case "MNUOPEN"
            redim text2(0) as string
            dim as string r 
            dim s as HWND
            DIM wszFile AS WSTRING * 260 = "*.*"
            DIM wszInitialDir AS STRING * 260 = CURDIR
            DIM wszFilter AS WSTRING * 260 = "TXT files (*.TXT)|*.TXT|" & "All Files (*.*)|*.*|"
            DIM dwFlags AS DWORD = OFN_EXPLORER OR OFN_FILEMUSTEXIST OR OFN_HIDEREADONLY
            DIM cws AS CWSTR = AfxOpenFileDialog(s, "", wszFile, wszInitialDir, wszFilter, "TXT", @dwFlags, NULL)
            MessageBoxW(s, cws, "Open", MB_OK)
            Form1.Text1.Text = txtfileopen(cws)
              
        Case "MNUENCRYPT"
            dim text1 as string = Form1.Text1.Text
            Form1.Text1.Text = ""
            
            Form1.Text1.Text = encode(text1)
        Case "MNUDECRYPT"
            dim text1 as string = Form1.Text1.Text
            Form1.Text1.Text = ""
            
            Form1.Text1.Text = decode(text1)
        Case Else
    End Select
    Function = 0
End Function

''
''
Function Form1_MainMenu_Popup( ByRef sender As wfxMenuItem, ByRef e As EventArgs ) As LRESULT
    Select Case UCase(sender.Name)
        Case "MNUFILE"
        Case Else
    End Select
    Function = 0
End Function

''
''
'Function Form1_Text1_TextChanged( ByRef sender As wfxTextBox, ByRef e As EventArgs ) As LRESULT
'    dim text4 as string = Form1.Text1.Text
'    if instr(text4, !"\r\n") then
'        Form1.Text1.Text = Form1.Text1.Text & !"\n"' & !"\r\n"
'    end if
    
'    Function = 0
'End Function

ron77
Posts: 200
Joined: Feb 21, 2019 19:24
Location: Israel
Contact:

Re: FBR_WORD - a simple text-editor in Freebasic

Post by ron77 »

hi

here is a new DEMO with me demonstrating the current state of the text editor and explaining the bug that it has...

https://sendvid.com/6dl37fgy

ron77
ron77
Posts: 200
Joined: Feb 21, 2019 19:24
Location: Israel
Contact:

Re: FBR_WORD - a simple text-editor in Freebasic

Post by ron77 »

hello i managed to find a solution to the bug... :-/
PaulSquires
Posts: 938
Joined: Jul 14, 2005 23:41

Re: FBR_WORD - a simple text-editor in Freebasic

Post by PaulSquires »

I see that you are posting the exact same questions here as well as over on my PlanetSquires forum. You may want to pick one or the other.
BTW, this is not a "bug". It is your misunderstanding of how multiline edit controls work and that AcceptReturn should be used.
PaulSquires
Posts: 938
Joined: Jul 14, 2005 23:41

Re: FBR_WORD - a simple text-editor in Freebasic

Post by PaulSquires »

BTW, I have posted over on my forum a pretty feature complete Notepad project that should help you. It is developed using WinFBE Visual Designer and incorporates full unicode support for text and files.
ron77
Posts: 200
Joined: Feb 21, 2019 19:24
Location: Israel
Contact:

Re: FBR_WORD - a simple text-editor in Freebasic

Post by ron77 »

thank you paul - your notepad project is quit elegant and full featured - however i wish to "try things my way" that is to build this text editor from scratch and to learn from the experience rather then just copy from an existing project...
Post Reply