jdTextEdit - A advanced Text Editor

Hi! I installed the 32 bit version of jdTextEdit. It’s a very good editor. Lot of options, nice!

The only little problem that I found, is related to the Haiku Application menu shortcut. If I run it from the Terminal, works perfectly. But if I use from the “Applications” menu, I get the following error message:

“jdTextEdit is unable to create his data folder”

I guess it try to write in some read-only folder. It’s weird because if I run it from the same location, but using the Terminal, works without any issue.

This can be a common issue for some applications because the Terminal provides more environment variables than when applications are launched outside the terminal. Since this is a Python application that is what I would suspect. Maybe it is trying to find something under $HOME for example but $HOME is empty and then it tries to create something in the root of the system, which is read-only.

There is probably a way for it to be fixed in the code but JakobDev might need to look into that. Haiku does provide some APIs to look up common folder names which maybe would be better to do here.

1 Like

I found the error. jdTextEdit ties to create his folder on a completely other place when it launches from the Menu. This directory doesn’t exists yet and jdTextEdit is unable to create sub directories in the current versions. This will be fixed in the future. In the mean time run this in the Terminak to fix the problem:

mkdir -p ~/.local/share

But it doesn’t fix the problem, that jdTextEdit uses a completely other directory when it is launched from the Terminal. It currently uses the following code to find the directory:

def getDataPath(env):
    if env.args["dataDir"]:
        return env.args["dataDir"]
    elif os.getenv("JDTEXTEDIT_DATA_PATH"):
        return os.getenv("JDTEXTEDIT_DATA_PATH")
    elif "dataDirectory" in env.distributionSettings:
        return env.distributionSettings["dataDirectory"].replace("~",str(Path.home()))
    elif os.getenv("SNAP_USER_DATA"):
        return os.path.join(os.getenv("SNAP_USER_DATA"),"jdTextEdit")
    elif platform.system() == 'Windows':
        return os.path.join(os.getenv("appdata"),"jdTextEdit")
    elif platform.system() == 'Darwin':
        return os.path.join(str(Path.home()),"Library","Application Support","jdTextEdit")
    else:
        if os.getenv("XDG_DATA_HOME"):
            return os.path.join(os.getenv("XDG_DATA_HOME"),"jdTextEdit")
        else:
            return os.path.join(str(Path.home()),".local","share","jdTextEdit")

I think it uses XDG_DATA_HOME when it is launched from the Terminal. Have anyone a suggestion which folder I should use on Haiku?

Besides of that, I think it’s a big problem that Haiku launches programs with other environment vars if you start a program from Terminal or from Menu. That may affect more programs and is a thing that needs to be fixed.

1 Like

home/config/settings/jdeditor/
Or:
home/config/jdeditor/
In Haiku you should avoid prefix with a dot (.config .data .settings)
If you use IRC you will get faster and better answers than here for short questions like:

Some patches already are at haikuports, maybe you can find some useful information there?

2 Likes

There are some patches around for it also (not sure if it helps, haven’t looked into the source):

3 Likes

Works now from Applications folder. Haiku 64bit newest hrev.

Very nice feature rich App, great to have. Check it out!

Please do not use dotfolders and alien folders on Haiku. With maximal respect: this is not a solution.

1 Like

10 posts were split to a new topic: Environment Variables Behavior On Haiku

Never though that this would cause be a long discussion. I’m not a Haiku developer but I still think having the same environment when launching from console and when launching from menu would be great. Whatever opinion you have about environment variables, it is fact that lots of programs using them, which needs to be extra patched for Haiku. But I think this should be discussed in a extra thread instead of here.

Anyways, Version 8.3 of jdTextEdit is now out. jdTextEdit now uses config/settings/jdTextEdit as directory. If you have any data in the old directories, just copy them into the new new folder. I also added line operations.

8 Likes

Thank you for your work on porting your editor @JakobDev. Sorry for the noise about environment variables, I have moved that into a new topic.

1 Like

I’m currently working on a new design of the settings window:
Screenshot_20210302_222218

10 Likes

I’m working on a split view for the next version:
Screenshot_20210305_174925

12 Likes

Great work :+1:

1 Like

The current code has been uploaded to GitLab. Would be nice if somebody could test it before I make a release. The split view requires a lot of code rewrite, so there might be bugs left. You can split it with View>Split View. The saved sessions are not compatible with the new version. It’s the best to start jdTextEdit in portable mode (run with -p) which doesn’t effect your data to test it.

I also added a menu to add templates from the editor, so you doesn’t need to copy files in the template folder by yourself, what users might not know.

1 Like

Would be nice to add a html 5 page template with new structure…

What about a dark theme?

How to do that, I could not find the save as template in Menu…

Can you post a template for HTML5? I’m not doing anything with HTML.

Did you mean a dark theme for the editor or the whole software?

You can save a file as template under File>New (from Template)>Add

Not sure by myself, I would be great to have a dark theme for the editor like we have in Koder (Haiku native editor)

Having a dark Theme for the editor is possible. jdTextEdit has already a API for adding Themes.But the Theme need colors for each language jdTextEdit offers, which is a lot of work, and I’m not a designer. Converting Themesfrom other editors isalso not easy.