Skip to content

Commit

Permalink
add suppport for unregistered Sublime versions
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenzek committed Jan 6, 2018
1 parent 3738c64 commit 60e73e3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ it will update the window title.
## Installation

This package is avalaible on [PackageControl](https://packagecontrol.io/).
If you have an unregistered version of Sublime Text you need to set the
setting "unregistered" to `true` (or to buy a license!).

## Requirement

Expand Down
12 changes: 9 additions & 3 deletions set_window_title.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sublime
import sublime

This comment has been minimized.

Copy link
@gwenzek

gwenzek Apr 18, 2018

Owner

I don't know what changed here, maybe I screw up the space. See #6


import os
import time
Expand Down Expand Up @@ -161,6 +161,10 @@ def get_official_title(self, view, project):
if project:
official_title += " (%s)" % project
official_title += " - Sublime Text"
settings = sublime.load_settings("set_window_title.sublime-settings")
if settings.get("unregistered", False):
official_title += " (UNREGISTERED)"

return official_title

def get_new_title(self, view, project, old_title):
Expand All @@ -174,8 +178,10 @@ def get_new_title(self, view, project, old_title):
settings)
template = self._replace_condition(template, "is_dirty",
view.is_dirty(), settings)

return template.format(path=path, project=project)
new_title = template.format(path=path, project=project)
if settings.get("unregistered", False):
new_title += " (UNREGISTERED)"
return new_title

def _pretty_path(self, view, settings):
view_name = view.name()
Expand Down
5 changes: 4 additions & 1 deletion set_window_title.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
// Are you using an unregistered version of Sublime ?
"unregistered": false,

// Template for the window title.
// The template accept the following parameters:
// - {path}: the path of the current file
Expand Down Expand Up @@ -29,5 +32,5 @@
"untitled": "<untitled>",

// Output some debug info in the console.
"debug": true,
"debug": false,
}

0 comments on commit 60e73e3

Please sign in to comment.