Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of new goodies from refactoring branch #127

Merged
merged 36 commits into from
Mar 13, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
caf3fb1
- Implemented custom input prompts via PromtEditor
richrd Feb 28, 2016
3d197cc
Polishing.
richrd Feb 28, 2016
3362eaa
Return False when promt is canceled.
richrd Feb 28, 2016
c31737e
Better string formatting.
richrd Feb 28, 2016
c368529
Linting.
richrd Feb 28, 2016
310e3ac
Refactored keymap to separate file with Sublime Text syntax.
richrd Feb 28, 2016
a355596
Tweaked keymap syntax and added Ctrl+Z for undo.
richrd Feb 28, 2016
eaf380a
Feature improvements
richrd Feb 28, 2016
3927eac
Fixed logging on Python 2.6 and disabled unicode symbols on Python 2.X
richrd Feb 29, 2016
b6e5109
Mapped Ctrl+Y to undo.
richrd Mar 1, 2016
00d7ac7
Restructured config command, added keymap command, and described usag…
richrd Mar 1, 2016
290c319
Refactored Viewer and Editor for better feature separation.
richrd Mar 1, 2016
1b95da0
Fixed proper initialization of PromptEditor.
richrd Mar 2, 2016
3858b74
Fixed saving files under new names.
richrd Mar 2, 2016
a8ee083
Added more scopes.
richrd Mar 2, 2016
6bd3d19
Fixed merging user keymap with defaults.
richrd Mar 2, 2016
12b336e
Slightly optimized lexer.
richrd Mar 2, 2016
9c9841b
Added performance notes.
richrd Mar 3, 2016
f14138f
Fixed removing string token.
richrd Mar 3, 2016
aca5a44
Dark status bars by default.
richrd Mar 3, 2016
4e56ac2
Fixed possibility of invoking find in the find promt itself recursively.
richrd Mar 3, 2016
a974921
Some tweaks to rendering separation.
richrd Mar 3, 2016
0ba2b80
Optimizations.
richrd Mar 3, 2016
6a32ee0
Cleanup.
richrd Mar 3, 2016
7664ca6
Quick Python 2.6 formatting fix.
richrd Mar 3, 2016
3a62ecd
Moved find commands to Viewer
richrd Mar 3, 2016
1f97386
Linting.
richrd Mar 4, 2016
eb44235
Optimized purging cursors and removed obsolete noupdate argument from…
richrd Mar 7, 2016
0723794
Removed unneccessary try/except from get_line_color.
richrd Mar 11, 2016
75681ef
Removed unneeded .keys() calls.
richrd Mar 11, 2016
7a13894
Removed redundant rendering from move_cursors().
richrd Mar 11, 2016
819fe6e
Minor logging tweaks.
richrd Mar 11, 2016
3ebe6e3
More sensible arrow_right implementation.
richrd Mar 13, 2016
014634e
Renamed modules.py to module_loader.py.
richrd Mar 13, 2016
3a17e57
Better implementation for config commands.
richrd Mar 13, 2016
1ef4cde
More scopes.
richrd Mar 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better string formatting.
  • Loading branch information
richrd committed Feb 28, 2016
commit c31737ee9731e7497eea3fa8747ca216940cb254
2 changes: 1 addition & 1 deletion suplemon/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def multisplit(data, delimiters):

def get_error_info():
"""Return info about last error."""
msg = str(traceback.format_exc()) + "\n" + str(sys.exc_info())
msg = "{0}\n{1}".format(str(traceback.format_exc()), str(sys.exc_info()))
return msg


Expand Down
10 changes: 5 additions & 5 deletions suplemon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def run_command(self, data):
self.logger.exception("Running command failed!")
return False
else:
self.set_status("Command '" + cmd + "' not found.")
self.set_status("Command '{0}' not found.".format(cmd))
return False
return True

Expand Down Expand Up @@ -560,7 +560,7 @@ def open(self):
return True

if not self.open_file(name):
self.set_status("Failed to load '" + name + "'")
self.set_status("Failed to load '{0}'".format(name))
return False
self.switch_to_file(self.last_file_index())
return True
Expand All @@ -583,11 +583,11 @@ def save_file(self, file=False):
if not f.get_name():
return self.save_file_as(f)
if f.save():
self.set_status("Saved [" + helpers.curr_time_sec() + "] '" + f.name + "'")
self.set_status("Saved [{0}] '{1}'".format(helpers.curr_time_sec(), f.name))
if f.path() == self.config.path():
self.reload_config()
return True
self.set_status("Couldn't write to '" + f.name + "'")
self.set_status("Couldn't write to '{0}'".format(f.name))
return False

def save_file_as(self, file=False):
Expand All @@ -601,7 +601,7 @@ def save_file_as(self, file=False):

def reload_file(self):
"""Reload the current file."""
if self.ui.query_bool("Reload '" + self.get_file().name + "'?"):
if self.ui.query_bool("Reload '{0}'?".format(self.get_file().name)):
if self.get_file().reload():
return True
return False
Expand Down
4 changes: 2 additions & 2 deletions suplemon/modules/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def value_str(self):
val = self.value()
if val:
if self.app.config["app"]["use_unicode_symbols"]:
return "\u26A1" + str(val) + "%"
return "\u26A1{0}%".format(str(val))
else:
return "BAT " + str(val) + "%"
return "BAT {0}%".format(str(val))
return ""

def get_status(self):
Expand Down
4 changes: 2 additions & 2 deletions suplemon/modules/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run(self, app, editor, args):
"""Run the linting command."""
editor = self.app.get_file().get_editor()
count = self.get_msg_count(editor)
status = str(count) + " lines with linting errors in this file."
status = "{0} lines with linting errors in this file.".format(str(count))
self.app.set_status(status)

def mainloop(self, event):
Expand All @@ -41,7 +41,7 @@ def mainloop(self, event):
line_no = cursor.y + 1
msg = self.get_msgs_on_line(editor, cursor.y)
if msg:
self.app.set_status("Line " + str(line_no) + ": " + msg)
self.app.set_status("Line {0}: {1}".format(str(line_no),msg))

def lint_current_file(self, event):
self.lint_file(self.app.get_file())
Expand Down
20 changes: 10 additions & 10 deletions suplemon/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ def show_top_status(self):
display = self.app.config["display"]
head_parts = []
if display["show_app_name"]:
name_str = "Suplemon Editor v" + self.app.version + " -"
name_str = "Suplemon Editor v{0} -".format(self.app.version)
if self.app.config["app"]["use_unicode_symbols"]:
logo = "\u2688" # Simple lemon (filled)
name_str = " " + logo + " " + name_str
name_str = " {0} {1}".format(logo, name_str)
head_parts.append(name_str)

# Add module statuses to the status bar
Expand Down Expand Up @@ -328,7 +328,7 @@ def file_list_str(self):
append += ["", is_changed_symbol][f.is_changed()]
fname = prepend + f.name + append
if not str_list:
str_list.append("[" + fname + "]")
str_list.append("[{0}]".format(fname))
else:
str_list.append(fname)
return " ".join(str_list)
Expand All @@ -338,15 +338,15 @@ def show_bottom_status(self):
editor = self.app.get_editor()
size = self.get_size()
cur = editor.get_cursor()
data = "@ " + str(cur[0]) + "," + str(cur[1]) + " " + \
"cur:" + str(len(editor.cursors)) + " " + \
"buf:" + str(len(editor.get_buffer()))
data = "@ {0},{1} cur:{2} buf:{3}".format(
str(cur[0]),
str(cur[1]),
str(len(editor.cursors)),
str(len(editor.get_buffer()))
)

if self.app.config["app"]["debug"]:
data += " cs:"+str(editor.current_state)+" hist:"+str(len(editor.history)) # Undo / Redo debug
# if editor.last_find:
# find = editor.last_find
# if len(find) > 10:find = find[:10]+"..."
# data = "find:'"+find+"' " + data

# Add module statuses to the status bar
for name in self.app.modules.modules.keys():
Expand Down