import sublime
from .javatar_actions import *
from .javatar_updater import *
from .javatar_usage import send_usages, get_usage_data, start_clock, stop_clock


# YY.MM.DD.HH.MM
VERSION = "14.11.12.23.14b"
UPDATEFOR = "all"
NEWSID = 18


def get_version():
    return VERSION


def show_news(title, prefix=""):
    news = ("Just install Javatar? Checkout JavatarDoc for Javatar information and guides. Link is located in README file.\n\n"
            "A small update but got a new improvement on class creation. Be sure to checkout JavaDoc!\n"
            "These are updates and fixes for Javatar " + VERSION + "...\n"
            "- Build notification via SubNotify (more details in JavatarDoc)\n"
            "- Fix package/class creation did not show any details\n"
            "- Fix Javatar Shell cause Sublime Text crash on output encoding error\n"
            "- Javatar Shell will now scroll to bottom\n"
            "- Class creation improvements (See JavaDoc for more information)\n"
            "- Remove abstract class snippets since a new class creation improvement can do more!\n\n"
            "You can report/suggest any issue on Javatar repository. Link is already located in README file.")
    view = sublime.active_window().new_file()
    view.set_name(title)
    view.run_command("javatar_util", {"util_type": "add", "text": prefix + news})
    view.set_read_only(True)
    view.set_scratch(True)


def check_news():
    add_action("javatar.util.news", "Check news")
    from .javatar_utils import get_settings, set_settings, is_stable
    if get_settings("message_id") < NEWSID:
        if get_settings("message_id") != -1:
            stop_clock(notify=False)
            if is_stable() and (UPDATEFOR == "stable" or UPDATEFOR == "all"):
                show_news("Javatar: Package has been updated!")
                add_action(
                    "javatar.util.news", "Show stable news"
                )
            elif not is_stable() and (UPDATEFOR == "dev" or UPDATEFOR == "all"):
                show_news("Javatar [Dev]: Package has been updated!")
                add_action("javatar.util.news", "Show dev news")
            start_clock()
            send_usages(get_usage_data())
            set_settings("message_id", NEWSID)
        elif get_settings("javatar_gp") & 0x1 == 0:
            send_usages(get_usage_data(), True)

@@ -232,95 +232,29 @@
 18%0A%0A
-%0Adef get_version():%0A    return VERSION%0A%0A%0Adef show_news(title, prefix=%22%22):%0A    news = (%22
+NEWS_TEMPLATE = '''%5C%0A
 Just
@@ -358,35 +358,18 @@
 ME file.
-%5Cn%5Cn%22%0A            %22
+%0A%0A
 A small 
@@ -448,33 +448,17 @@
 JavaDoc!
-%5Cn%22%0A            %22
+%0A
 These ar
@@ -493,43 +493,21 @@
 tar 
-%22 + 
+%7B
 VERSION
- + %22...%5Cn%22%0A            %22
+%7D...%0A
 - Bu
@@ -565,33 +565,17 @@
 atarDoc)
-%5Cn%22%0A            %22
+%0A
 - Fix pa
@@ -619,33 +619,17 @@
  details
-%5Cn%22%0A            %22
+%0A
 - Fix Ja
@@ -689,33 +689,17 @@
 ng error
-%5Cn%22%0A            %22
+%0A
 - Javata
@@ -731,33 +731,17 @@
 o bottom
-%5Cn%22%0A            %22
+%0A
 - Class 
@@ -796,33 +796,17 @@
 rmation)
-%5Cn%22%0A            %22
+%0A
 - Remove
@@ -885,27 +885,10 @@
 ore!
-%5Cn%5Cn%22%0A            %22
+%0A%0A
 You 
@@ -978,18 +978,143 @@
 ME file.
-%22)
+%0A'''%0A%0A%0Adef get_version():%0A    return VERSION%0A%0A%0Adef show_news(title, prefix=%22%22):%0A    news = NEWS_TEMPLATE.format(get_version())%0A
 %0A    vie

Use a constant for the news template