Dev Build 2144 is out now, with a few miscellaneous changes.
Dev Build 2144
API: Added view.encoding() and view.set_encoding()
API: Added view.line_endings() and view.set_line_endings()
yippee !!!
What are the semantics of .set_encoding()?
- I’ve got a file encoded using cp1250 with accented characters,
- I open this file in Sublime, unfortunately it’s able to interpret file content as ‘utf-8’ string, so the fallback encoding is not used:
>>> view.encoding()
u'UTF-8'
3) Then I call:
[code]>>> view.set_encoding(u’Central European (Windows 1250)’)
view.encoding()
u’Central European (Windows 1250)’[/code]
- However, it seems like Sublime did not reinterpret the file content (bytes) using new encoding, but simply stored new encoding to be used when saving.
Now that I think about it, this behaviour is reasonable. However I would like to be able somehow handle encoding specifying comments python.org/dev/peps/pep-0263/.
What do you think jps?
Hy Jon. There is a problem on showing * on tab that has modified content. (* is missing)
It doesn’t work yet with Soda Theme (need update).
But it work for me with default theme (the cross is replaced with a big dot).
startup, version: 2144 windows x64 channel: dev
It just sets the encoding that will be used when saving next. If you want to reopen the current file with a different encoding, you can use the reopen command - see Default/Main.sublime-menu for an example.
[quote=“bizoo”]
It doesn’t work yet with Soda Theme (need update).
But it work for me with default theme (the cross is replaced with a big dot).
startup, version: 2144 windows x64 channel: dev[/quote]
To get the indicators working in Soda again you just need to add the following to your Global settings.
"highlight_modified_tabs": true
[quote=“bizoo”]API: Added view.encoding() and view.set_encoding()
API: Added view.line_endings() and view.set_line_endings()
yippee !!![/quote]
Thank You Jps!
API: Added view.encoding() and view.set_encoding()
API: Added view.line_endings() and view.set_line_endings()
What’s the list of encodings accepted by set_encoding() ?
I try to get an UTF-8 with BOM but didn’t find how to spell it…
And is there any plan to have default encoding by syntax ?
Actually, I use different encoding for different language:
-Delphi and PL/SQL files -> cp1252
-Python -> utf-8 BOM
-Almost anything else -> utf-8
Actually new files are ‘Undefined’ and get an encoding when saved.
What I like is that the encoding used when the file is saved come from a settings in the Base File.sublime-settings (or the syntax specific one).
A warning message before saving if the encoding didn’t take care of some of the char in the buffer would be nice.
I’m pretty sure it’s easy to make a plugin that trap the on_pre_save event to do that work, but I just wonder if something is planned before doing it.
[quote=“jps”]
It just sets the encoding that will be used when saving next. If you want to reopen the current file with a different encoding, you can use the reopen command - see Default/Main.sublime-menu for an example.[/quote]
So it’s possible to call reopen from API ? Afaik it’s not exposed to public.
Commands can be executed via API in one of the following ways:
view.run_command('command_name_here')
window.run_command('command_name_here')
IIRC, since recently the window object dispatches view commands based on input focus, so you can run view/window commands from window plugins easily.
You can also pass args if needed:
window.run_command('command_name_here', {"arg1_here":"foo", "arg2_here":10)
So I guess this should work:
window.run_command('reopen')
The works for me, though:
view.run_command("reopen", {"encoding":"utf-16 le"})
I might have made up the part about command dispatching or just didn’t get it right.
[quote=“guillermooo”]The works for me, though:
view.run_command("reopen", {"encoding":"utf-16 le"})
I might have made up the part about command dispatching or just didn’t get it right.[/quote]
You have right it works now, but I was trying to run it in on_load event and that was the problem (it’s working only via sublime.set_timeout in on_load).
I’ve now updated Soda Theme to support the new file state theme features.
Sidebar file items will now show a dirty indicator, and tabs will show a dirty state indicator if you’ve got “highlight_modified_tabs”: true.
??? All he added was a dot by the file…how can that be ugly? I find it very useful. Before I had a hard time telling what wasn’t saved, now I can easily tell. I think it looks fine, and more importantly, useful.
Id like the old way what shown an asterix after tab text, not the new one that replace (x) from close tab with a round..Anyway, it
s ok that works again on soda.
I see the new tab dirty indicators (very nice update, thanks), but I’m not seeing the sidebar dirty indicator – is there a setting to turn that on?