From 3f9d9bf84f53f93d9504d4f0cf0c3ef12502af3e Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Fri, 3 Jan 2014 15:51:27 +0100 Subject: [PATCH 1/6] Only install colorama on windows --- jrnl/util.py | 4 ++++ setup.py | 1 + 2 files changed, 5 insertions(+) diff --git a/jrnl/util.py b/jrnl/util.py index 102433c7..a14e2915 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -8,6 +8,8 @@ import keyring import pytz try: import simplejson as json except ImportError: import json +if "win32" in sys.platform: + import colorama import re import tempfile import subprocess @@ -141,5 +143,7 @@ def get_text_from_editor(config, template=""): def colorize(string): """Returns the string wrapped in cyan ANSI escape""" + if "win32" in sys.platform: + return colorama.Fore.CYAN + string + colorama.Fore.RESET return u"\033[36m{}\033[39m".format(string) diff --git a/setup.py b/setup.py index fafd0515..bd6455e1 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,7 @@ def get_version(filename="jrnl/__init__.py"): conditional_dependencies = { "pyreadline>=2.0": "win32" in sys.platform, + "colorama>=0.2.5": "win32" in sys.platform, "argparse==1.2.1": sys.version.startswith("2.6") } From 03bce74262f419d0bb75944e78b6b33067e4c04e Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Fri, 3 Jan 2014 15:52:59 +0100 Subject: [PATCH 2/6] Make editing work with templates --- jrnl/util.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jrnl/util.py b/jrnl/util.py index a14e2915..7a049ac0 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -128,11 +128,9 @@ def load_and_fix_json(json_path): def get_text_from_editor(config, template=""): tmpfile = os.path.join(tempfile.gettempdir(), "jrnl") - if template: - with codecs.open(tmpfile, 'w', "utf-8") as f: + with codecs.open(tmpfile, 'w', "utf-8") as f: + if template: f.write(template) - with open(tmpfile, 'w'): - pass subprocess.call(config['editor'].split() + [tmpfile]) with codecs.open(tmpfile, "r", "utf-8") as f: raw = f.read() From ea58151395ce810a09280ebb084ee08bf5aa394c Mon Sep 17 00:00:00 2001 From: William Minchin Date: Thu, 2 Jan 2014 17:58:49 -0700 Subject: [PATCH 3/6] Windows documentation --- docs/advanced.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/advanced.rst b/docs/advanced.rst index b00c4525..6fcafee4 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -99,3 +99,26 @@ Your ``default`` and your ``food`` journals won't be encrypted, however your ``w Changing ``encrypt`` to a different value will not encrypt or decrypt your journal file, it merely says whether or not your journal `is` encrypted. Hence manually changing this option will most likely result in your journal file being impossible to load. +Windows Usage +------------- + +A couple of tips to get jrnl working better on Windows: + +The configuration file is typically found at ``C:\Users\[Your Username\.jrnl_conf``. This is just a text file and so can be edited in a text editor (but don't use Notepad, it will mess with the line endings). + +For editing entries, Notepad will technically work, but doesn't play nice with line endings. A good alternative is `Notepad++ `_. To set Notepad++ as your editor, edit the jrnl config file (``.jrnl_conf``) like this: + +.. code-block:: javascript + + { + ... + "editor": "C:\\Program Files (x86)\\Notepad++\\notepad++.exe -multiInst", + } + +The double backslashes are needed so jrnl can read the file path correctly. The ``-multiInst`` option will cause jrnl to open its own Notepad++ windows. When you're done editing an entry in Notepad++, save the file and close the Notepad++ window for jrnl to know you're done editing and record your changes. + +Known Issues +~~~~~~~~~~~~ + +- The Windows shell prior to Windows 7 has issues with unicode encoding. If you want to use non-ascii characters, change the codepage with ``chcp 1252`` before using `jrnl` (Thanks to Yves Pouplard for solving this!) +- _jrnl_ relies on the `PyCrypto` package to encrypt journals, which has some known problems with installing on Windows and within virtual environments. From 480eb4574b3d1af4c4b5fbc0bc2c069b17be1dc5 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Fri, 3 Jan 2014 15:59:38 +0100 Subject: [PATCH 4/6] Move docs on Windows to FAQ --- docs/advanced.rst | 18 ------------------ docs/recipes.rst | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/docs/advanced.rst b/docs/advanced.rst index 6fcafee4..b7d098f1 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -99,24 +99,6 @@ Your ``default`` and your ``food`` journals won't be encrypted, however your ``w Changing ``encrypt`` to a different value will not encrypt or decrypt your journal file, it merely says whether or not your journal `is` encrypted. Hence manually changing this option will most likely result in your journal file being impossible to load. -Windows Usage -------------- - -A couple of tips to get jrnl working better on Windows: - -The configuration file is typically found at ``C:\Users\[Your Username\.jrnl_conf``. This is just a text file and so can be edited in a text editor (but don't use Notepad, it will mess with the line endings). - -For editing entries, Notepad will technically work, but doesn't play nice with line endings. A good alternative is `Notepad++ `_. To set Notepad++ as your editor, edit the jrnl config file (``.jrnl_conf``) like this: - -.. code-block:: javascript - - { - ... - "editor": "C:\\Program Files (x86)\\Notepad++\\notepad++.exe -multiInst", - } - -The double backslashes are needed so jrnl can read the file path correctly. The ``-multiInst`` option will cause jrnl to open its own Notepad++ windows. When you're done editing an entry in Notepad++, save the file and close the Notepad++ window for jrnl to know you're done editing and record your changes. - Known Issues ~~~~~~~~~~~~ diff --git a/docs/recipes.rst b/docs/recipes.rst index 852b1219..0bfb92a5 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -36,6 +36,26 @@ On OS X, you can use the fabulous `iA Writer `_ to What does this do? ``open -b ...`` opens a file using the application identified by the bundle identifier (a unique string for every app out there). ``-Wn`` tells the application to wait until it's closed before passing back control, and to use a new instance of the application. + +Using Notepad++ to write entries on Windows +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. note:: + + The configuration file is typically found at ``C:\Users\[Your Username]\.jrnl_conf``. This is just a text file and so can be edited in a text editor (but don't use Notepad, it will mess with the line endings). + +To set `Notepad++ `_ as your editor, edit the jrnl config file (``.jrnl_conf``) like this: + +.. code-block:: javascript + + { + ... + "editor": "C:\\Program Files (x86)\\Notepad++\\notepad++.exe -multiInst", + } + +The double backslashes are needed so jrnl can read the file path correctly. The ``-multiInst`` option will cause jrnl to open its own Notepad++ window. When you're done editing an entry in Notepad++, save the file and close the Notepad++ window for jrnl to know you're done editing and record your changes. + + Known Issues ------------ From 24147a25affb74adb902662841cf310bd38f8b24 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Fri, 3 Jan 2014 16:02:39 +0100 Subject: [PATCH 5/6] Changelog --- CHANGELOG.md | 2 +- LICENSE | 2 +- jrnl/__init__.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d26aac0..e4684510 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Changelog ### 1.7 (December 22, 2013) -* __1.7.4__ Gets rid of colorama. +* __1.7.5__ Colorama is only needed on windows. Smaller fixes * __1.7.3__ Touches temporary files before opening them to allow more external editors. * __1.7.2__ Dateutil added to requirements. * __1.7.1__ Fixes issues with parsing time information in entries. diff --git a/LICENSE b/LICENSE index df698485..f2fbf16a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013 Manuel Ebert +Copyright (c) 2014 Manuel Ebert Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 33c20aa5..a8e1bfe3 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -7,10 +7,10 @@ jrnl is a simple journal application for your command line. """ __title__ = 'jrnl' -__version__ = '1.7.4' +__version__ = '1.7.5' __author__ = 'Manuel Ebert' __license__ = 'MIT License' -__copyright__ = 'Copyright 2013 Manuel Ebert' +__copyright__ = 'Copyright 2013 - 2014 Manuel Ebert' from . import Journal from . import cli From 57785117abe820db7a2134876c33980203d22a32 Mon Sep 17 00:00:00 2001 From: William Minchin Date: Fri, 3 Jan 2014 10:42:32 -0700 Subject: [PATCH 6/6] colorama fixes --- jrnl/util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jrnl/util.py b/jrnl/util.py index 7a049ac0..0c5d148d 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -10,6 +10,7 @@ try: import simplejson as json except ImportError: import json if "win32" in sys.platform: import colorama + colorama.init() import re import tempfile import subprocess @@ -141,7 +142,5 @@ def get_text_from_editor(config, template=""): def colorize(string): """Returns the string wrapped in cyan ANSI escape""" - if "win32" in sys.platform: - return colorama.Fore.CYAN + string + colorama.Fore.RESET return u"\033[36m{}\033[39m".format(string)