autodetect bug

Developers
2004-04-15
2004-04-16
  • limodou, I removed your section in DrFrame.OnPrefs.

    It messed with the preference.  I am not clear on what you were trying to accomplish there, but whatever it is, that is not the way to do it.  It causes the preference for encoding to be completely ineffective.

     
    • liyinghui
      liyinghui
      2004-04-15

      When open a file, if the file encoding is utf-8, so I had to save the encoding in fileencodingArray. And the utf-8 will be the default encoding of the file. So I think when you open the preference window, the encoding option should be utf-8. Thus I added the code in OnPrefs. This indeed confuses the preference optionBut if I don't do this , when open preference option window, the encoding might be the default encoding option and not the utf-8 encoding. You can guess when you updating preference, what encoding should I use, original or new? This problem puzzled me so long. Later I advised you to create our own open file and save file window, and user can choice the file encoding with them. Further more, we must save each file encoding seperately. The preference encoding will be always the default encoding, and used when user doesn't sepcify the encoding of a file. When all of these things have down, the encoding problem will be resolved at last.

       
    • The thing about prefs, is that they are separate from what is going on in the application at the moment.

      They determine default behaviour only.  Therefore I do not set the "prompt is visible option" to a different value depending on whether or not a program is running.

      In the same vein, it would not be wise to set anything else in prefs, like encoding, based upon what the encoding is at a given moment.  That defeats the purpose of having preferences in the first place.

      " when open preference option window, the encoding might be the default encoding option and not the utf-8 encoding".  In this case, this is preciesly what should happen.  I'd expect a user who wants utf-8 by default to select utf-8 by default.

      You should not be updating the preference at all.
      If the user chooses a new default, then that can update DrPython, but only the user, not DrPython, should set preferences.

      Why do we have to save each file encoding separetly?

      I agree the new file dialog will fix a lot, but why the other stuff?

       
    • liyinghui
      liyinghui
      2004-04-16

      If you open a file in certain encoding, so you may want the file is saved in the same encoding. If you use SDI window, that's will easy to do. But when using MDI window, you could open a lot of file, and each file has different encoding, so if you only use default encoding in preperence, it may confuse all files' encoding. So I think, if one file opened with certain encoding, we must save the encoding, then use it when saving the file. If one file opened without certain encoding, i.e. default encoding, we may use encoding in preference or in saving file window to encode the file. And this will not confuse the preference. Thus I said, "we must save the file encoding seperately", in order to save the file in proper encoding. Could you understand me?

       
    • This is no longer the case.

      Since encoding is saved in each Document, then each Document will save with the correct encoding (unless something has been changed).

      In terms of prefs, yes, that is how it should work.

      Unless the user says "autodetect", then DrPython will use their default encoding when they open files.  When they open a file, they can tell DrPython to use a different encoding (or not use one at all).

      I am not sure where the problem is.

       
    • liyinghui
      liyinghui
      2004-04-16

      It could be a mistake. What I said "we must save the file encoding seperately" only means I want to save each file's encoding. Is your mean that it has been saved in txtDocument.locale, and doesn't need to save it in an alone place. I agree on this.

       
    • Then I think we are set.  I took save to mean "Save a file".  I mean that the variable txtDocument.locale has been set.