• Welcome to PlanetSquires Forums.
 

A little fun WinFBE project :-)

Started by Paul Squires, July 15, 2016, 11:50:08 PM

Previous topic - Next topic

Paul Squires

I am putting this modern version of the editor on hold. I am working on feature completing the original classic version of the editor. I will be adding the UTF-8 capability today and will update the GitHub repository later tonight.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

I added the UTF-8 support by following Jose's suggestions in this thread. Once I upload the source/exe change tonight to GitHub I will ask for help in testing that the Unicode characters function correctly in the editor.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

New WinFBE with UTF-8 unicode support added to GitHub repository.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

#18
It works as expected and it is all you can do using Scintilla, that has not UTF-16 support.

However, keep in mind that, since Windows does not understand UTF-8, it is only a workaround. What will be needed is UTF-16 support in Scintilla, but I don't think that this will happen.

People wanting to use unicode through UTF-8 will need to always use a function like AfxUcode to convert from UTF-8 to UTF-16.

José Roca

#19
The code templates are outdated.

I will revise them to use CWSTR instead of WSTRING.

Paul Squires

Awesome, thanks Jose for testing the UTF-8 functionality. I am working on some user interface changes this morning and hope to have it posted today. I will start a separate thread detailing changes once that is done.

(feels good to be back programming again)
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

#21
Using the 64-bit version I have noticed two problems, but I can't repeat them at will, ie. sometimes happens and sometimes don't.

The first one is that sometimes the editor is unable to load the text of a template. Must be because you have changed my original code posted at http://www.planetsquires.com/protect/forum/index.php?topic=3867.msg28442#msg28442

You're using REDIM PRESERVE and this causes problems. With REDIM PRESERVE apparently the memory changes and some of the pointers stored in the listbox are no longer valid. This is why I first get the number of files to dimension the array.

   ' // Search templates
   DIM hSearch as HANDLE, WFD AS WIN32_FIND_DATAW, FileNo AS LONG, nType AS LONG, nItem AS LONG
   DIM wszPath AS WSTRING * MAX_PATH, wszCurPath AS WSTRING * MAX_PATH, wszText AS WSTRING * 260
   DIM wszFullPath AS WSTRING * MAX_PATH * 2, idx AS LONG, nLin AS LONG
   wszPath = ExePath & "\Templates\"
   wszCurPath = wszPath & "*.fbtpl"

   ' // Count the number of files and dimension the array
   ' // REDIM PRESERVE causes problems
   DIM nCount AS LONG
   hSearch = FindFirstFileW(wszCurPath, @WFD)
   IF hSearch <> INVALID_HANDLE_VALUE THEN
      DO
         IF (WFD.dwFileAttributes AND FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY THEN
            nCount +=1
         END IF
      LOOP WHILE FindNextFileW(hSearch, @WFD)
      FindClose(hSearch)
   END IF
   ' // Dimension the array
   IF nCount = 0 THEN EXIT FUNCTION
   DIM rgwszPaths(nCount - 1) AS WSTRING * MAX_PATH
   idx = 0

   ' // Find the files
   hSearch = FindFirstFileW(wszCurPath, @WFD)
   IF hSearch <> INVALID_HANDLE_VALUE THEN
      DO
         IF (WFD.dwFileAttributes AND FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY THEN
            wszFullPath = wszPath & WFD.cFileName
            ' // Get the description
            FileNo = FREEFILE
            OPEN wszFullPath FOR INPUT AS #FileNo
            IF ERR = 0 THEN
               nLin = 0
               DO UNTIL EOF(FileNo)
                  LINE INPUT #FileNo, wszText
                  nLin += 1
                  IF nLin = 1 THEN nType = VAL(wszText)
                  IF nType < 1 OR nType > 2 THEN EXIT DO
                  IF nType = 1 AND nLin = 3 THEN EXIT DO
                  IF nType = 2 AND nLin = 4 THEN EXIT DO
               LOOP
               CLOSE FileNo
               ' // Display the description in the listbox
               nItem = SendMessageW(hListBox, LB_ADDSTRING, 0, cast(LPARAM, @wszText))
               ' // Store the full path in the array
               rgwszPaths(idx) = wszFullPath
               ' // Store a pointer to the element of the array in the listbox item
               SendMessageW hListBox, LB_SETITEMDATA, nItem, cast(LPARAM, VARPTR(rgwszPaths(idx)))
               idx += 1
               IF idx > UBOUND(rgwszPaths) THEN EXIT DO
            END IF
         END IF
      LOOP WHILE FindNextFileW(hSearch, @WFD)
      FindClose(hSearch)
   END IF



The second one are random crashes when changing colors and clicking the OK button. The selection is saved, but the editor sometimes crashes.

Paul Squires

Thanks Jose, I will revert the code back. I will also check the color selection crash problem. I have been testing using the 32-bit version but I will switch to the 64 bit version tonight.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

I have been making lots of changes to the user interface today so I can't upload new code until that is stable.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer