mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
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
70 lines
2.3 KiB
C++
70 lines
2.3 KiB
C++
#ifndef COCOA_P0XQO9KO
|
|
#define COCOA_P0XQO9KO
|
|
|
|
#include <text/tokenize.h>
|
|
#include <oak/oak.h>
|
|
|
|
static BOOL IsGUITestsEnabled (std::string const& testName)
|
|
{
|
|
std::set<std::string> tests;
|
|
std::string envVar = getenv("GUI_TESTS") ?: "";
|
|
for(auto const& test : text::tokenize(envVar.begin(), envVar.end(), ' '))
|
|
tests.insert(test);
|
|
|
|
return tests.find("all") != tests.end() || tests.find(testName) != tests.end();
|
|
}
|
|
|
|
static void OakSetupApplicationWithView (NSResponder* aView, std::string testName = NULL_STR)
|
|
{
|
|
if(testName == NULL_STR)
|
|
{
|
|
testName = [[[NSProcessInfo processInfo] processName] UTF8String];
|
|
if(testName.find("cxx_test_") == 0)
|
|
testName = testName.substr(strlen("cxx_test_"));
|
|
}
|
|
|
|
if(!IsGUITestsEnabled(testName))
|
|
return;
|
|
|
|
[NSApplication sharedApplication];
|
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
[NSApp activateIgnoringOtherApps:YES];
|
|
|
|
NSString* appName = [[NSProcessInfo processInfo] processName];
|
|
appName = [[[appName componentsSeparatedByString:@"_"] componentsJoinedByString:@" "] capitalizedString];
|
|
|
|
NSMenu* appMenu = [NSMenu new];
|
|
[appMenu addItem:[[NSMenuItem alloc] initWithTitle:[@"Quit " stringByAppendingString:appName] action:@selector(terminate:) keyEquivalent:@"q"]];
|
|
|
|
NSMenuItem* appMenuItem = [NSMenuItem new];
|
|
[appMenuItem setSubmenu:appMenu];
|
|
|
|
NSMenu* mainMenu = [NSMenu new];
|
|
[mainMenu addItem:appMenuItem];
|
|
[NSApp setMainMenu:mainMenu];
|
|
|
|
NSWindow* window = nil;
|
|
if([aView isKindOfClass:[NSWindow class]])
|
|
{
|
|
window = (NSWindow*)aView;
|
|
}
|
|
else if([aView isKindOfClass:[NSView class]])
|
|
{
|
|
NSView* view = (NSView*)aView;
|
|
NSRect winRect = [NSWindow frameRectForContentRect:NSInsetRect([view bounds], -10, -10) styleMask:NSTitledWindowMask|NSResizableWindowMask];
|
|
window = [[NSWindow alloc] initWithContentRect:winRect styleMask:NSTitledWindowMask|NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO];
|
|
[view setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
|
|
[view setFrame:NSInsetRect([[window contentView] bounds], 10, 10)];
|
|
[[window contentView] addSubview:view];
|
|
}
|
|
|
|
[window cascadeTopLeftFromPoint:NSMakePoint(20, 20)];
|
|
[window setTitle:appName];
|
|
[window setFrameAutosaveName:@"Main Window"];
|
|
[window makeKeyAndOrderFront:nil];
|
|
|
|
[NSApp run];
|
|
}
|
|
|
|
#endif /* end of include guard: COCOA_P0XQO9KO */
|