62 Commits

Author SHA1 Message Date
Allan Odgaard
caaa36161d Change most fprintf log statements to using os_log 2020-05-04 19:20:04 +07:00
Allan Odgaard
e4f61f12b7 Change a few leading spaces to tabs 2020-04-30 13:28:24 +07:00
Allan Odgaard
4013020b14 Use dot syntax for NSNumber’s boolValue property 2020-04-14 12:58:10 +07:00
Allan Odgaard
dae1103728 Update LINK declarations 2019-07-16 19:42:29 +02:00
Allan Odgaard
b5b36a558b Add missing framework dependencies 2019-06-26 13:21:11 +02:00
Allan Odgaard
db41b4b524 Add OakTheme: An Objective-C version of theme_t
This doesn’t do any caching of style lookups so performance is worse than theme_t and it also lacks an API to control the initial base font.

For now, the intention is to use this for system dialogs, such as the Find dialog, but long-term it should also be used by OakTextView, at which point, caching and base font support should be added.
2018-11-22 16:24:17 +07:00
Allan Odgaard
82de801d3e Add UUID for the macOS System Theme
Theme available here: e6e9185062
2018-11-22 16:24:17 +07:00
Allan Odgaard
1f97f479e7 Update CoreText constants to use “modern” names 2018-11-09 13:57:06 +07:00
Allan Odgaard
c288adf982 Add a constant for the Twilight theme UUID 2018-11-06 20:00:08 +07:00
Ronald Wampler
c0fb320549 Fix issues with redundant qualified names
Starting in Clang 5, lookup with nested-class names is stricter (e.g., A::A now specifically refers to the constructor name).
2017-06-23 13:24:04 -04:00
mathbunnyru
440414f96c Use nullptr in all C++ files instead of NULL
This brings us a bit of extra type safety, for example where an integer is expected, nullptr should be disallowed by the compiler (unlike NULL).
2016-10-22 21:40:14 +07:00
Allan Odgaard
e6ed50c107 Introduce kMacClassicThemeUUID since we reference it in multiple places 2016-09-26 11:09:32 +02:00
Allan Odgaard
2593550f9a Parse ‘strikethrough’ in fontStyle 2016-08-24 21:22:26 +02:00
Allan Odgaard
85a82d2bf8 Allow theme’s fontStyle to mix plain with bold, italic, and underline
If we set ‘plain bold’ then it means that italic and underline are explicitly disabled (should a more general theme rule enable them), but bold is left enabled.
2016-08-24 20:09:34 +02:00
Allan Odgaard
ef876499bd Use system’s default monospace font for theme_t 2016-07-05 12:13:06 +02:00
Allan Odgaard
417193e089 Update link dependencies for all targets
Some targets were including headers from frameworks not specified in their link dependencies. For a clean build this could cause an issue because the header was not available at the time of building the target.

The updated link dependencies are also based on what a target’s tests require. Ideally tests would have separate link dependencies, but as we don’t want to maintain this manually, this will have to wait until the build system automatically handles link dependencies.

Currently the commit command uses constants from the CommitWindow framework but should actually not be linked with it. However, the optimizer will strip dead code, so it should not result in much if any difference in the resulting binary and does solve a build dependency issue.
2016-05-07 13:00:55 +02:00
Allan Odgaard
f06f447ede Avoid referencing private types by using std::remove_pointer 2015-08-27 22:46:53 +02:00
Joachim Mårtensson
70893f4583 Use dense_hash_map for style cache 2015-05-09 21:24:38 +02:00
Allan Odgaard
40879d5683 Replace sizeofA macro with range-based for loop or std::begin/end 2015-03-05 16:38:09 +07:00
Allan Odgaard
1d3ccb157a Use a std::string instead of scope_t as cache key
Since we do a lot of lookups the faster operator< of std::string improves performance slightly.
2014-09-16 14:13:06 +02:00
Allan Odgaard
539dee1486 Gutter view colors would be leaked when reloading themes 2014-05-17 13:21:53 +07:00
Allan Odgaard
1f0e3db472 Remove trailing zeroes from numeric literals
I mainly dislike the trailing zeroes because CGFloat used to be a float but 1.0 is a double (1.0f would be a float). So better to under-specify and let the compiler figure out the proper type.
2014-04-14 14:26:52 +07:00
Allan Odgaard
39b94e6ac3 Harmonize whitespace and add trailing newline 2014-04-14 14:26:52 +07:00
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
7d91fd8322 Allow fractional font sizes.
Closes #1125
2013-12-14 12:10:05 +07:00
Allan Odgaard
ff14e818bc Add gutter_styles_t::is_transparent 2013-11-03 20:37:48 +01:00
Allan Odgaard
1d0428383f Parse theme colors using 8-bit notation (#RGB)
This is to improve interoperability, as some themes (not produced by TextMate 1.x’s theme editor) use this shorter notation.
2013-10-31 17:27:15 +01:00
Allan Odgaard
798961da6b Handle themes with invalid foreground/background color
Fixes #1179
2013-10-31 17:27:14 +01: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
efe617b4bc Update testing system for theme framework 2013-07-26 13:53:58 +02:00
Allan Odgaard
4bae908d49 Move CGColorRef helper functions
These only have one user, so let’s make them private helper functions instead.
2013-02-20 12:54:26 +01:00
Allan Odgaard
d70ccc7cdf Allow theme colors to use the sRGB color profile
This is enabled by adding the following to your theme:

    colorSpaceName = sRGB;

The default color space used for themes is “Apple Generic RGB” which is a bad choice for interoperability with other software (e.g. exporting a theme to CSS, creating theme colors in Photoshop, and similar).

Related to issue #768.
2013-02-18 15:38:27 +01:00
Allan Odgaard
08534e737f Change gutter colors to CGColorRef 2013-02-18 15:38:27 +01:00
Allan Odgaard
deeff330ee Change cf::color_t → CGColorRef
This change is required to introduce support for different color profiles.
2013-02-18 15:38:27 +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
Joachim Mårtensson
8de62bbc85 Don't mutate shared themes 2013-02-04 20:44:21 +01:00
Allan Odgaard
951fd53b30 Construct default theme from a dummy bundle item 2013-01-29 21:41:17 +01:00
Allan Odgaard
c8ab123aaf Move font name/size to theme_t
Since styles_for_scope effectively ignore the font parameters (and instead return styles based on the font parameters used when the cache entry was created) it is a better design to have theme_t own the font. This way, changing it can do the proper cache invalidation.

A minor downside is that we can now change the font of the theme without also changing the layout’s font, which wouldn’t cause proper layout invalidation — since layout_t owns theme_t though, users of a layout should always change font via layout_t (which will then change it in the theme).

Also, themes cannot be shared between views that wish to use different font settings.
2013-01-23 09:33:29 +01:00
Allan Odgaard
30c60ddc34 Accept scope_t instead of context_t
Since styles are applied to the actual content, we only have a single scope, not a left/right scope.
2013-01-23 08:19:39 +01:00
Joachim Mårtensson
2b51ca93bd Don’t use font name / size as key values in style cache
Font name and font size was being used in the cache key as a way to avoid having to do cache invalidation. This comes at a price of a 3X slow down. Instead clear the cache when font size/name changes. Excessive font name/size switching should be deterred IMO, why not with slowdowns? so no real downside. This does not affect themes setting font name/size, as they are handled by another mechanism.
2013-01-23 08:04:17 +01:00
Robert Hencke
7a9ff232fe Apply default gutter theme when no theme is active
Previously, if no themes were active, the gutter colors would
not be set.  This would, effectively, give you random gutter colors
on TextMate startup. (or, sometimes, a completely transparent gutter).
2012-10-24 21:07:21 +07:00
Allan Odgaard
b88ba4ff23 Extend theme_t’s public API 2012-09-10 22:47:57 +02:00
Allan Odgaard
7a67248dec No longer necessary to set all gutter colors
Previously all the colors were calculated so setting e.g. the icon color made it sort of necessary to also set the iconHover and iconPressed color.

Now the default icon hover and pressed colors are a potential user supplied icon color. Likewise, the default icon color is a potential user supplied foreground color, etc.
2012-09-08 01:02:47 +02:00
Allan Odgaard
aba449d171 Move gutter styles to own settings dictionary
This removes all the blending, the need to provide a scope selector to obtain them, and no longer taxes the general syntax highlight (by no longer having to carry around a dozen gutter styles per scope).
2012-09-08 00:40:08 +02:00
Dennis Vennink
f2f14dd48a Extended gutter theming support
The following four new keys have been added:

 - gutterIconsHover
 - gutterIconsPressed
 - gutterSelectionIconsHover
 - gutterSelectionIconsPressed
2012-09-07 21:21:35 +02:00
Allan Odgaard
8a7710e93e Use std::tuple instead of boost::tuple 2012-08-30 23:04:20 +02:00
Jacob Bandes-Storch
e3aa997b06 Use libc++: replace std::tr1 with std 2012-08-28 13:30:20 +02:00
Allan Odgaard
fc13d2021d Tweak gutter colors
Use the text foreground color for icons when the theme doesn’t provide a color and introduce ‘gutterSelectionIcons’ for the color of selected icons (defaults to selected foreground color).

Also changed the gutter selection border color to match the divider color (when it isn’t specified by the theme).
2012-08-26 18:52:25 +02:00
Dennis Vennink
6e02f55fff Add gutterSelectionBorder and gutterIcons theme keys 2012-08-26 18:26:34 +02:00