Sublime Forum

Dev Build 2144

#1

Dev Build 2144 is out now, with a few miscellaneous changes.

0 Likes

Encoding questions
Encoding questions
#2

API: Added view.encoding() and view.set_encoding() API: Added view.line_endings() and view.set_line_endings()
yippee !!!

0 Likes

#3

What are the semantics of .set_encoding()?

  1. I’ve got a file encoded using cp1250 with accented characters,
  2. 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]

  1. 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?

0 Likes

#4

Hy Jon. There is a problem on showing * on tab that has modified content. (* is missing)

0 Likes

#5

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

0 Likes

#6

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.

0 Likes

#7

[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
0 Likes

#8

ok, thanks

0 Likes

#9

[quote=“bizoo”]API: Added view.encoding() and view.set_encoding() API: Added view.line_endings() and view.set_line_endings()
yippee !!![/quote]

:mrgreen: Thank You Jps!

0 Likes

#10

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.

0 Likes

#11

[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.

0 Likes

#12

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')
0 Likes

#13

But it doesn’t :smile: thanks anyway guillermooo.

0 Likes

#14

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.

0 Likes

#15

[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).

0 Likes

#16

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.

0 Likes

#17

Thanks but it`s ugly the new way … :frowning:

0 Likes

#18

??? 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.

0 Likes

#19

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, its ok that works again on soda.

0 Likes

#20

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?

0 Likes