Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

When an unsaved file is compiled it will be saved now in the front end

too. (This behaviour can be changed using the compileUnsavedSave
setting)

Improved tooltips.
  • Loading branch information...
commit 1bb5d85be5afc37bfd47317b54828829dc4c40b4 1 parent 79314bb
Dominik Picheta dom96 authored
10 SettingsDoc.markdown
View
@@ -0,0 +1,10 @@
+## Settings documentation
+
+### compileUnsavedSave
+
+When an unsaved file is compiled, the file will be saved to /tmp/aporia. If this
+setting is ``False`` the tab holding the unsaved file will remain in the
+unsaved state. Otherwise the tab will transition into the saved state, but will
+be marked as temporary.
+
+**Default**: ``True``
31 aporia.nim
View
@@ -145,10 +145,16 @@ proc saveTab(tabNr: int, startpath: string, updateGUI: bool = true) =
win.Tabs[tabNr].saved = True
if updateGUI:
var name = extractFilename(path)
+ var tooltip = "<b>Path: </b> " & path & "\n" &
+ "<b>Language: </b> " & getLanguageName(win, tabNr)
- var cTab = win.Tabs[tabNr]
- cTab.label.setText(name)
- cTab.label.setTooltipText(path)
+ let cTab = win.Tabs[tabNr]
+ if cTab.isTemporary:
+ cTab.label.setMarkup(name & "<span color=\"#CC0E0E\"> *</span>")
+ tooltip.add("\n<i>File is saved in temporary files and may be deleted.</i>")
+ else:
+ cTab.label.setText(name)
+ cTab.label.setTooltipMarkup(tooltip)
updateMainTitle(tabNr)
if config:
@@ -320,7 +326,7 @@ proc cursorMoved(buffer: PTextBuffer, location: PTextIter,
mark: PTextMark, user_data: pgpointer){.cdecl.} =
var markName = mark.getName()
if markName == nil:
- return
+ return # We don't want anonymous marks.
if $markName == "insert" or $markName == "selection_bound":
updateStatusBar(buffer, $markName)
@@ -651,7 +657,13 @@ proc addTab(name, filename: string, setCurrent: bool = True, encoding = "utf-8")
nam = extractFilename(filename)
var (TabLabel, labelText, closeBtn) = createTabLabel(nam, scrollWindow)
- if filename != "": TabLabel.setTooltipText(filename)
+ if filename != "":
+ var tooltip = "<b>Path: </b> " & filename & "\n" &
+ "<b>Language: </b> " & getLanguageName(win, buffer)
+ if filename.startsWith(getTempDir()):
+ labelText.setMarkup(nam & "<span color=\"#CC0E0E\"> *</span>")
+ tooltip.add("\n<i>File is saved in temporary files and may be deleted.</i>")
+ TabLabel.setTooltipMarkup(tooltip)
# Add a tab
var nTab: Tab
nTab.buffer = buffer
@@ -1010,9 +1022,12 @@ proc saveForCompile(currentTab: int): string =
if not existsDir(getTempDir() / "aporia"): createDir(getTempDir() / "aporia")
result = getTempDir() / "aporia" / "a" & ($currentTab).addFileExt("nim")
win.Tabs[currentTab].filename = result
- saveTab(currentTab, os.splitFile(win.tabs[currentTab].filename).dir, false)
- win.Tabs[currentTab].filename = ""
- win.Tabs[currentTab].saved = false
+ if win.settings.compileUnsavedSave:
+ saveTab(currentTab, os.splitFile(win.tabs[currentTab].filename).dir, true)
+ else:
+ saveTab(currentTab, os.splitFile(win.tabs[currentTab].filename).dir, false)
+ win.Tabs[currentTab].filename = ""
+ win.Tabs[currentTab].saved = false
else:
saveTab(currentTab, os.splitFile(win.tabs[currentTab].filename).dir)
result = win.tabs[currentTab].filename
6 cfg.nim
View
@@ -35,7 +35,8 @@ proc defaultSettings*(): TSettings =
result.recentlyOpenedFiles = @[]
result.singleInstancePort = 55679
result.showCloseOnAllTabs = false
-
+ result.compileUnsavedSave = true
+
proc writeSection(f: TFile, sectionName: string) =
f.write("[")
f.write(sectionName)
@@ -93,6 +94,7 @@ proc save*(win: var MainWin) =
f.writeKeyVal("selectHighlightAll", $settings.selectHighlightAll)
f.writeKeyVal("searchHighlightAll", $settings.searchHighlightAll)
f.writeKeyVal("singleInstancePort", $int(settings.singleInstancePort))
+ f.writeKeyVal("compileUnsavedSave", $settings.compileUnsavedSave)
f.writeSection("auto")
f.write("; Stuff which is saved automatically," &
@@ -190,6 +192,8 @@ proc load*(input: PStream, lastSession: var seq[string]): TSettings =
result.recentlyOpenedFiles.add(file)
of "lastselectedtab":
result.lastSelectedTab = e.value
+ of "compileunsavedsave":
+ result.compileUnsavedSave = isTrue(e.value)
else:
raise newException(ECFGParse, "Key \"" & e.key & "\" is invalid.")
of cfgError:
4 todo.markdown
View
@@ -7,7 +7,6 @@
* Search & Replace, when clicking replace and a lot of text is scrolled no syntax highlighting occurs.
* Sort View -> Syntax Highlighting
* Fix docs in suggest.
-* Temporary file saves.
* keywords.txt -> nimrod.lang
* Output text view limit. OOMed my system because of a lot of output already.
* Go to definition: if forward declarations are present, go to definition should go to the definition not forward declaration.
@@ -15,6 +14,7 @@
* Gdk-CRITICAL **: gdk_window_invalidate_rect_full: assertion `GDK_IS_WINDOW (window)' failed
* Caused by a GtkSourceView from a tab other than the current one being focused.
* Use the same strategy as scrolling for making sure that the selected tab gets focused.
+* Search for ⌚, it selects too much with regex.
## Other language features
* Ability to change to hard tabs.
@@ -50,8 +50,6 @@
* Fix VPaned after that change to win.show().
* docking with http://developer.gnome.org/gdl/
* minimum mode -- look at screenshots dir
-* When compiling an unsaved file, make it saved on the frontend.
- So that when i'm editing it further I can press Ctrl + S without getting angry.
* If search term is misspelled, try to find something close to it and color
the textbox orange but do go to it.
* Ctrl+Shift up/down should move the current line up or down.
24 utils.nim
View
@@ -38,6 +38,7 @@ type
toolBarVisible*: bool # Whether the top panel is shown
bottomPanelVisible*: bool # Whether the bottom panel is shown
suggestFeature*: bool # Whether the suggest feature is enabled
+ compileUnsavedSave*: bool # Whether compiling unsaved files will make them appear saved in the front end.
nimrodCmd*: string # command template to use to exec the Nimrod compiler
customCmd1*: string # command template to use to exec a custom command
@@ -386,22 +387,26 @@ proc getCurrentLanguage*(win: var MainWin, pageNum: int = -1): string =
else:
return ""
-proc getLanguageName*(win: var MainWin, pageNum: int = -1): string =
- ## Returns the language name of the ``pageNum`` tab.
+proc getLanguageName*(win: var MainWin, buffer: PSourceBuffer): string =
+ ## Returns the language name of ``buffer``.
##
## If there is no syntax highlighting for the current tab ``"Plain Text"`` is
## returned.
- var currentPage = pageNum
- if currentPage == -1:
- currentPage = win.getCurrentTab()
- var isHighlighted = win.Tabs[currentPage].buffer.getHighlightSyntax()
+ var isHighlighted = buffer.getHighlightSyntax()
if isHighlighted:
- var SourceLanguage = win.Tabs[currentPage].buffer.getLanguage()
+ var SourceLanguage = buffer.getLanguage()
if SourceLanguage == nil: return "Plain Text"
return $sourceLanguage.getName()
else:
return "Plain Text"
+proc getLanguageName*(win: var MainWin, pageNum: int = -1): string =
+ ## Returns the language name of the ``pageNum`` tab.
+ var currentPage = pageNum
+ if currentPage == -1:
+ currentPage = win.getCurrentTab()
+ return getLanguageName(win, win.Tabs[currentPage].buffer)
+
proc getCurrentLanguageComment*(win: var MainWin,
syntax: var tuple[line, blockStart, blockEnd: string], pageNum: int) =
## Gets the current line comment string and block comment string.
@@ -448,3 +453,8 @@ proc findProjectFile*(directory: string): tuple[projectFile, projectCfg: string]
if not existsFile(projectFile & "rod"):
projectFile = ""
return (projectFile, projectCfgFile)
+
+proc isTemporary*(t: Tab): bool =
+ ## Determines whether ``t`` is saved in /tmp
+ return t.filename.startsWith(getTempDir())
+
Please sign in to comment.
Something went wrong with that request. Please try again.