Skip to content

Commit 8fd133b

Browse files
committed
0 parents  commit 8fd133b

10 files changed

+358
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Binaries

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SublimeTextSourceCodeAccess
2+
3+
Based on code from [fire/SensibleEditorSourceCodeAccess](https://github.com/fire/SensibleEditorSourceCodeAccess).
4+
5+
Clone this to your UnrealEngine directory at `Engine/Plugins/Developer` (symlinking doesn't work).

Resources/Icon128.png

12.4 KB
Loading
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* Copyright (c) 2014 K. Ernest 'iFire' Lee
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
21+
22+
#include "SublimeTextSourceCodeAccessPrivatePCH.h"
23+
#include "Runtime/Core/Public/Features/IModularFeatures.h"
24+
#include "SublimeTextSourceCodeAccessModule.h"
25+
26+
IMPLEMENT_MODULE( FSublimeTextSourceCodeAccessModule, SublimeTextSourceCodeAccess );
27+
28+
void FSublimeTextSourceCodeAccessModule::StartupModule()
29+
{
30+
// Bind our source control provider to the editor
31+
IModularFeatures::Get().RegisterModularFeature(TEXT("SourceCodeAccessor"), &SublimeTextSourceCodeAccessor);
32+
}
33+
34+
void FSublimeTextSourceCodeAccessModule::ShutdownModule()
35+
{
36+
// Unbind our source control provider from the editor
37+
IModularFeatures::Get().UnregisterModularFeature(TEXT("SourceCodeAccessor"), &SublimeTextSourceCodeAccessor);
38+
}
39+
40+
FSublimeTextSourceCodeAccessor& FSublimeTextSourceCodeAccessModule::GetAccessor()
41+
{
42+
return SublimeTextSourceCodeAccessor;
43+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* Copyright (c) 2014 K. Ernest 'iFire' Lee
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
21+
22+
#pragma once
23+
24+
#include "SublimeTextSourceCodeAccessor.h"
25+
26+
class FSublimeTextSourceCodeAccessModule : public IModuleInterface
27+
{
28+
public:
29+
/** IModuleInterface implementation */
30+
virtual void StartupModule() override;
31+
virtual void ShutdownModule() override;
32+
FSublimeTextSourceCodeAccessor& GetAccessor();
33+
34+
private:
35+
FSublimeTextSourceCodeAccessor SublimeTextSourceCodeAccessor;
36+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* Copyright (c) 2014 K. Ernest 'iFire' Lee
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
21+
22+
#pragma once
23+
24+
#include "Core.h"
25+
#include "ModuleManager.h"
26+
#include "ISourceCodeAccessModule.h"
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/* Copyright (c) 2014 K. Ernest 'iFire' Lee
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
21+
22+
#include "SublimeTextSourceCodeAccessPrivatePCH.h"
23+
#include "SublimeTextSourceCodeAccessor.h"
24+
#include "DesktopPlatformModule.h"
25+
26+
#define LOCTEXT_NAMESPACE "SublimeTextSourceCodeAccessor"
27+
28+
bool FSublimeTextSourceCodeAccessor::CanAccessSourceCode() const
29+
{
30+
return FPaths::FileExists(TEXT("/usr/bin/clang"));
31+
}
32+
33+
FName FSublimeTextSourceCodeAccessor::GetFName() const
34+
{
35+
return FName("SublimeTextSourceCodeAccessor");
36+
}
37+
38+
FText FSublimeTextSourceCodeAccessor::GetNameText() const
39+
{
40+
return LOCTEXT("SublimeTextDisplayName", "Sublime Text");
41+
}
42+
43+
FText FSublimeTextSourceCodeAccessor::GetDescriptionText() const
44+
{
45+
return LOCTEXT("SublimeTextDisplayDesc", "Open source code files with Sublime Text");
46+
}
47+
48+
bool FSublimeTextSourceCodeAccessor::OpenSolution()
49+
{
50+
FString FullPath;
51+
if ( FDesktopPlatformModule::Get()->GetSolutionPath(FullPath) )
52+
{
53+
if ( FPaths::FileExists(FullPath) )
54+
{
55+
// Add this to handle spaces in path names.
56+
const FString NewFullPath = FString::Printf(TEXT("\"%s\""), *FullPath);
57+
58+
FString Editor = FString(TEXT("/usr/bin/subl"));
59+
if ( FLinuxPlatformProcess::CreateProc(
60+
*Editor,
61+
*NewFullPath,
62+
true,
63+
true,
64+
false,
65+
nullptr,
66+
0,
67+
nullptr,
68+
nullptr
69+
).IsValid() )
70+
{
71+
return true;
72+
}
73+
}
74+
}
75+
76+
return false;
77+
}
78+
79+
bool FSublimeTextSourceCodeAccessor::OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber)
80+
{
81+
FString Editor = FString(TEXT("/usr/bin/subl"));
82+
83+
// Add this to handle spaces in path names.
84+
const FString NewFullPath = FString::Printf(TEXT("\"%s:%d:%d\""), *FullPath, LineNumber, ColumnNumber);
85+
86+
if ( FLinuxPlatformProcess::CreateProc(
87+
*Editor,
88+
*NewFullPath,
89+
true,
90+
true,
91+
false,
92+
nullptr,
93+
0,
94+
nullptr,
95+
nullptr
96+
).IsValid() )
97+
{
98+
return true;
99+
}
100+
101+
return false;
102+
}
103+
104+
bool FSublimeTextSourceCodeAccessor::OpenSourceFiles(const TArray<FString>& AbsoluteSourcePaths)
105+
{
106+
for ( const FString& SourcePath : AbsoluteSourcePaths )
107+
{
108+
FString Editor = FString(TEXT("/usr/bin/subl"));
109+
110+
// Add this to handle spaces in path names.
111+
const FString NewSourcePath = FString::Printf(TEXT("\"%s\""), *SourcePath);
112+
113+
if ( !(FLinuxPlatformProcess::CreateProc(
114+
*Editor,
115+
*NewSourcePath,
116+
true,
117+
true,
118+
false,
119+
nullptr,
120+
0,
121+
nullptr,
122+
nullptr
123+
).IsValid()) )
124+
{
125+
return false;
126+
}
127+
}
128+
129+
return true;
130+
}
131+
132+
bool FSublimeTextSourceCodeAccessor::AddSourceFiles(const TArray<FString>& AbsoluteSourcePaths, const TArray<FString>& AvailableModules)
133+
{
134+
return false;
135+
}
136+
137+
bool FSublimeTextSourceCodeAccessor::SaveAllOpenDocuments() const
138+
{
139+
return false;
140+
}
141+
142+
void FSublimeTextSourceCodeAccessor::Tick(const float DeltaTime)
143+
{
144+
145+
}
146+
147+
#undef LOCTEXT_NAMESPACE
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* Copyright (c) 2014 K. Ernest 'iFire' Lee
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
21+
22+
#pragma once
23+
24+
#include "ISourceCodeAccessor.h"
25+
26+
class FSublimeTextSourceCodeAccessor : public ISourceCodeAccessor
27+
{
28+
public:
29+
/** ISourceCodeAccessor implementation */
30+
virtual bool CanAccessSourceCode() const override;
31+
virtual FName GetFName() const override;
32+
virtual FText GetNameText() const override;
33+
virtual FText GetDescriptionText() const override;
34+
virtual bool OpenSolution() override;
35+
virtual bool OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber = 0) override;
36+
virtual bool OpenSourceFiles(const TArray<FString>& AbsoluteSourcePaths) override;
37+
virtual bool SaveAllOpenDocuments() const override;
38+
virtual bool AddSourceFiles(const TArray<FString>& AbsoluteSourcePaths, const TArray<FString>& AvailableModules) override;
39+
virtual void Tick(const float DeltaTime) override;
40+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* Copyright (c) 2014 K. Ernest 'iFire' Lee
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
21+
22+
namespace UnrealBuildTool.Rules
23+
{
24+
public class SublimeTextSourceCodeAccess : ModuleRules
25+
{
26+
public SublimeTextSourceCodeAccess(TargetInfo Target)
27+
{
28+
PrivateDependencyModuleNames.AddRange(
29+
new string[]
30+
{
31+
"Core",
32+
"DesktopPlatform",
33+
"SourceCodeAccess"
34+
}
35+
);
36+
}
37+
}
38+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"FileVersion" : 3,
3+
"FriendlyName" : "Sublime Text Source Code Access",
4+
"Version" : 1,
5+
"VersionName" : "1.0",
6+
"CreatedBy" : "Felix Laurie von Massenbach",
7+
"CreatedByURL" : "http://erbridge.co.uk/",
8+
"EngineVersion" : "4.7.3",
9+
"Description" : "Allows access to source code with Sublime Text.",
10+
"Category" : "Developer.Source Code Access",
11+
"EnabledByDefault" : true,
12+
13+
"Modules" :
14+
[
15+
{
16+
"Name" : "SublimeTextSourceCodeAccess",
17+
"Type" : "Developer",
18+
"WhitelistPlatforms" : [ "Linux" ],
19+
"LoadingPhase" : "PreDefault"
20+
}
21+
]
22+
}

0 commit comments

Comments
 (0)