• 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

Last Sunday I was sitting on the couch getting ready to watch the Portugal/France match and started doing a little research on code editor features looking for ideas for things to add to WinFBE. I started reading reviews of all of the major code editors. One review of Notepad++ stood out to me because it said that the editor was amazing in terms of functionality but it's user interface was horribly dated. That got me thinking that WinFBE's interface must look dated as well because it is based on very traditional concepts.

Last year when I was doing a lot of web development, I used SublimeText editor a lot. I loved it's interface because it was so unobtrusive. A few reviews pointed to Microsoft's new open source code editor, VS Code. I downloaded it and it looks awesome.

So.... I just started coding out of enjoyment wondering if I could emulate those editors. Got to use a lot of my old Win GDI skills. Decided to use GDI because it is so fast and I didn't want to take the time to learn Direct 2D or DirectWrite, etc. Everything progressed quite quickly. Custom made tab control, custom statusbar, popout panels, etc. Best of all, it is high dpi ware, localized, and based on color theme files. I created a "dark" theme that you will see in the screenshot below. Just about everything on the screen can be assigned a color.

I have attached some demo files if you are adventurous and would like to see the application live. There is not very much functionality in it yet. The tab control does not scroll left or right yet. I eliminated all scroll bars from the controls because I need to create my own so that they look better visually with the color scheme.

The hardest/coolest/most frustrating thing to code so far was the control for the file/folder explorers. I started writing it from scratch and then a couple of days into it, it made more sense to use a standard Treeview. I had to use some cool custom draw and other programming magic in order to get it to look and act like the control in VS Code. Still more work needed on it though but it's getting there.

Long story short, I like the new style and I guess I'm a little excited to show it off. I now need to use Jose's latest CWindow and Afx code into the codebase. That will be great test of Jose's new tools. Looking forward to using WSTR instead of all those fixed WSTRINGs.

Now it will be nice to have to separate versions of WinFBE that will cater to just about everyone's tastes.

....it's getting late here. Time for bed.  :)




Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Oh, and this only works on Windows Vista or higher.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

You will notice just how super fast and flicker free the program is. I took great care to eliminate flicker. I just tested CWindow RC13 and only had to make a couple of changes for it to compile.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Johan Klassen


Marc Pons

hi Paul,

your new editor, will it be unicode compliant ?
if yes using what kind of encoding , uft8, utf16, ucs2... ?

and as I have seen, it uses the scintilla lexer , wich seems to only plays with utf8 unicode encoding,

i'm wondering how do you manage that?

Marc

Paul Squires

The application itself is UTF-16 because it is Windows based only. There is a way to use Scintilla with Unicode but I haven't delved into it yet. Apparently, Notepad++ uses Scintilla and Unicode.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

Scintilla doesn't support UT16, but UT-8. In CSED I have an option called "Enable Unicode (UT-8)". Then, when I set the Scintilla options, I do:


   ' // Enable unicode (UTF-8 encoding)
   IF pSed.UnicodeEnabled THEN
      SCIP_SetCodePage pSci, %SC_CP_UTF8
   ELSE
      SCIP_SetCodePage pSci, 0
   END IF


José Roca

#7
But Windows doesn't support UTF-8. Therefore, you have to use:


DIM cbs AS CBSTR = AfxUcode("Дми́трий", CP_UTF8)
SetWindowTextW pWindow.hWindow, cbs


If you don't activate UTF-8, you can do:


DIM cbs AS CBSTR = AfxUcode("Дми́трий", 1251)
SetWindowTextW pWindow.hWindow, cbs


Either activate UTF-8 and use CP_UTF8 as the code page, or choose the appropriate charset and pass the code page for that language.


José Roca

#8
In the first case, the literal is saved as ansi UTF-8 encoded: "Дми́Ã'‚Ã'â,¬ÃÂ¸ÃÂ¹"

In the second case, the literal is saved as ASCII: "Ã,,ìèòðèé"

So simply add the option of enable UTF-8 and let the user to choose if he wants to use UTF-8 or choose a charset.

José Roca

#9
Since I added UTF-8 support to the last version of CWSTR, you can also use:


DIM cbs AS CBSTR = CBSTR("Дми́Ã'‚Ã'â,¬ÃÂ¸ÃÂ¹", CP_UTF8)
SetWindowTextW pWindow.hWindow, cbs


That in the editor will look like


DIM cbs AS CBSTR = CBSTR("Дми́трий", CP_UTF8)
SetWindowTextW pWindow.hWindow, cbs


if you implement the enable UTF-8 option and the user has checked it.

It can be the simpler solution because you will always use CP_UTF8 as the code page, and it also works with CWSTR.


DIM cws AS CWSTR = CWSTR("Дми́трий", CP_UTF8)
SetWindowTextW pWindow.hWindow, cws


It also has the advantage of working with accented Russian vocals,  whereas choosing the Russian charset Scintilla doesn't understand them. So, my advice is to use UTF-8 encoding, because it is what Scintilla supports.

With the lastest version of CWSTR we can even do:


SetWindowTextW pWindow.hWindow, CWSTR("Дми́трий", CP_UTF8)


or


SetWindowTextW pWindow.hWindow, CBSTR("Дми́трий", CP_UTF8)


Of course, don't use FB's WSTR, that does not support a code page.

Paul Squires

Thanks Jose, I will come back to this once I get to the point of adding the unicode functionality for Scintilla. I am still pretty new to the whole unicode universe :)
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Marc Pons

Jose, Paul


yes i think, the more convenient way is doing,  as Jose is saying

have implemented the  "enable UTF-8 option" and the user has to checked it.
( or better if the file was saved as utf_8 it could be automaticaly selected)

using the lastest version of CWSTR
after the user would  can see on the screen :

SetWindowTextW pWindow.hWindow, CWSTR("Дми́трий", CP_UTF8)


but , if in fact the real typing the user has to do is the following:
SetWindowTextW pWindow.hWindow, CWSTR("Дми́Ã'‚Ã'â,¬ÃÂ¸ÃÂ¹", CP_UTF8)

because scintilla can show utf8 as unicode representation , but user have to enter all as utf-8 code
scintilla does not have convertion tool .

Paul , i think you probably have to give somewhere , a menu for encoding / converting ( as notepad++ is giving)
or better vitual keyboards to make the input WYSIWYG...

Paul

José Roca

Convertion tool: A dialog with two text boxes, one for input and another for output. Input: Enter text in your f**g language and click the Convert button. Output: Text translated to UTF-8.

Marc Pons

found a site that gives the direct input with virtual keyboards
and after you simply copy the selected text ,wich is utf8 encoded,
to the editor .

it works perfectly with csed when enabling utf8 usage

the site : https://www.branah.com

as sample,for russian https://www.branah.com/russian

Paul Squires

After having used the new format for the editor I am not impressed with the usability of the left hand side popout menu panels or the concept of using actual disk folders for a project. Although they look cool, they just do not add enough value to the editor.  I am removing both of those concepts and reverting back to a simpler left hand side treeview that displays files belonging to the project. Projects will be implemented in the same manner as they are in the current WinFBE version rather than the using the "folder" concept.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer