Commit Graph

50 Commits

Author SHA1 Message Date
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Allan Odgaard
0a21664f6d Replace iterate macro with new for loop (C++11)
Also use emplace_back a few places.
2013-12-14 13:12:45 +07:00
Allan Odgaard
45db36234c File path settings now rank higher than scope settings
A file setting like “src/*.cc” is arguably more specific (and thus more local) than targeting the scope “source.c++”, so it makes sense that the file settings rank higher than scope settings.

Some users also find it natural to target file extensions over scopes, but as TM will store some learned settings with a scope selector, it would previously lead to confusion, when a user was unable to e.g. change tab size for “*.php” (because TM had a learned setting for “source.php”).
2013-12-14 12:57:24 +07:00
Steven Clukey
bbe1ca357b Add “invisiblesMap” option to the .tm_properties file
This setting allows changing which invisibles are shown and what glyph
is used for them.

Invisibles are '\t', '\n', and ' ', to turn one off, add ~[\t \n] to
the settings string. To set the glyph used for the invisible, add [\t
\n][glyph_to_use].
2013-10-08 23:06:29 +02:00
Allan Odgaard
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
fc7f86d8eb Do not clear cache during normal lookup
We keep indirect references to cache lookups (for the duration of the function that use the cache) so we can only do cleanup at the start or end of the function which use the cache.
2013-08-28 15:27:42 +02:00
Allan Odgaard
ba85697ac4 Change “counterpart” to “related file”
This applies both to the action method and the settings key, the latter is now relatedFilePath to indicate that it’s a full absolute path (neither relative or a glob pattern).
2013-07-21 13:25:27 +02:00
Allan Odgaard
698f08ab35 Allow customizing what is used for ‘Go to File Counterpart’ (⌥⌘↑)
The user can now set ‘counterpart’ in .tm_properties to the absolute path of what should be used for ⌥⌘↑. If the file does not exist (on disk or as an open tab) then TextMate will fallback to searching the current folder for a file with same name.

To switch between go source and go test files one could add the following:

   [ *.go ]
   counterpart = "${TM_FILEPATH/(_test)?\.go$/${1:?:_test}.go/}"

Here the regular expression transformation will remove ‘_test’ from the file name if it exists, otherwise add it.

One could also do multiple settings like:

   [ *.go ]
   counterpart = "${TM_FILEPATH/(?=\.go$)/_test/}"

   [ *_test.go ]
   counterpart = "${TM_FILEPATH/_test(?=\.go$)//}"

Here ‘*.go’ files get the ‘_test’ added to their name, though files matched by the ‘*_test.go’ glob will instead have it removed.
2013-07-11 00:23:25 +02:00
Allan Odgaard
f5d28f2dd1 Let file chooser read ‘followSymbolicLinks’ from .tm_properties
Set this to ‘true’ if you want the file chooser (⌘T) to follow symbolic links.

The reason for making it a ‘.tm_properties’ setting is only because I am not yet sure how to best integrate this into the UI. The find dialog has an identical UI option which is global option — it would make sense to coalesce these two options, and while doing that, make the find dialog’s version a project/path setting rather than have it be global.

Closes #984.
2013-06-25 17:43:45 +02:00
Allan Odgaard
35ffdd5dd8 Don’t setup basic environment in ‘variables_for_path’
We expect the caller to pass us a properly setup environment.
2013-05-12 11:09:18 +07:00
Allan Odgaard
bf7d657eef Move some TM variables to oak::basic_environment 2013-05-12 11:09:18 +07:00
Allan Odgaard
ec9208afa9 Use whitelist feature to preserve dialog variables 2013-05-12 11:09:18 +07:00
Allan Odgaard
ce4ae62547 Change ‘variables_for_path’ API
We now accept the a directory in addition to the path. If a directory is provided, the path is only used to filter variables rooted at the directory.
2013-05-12 11:09:18 +07:00
Allan Odgaard
bd34c84253 Remove support for disabling file browser status updating
This preference was introduced as a workaround for poor performance when displaying large folders, this however should no longer be an issue.
2013-03-19 15:02:32 +01:00
Allan Odgaard
57c2aeda47 Use libdispatch for monitoring file changes
This is instead of using kqueue, which has more overhead and require a dedicated thread for the kevent run-loop.
2013-02-25 15:28:37 +01:00
Allan Odgaard
a3ec258912 Update settings tests to new system 2013-02-25 15:25:17 +01:00
Allan Odgaard
b718106ff8 Make semi-internal API private
This was previously public so that we could write tests for it, but since the test runner is linked with the object files, it can access symbols that has visibility set to hidden.
2013-02-23 11:24:56 +01:00
Allan Odgaard
873b9e8ced Introduce TM_PROPERTIES_PATH
This will be a colon-separated list of the .tm_properties files sourced for the current context. Mainly for debug purposes but could be used for an “Edit Properties…” command that show existing files (without having to scan the disk).
2013-02-15 15:27:56 +01:00
Allan Odgaard
9637ca051f Only set CWD for root section
The bracketed sections inherit from the root section, so there is no need to set this variable for each.
2013-02-15 15:27:56 +01:00
Allan Odgaard
b139ac5097 Change push_back → emplace_back (C++11)
This is mainly motivated by readability, so I only did a few select replacements.
2013-02-08 11:20:35 +01:00
Allan Odgaard
e75e7ec8e5 Change text::format → std::to_string (C++11) 2013-02-08 11:20:34 +01:00
Allan Odgaard
6cd18bafb0 Allow property sections to match folders
We generally lookup include/exclude patterns for a folder rather than a file, and here it makes sense to allow the bracketed sections of the property files to target the folder.

Since the sections are not ranked based on how good a match they are, targeting a subfolder, and then a subfolder of this subfolder, does not have which settings take precedence defined.
2013-01-28 21:01:12 +01:00
Allan Odgaard
54fe77ebdb Fix coding style 2013-01-28 20:37:33 +01:00
Allan Odgaard
f8fa69d8b4 Calling setting_t::set with NULL_STR restores the default 2013-01-25 11:01:56 +01:00
Allan Odgaard
fae30ed6e8 Use wrapper for getpwuid() to avoid crash
Based on crash logs this problem still exists on 10.8.2 <rdar://10261043>.
2013-01-10 23:48:46 +01:00
Josh Goebel
dc34d5c9d9 Allow disabling document status in file browser
Disabling this is achieved by setting `fileBrowserDocumentStatus` to `false` in `.tm_properties`.

Disabling it should remove potential delays after opening, closing, and saving files when file browser is showing a lot of files. It is meant as a temporary workaround until the performance issues are addressed.
2012-11-12 13:28:34 +07:00
Ole Gammelgaard Poulsen
ca25560f19 Added tm_query CLI that returns settings and variables for a file 2012-09-24 21:32:29 +02:00
Allan Odgaard
a45c2f6ea9 Improve “is scope selector” heuristic
A root scope can also be followed by a comma, e.g. “text, source”.
2012-09-16 18:00:35 +02:00
Allan Odgaard
923dab6375 Scoped properties are now applied last
This is so that a global setting for ‘source.ruby’ takes precedence over a local ‘source’ setting.

A minor downside is that a local properties file cannot use scoped settings outside a scope selector section.
2012-09-16 11:41:24 +02:00
Allan Odgaard
ba28b9e1ae Set TM_APP_IDENTIFIER
This is for bundles that need to read TextMate’s preferences file (should only be those using a nib with user defaults bindings for their preferences dialog).
2012-09-12 18:30:37 +02:00
Allan Odgaard
4f017345fc Add file/folder exclude keys for search and file chooser
This is just for completeness.
2012-09-12 18:30:36 +02:00
Allan Odgaard
b2fa6ff377 Remove UUID from settings API
Don’t recall what the intent was with this.
2012-09-11 00:05:05 +02:00
Allan Odgaard
c332ae69e6 Allow disabling SCM status from .tm_properties
This is done by adding the following (which can be limited to a folder):

    scmStatus = false
2012-09-02 17:53:50 +02:00
Jacob Bandes-Storch
d4ce498f60 Use 64-bit: numeric type fixes
Unfortunately a printf precision specifier (‘%.*s’) can not come with a width specifier so we have to cast to int. The width specifier ‘t’ is used for ptrdiff_t.
The int → NSInteger change fixed a bug with popup menu positioning, but there was no associated warning or error. It's possible there are more such bugs that we haven't found yet!
2012-08-28 21:32:47 +02:00
Allan Odgaard
15ba1374ca Add settings_t saving tests 2012-08-26 01:26:16 +02:00
Allan Odgaard
92b3c9e2c5 Remove hardcoded paths from settings_t
Mainly this is because when we run tests, we do not want global or default settings from TextMate, so now TextMate.app explicitly sets the path to the default and global settings (unlike when running tests).
2012-08-26 01:26:16 +02:00
Allan Odgaard
00ed4cab68 Improve flexibility in settings API
If we only provide key and value, we set the setting globally.

If we provide an additional file type, we set it for that file type and parent file types (i.e. “text” is parent of “text.plain”) plus globally. An exception is when we give an “attr” scope as file type (then we do not cascade upward).

If we provide a path / glob, we set it for that path / glob and, as file type we can provide NULL_STR to limit it to just that path / glob, the empty string ("") to also set it globally, or a file type (which is treated as above).
2012-08-25 14:54:47 +02:00
Allan Odgaard
629630c648 Proper escaping in section headers (tmProperties) 2012-08-25 14:54:46 +02:00
Allan Odgaard
68ec6f0d62 Don’t do upward cascading when storing ‘attr’ settings
Used in tmProperties this is to target untitled files, files with unknown encoding, and similar, so unlike text or source scopes, we do not want to set the option broader than the exact scope.
2012-08-25 02:06:04 +02:00
Allan Odgaard
5140dc730c Quote variables when writing Global.tmProperties
We also eliminate variables which have same value as in Default.tmProperties.
2012-08-25 02:06:04 +02:00
Allan Odgaard
a134b213eb Add settings_t::raw_get
This allows getting a variable from the global domain without any variable interpolation (for settings that use $variables or \escapes).

This is required to provide a UI for editing preferences values (here we want to edit the unexpanded value, and the version in the global domain).
2012-08-25 02:06:03 +02:00
Allan Odgaard
32be6b4800 Add kSettingsLineEndingsKey
Presently not used (by the loader/saver).
2012-08-25 00:57:48 +02:00
Allan Odgaard
0b3e361e54 Add code to save Global.tmProperties
Instead of storing things in user defaults we will store them in ~/Library/Application Support/TextMate/Global.tmProperties.

This just makes things a lot easier than having to mix NSUserDefaults with our .tm_properties files, especially since changing a setting in the UI should sometimes be global, sometimes be for the current file’s type, and sometimes just for the current document (e.g. spelling language).

These features are already available with the .tm_properties.
2012-08-24 16:57:32 +02:00
Allan Odgaard
f5c7301ba7 Use O_CLOEXEC when possible
This avoids having to do a fcntl(fd, F_SETFD, FD_CLOEXEC) to set the “close on exec” flag.
2012-08-24 16:52:42 +02:00
Allan Odgaard
3c79f275f1 Use constants for settings keys 2012-08-23 17:15:12 +02:00
Allan Odgaard
718ea40002 Use path::is_absolute instead of own logic 2012-08-13 22:54:09 +02:00
Allan Odgaard
b85aafb9a9 Crash when searching a bogus path
If we set projectDirectory to a non-path (e.g. ‘dummy’) then that value makes it into the default folder to search (on ⇧⌘F). Since we want folder specific settings for the path we are about to search (include/exclude patterns) then we would ask for settings for a non-path, which the settings framework couldn’t handle (it kept asking for the parent of this non-path expecting to eventually get to either the user’s home folder or the root of the disk, but instead it would loop infinitely).

This fixes issue #19.
2012-08-13 22:22:02 +02:00
Allan Odgaard
e680130eaf Move oak::basic_environment to the io framework
Previously this was under the OakSystem framework which depends on the io framework meaning that the io framework itself was unable to obtain a basic environment, which is necessary for next commit.
2012-08-11 19:31:10 +02:00
Allan Odgaard
9894969e67 Initial commit 2012-08-09 16:25:56 +02:00