Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MoveLinePlugin.c
Go to the documentation of this file.
1/*
2#ifdef WORKBENCH
3[WorkbenchPluginAttribute(name: "Move Line Up", shortcut: "Alt+Up", wbModules: { "ScriptEditor" }, category: "Move Line", awesomeFontCode: 0xF062)]
4class SCR_MoveLineUpPlugin : WorkbenchPlugin
5{
6 //------------------------------------------------------------------------------------------------
7 override void Run()
8 {
9 ScriptEditor scriptEditor = Workbench.GetModule(ScriptEditor);
10 int currentLineIndex = scriptEditor.GetCurrentLine();
11 if (currentLineIndex == 0)
12 return;
13
14 int aboveLineIndex = currentLineIndex - 1;
15
16 string aboveLine;
17 string currentLine;
18
19 scriptEditor.GetLineText(aboveLine, aboveLineIndex);
20 scriptEditor.GetLineText(currentLine, currentLineIndex);
21
22 SCR_MoveLineDownPluginHelper.IndentChange(aboveLine, currentLine);
23
24 scriptEditor.SetLineText(currentLine, aboveLineIndex);
25 scriptEditor.SetLineText(aboveLine, currentLineIndex);
26 }
27}
28
29[WorkbenchPluginAttribute(name: "Move Line Down", shortcut: "Alt+Down", wbModules: { "ScriptEditor" }, category: "Move Line", awesomeFontCode: 0xF063)]
30class SCR_MoveLineDownPlugin : WorkbenchPlugin
31{
32 //------------------------------------------------------------------------------------------------
33 override void Run()
34 {
35 ScriptEditor scriptEditor = Workbench.GetModule(ScriptEditor);
36 int currentLineIndex = scriptEditor.GetCurrentLine();
37 if (currentLineIndex == scriptEditor.GetLinesCount() - 1)
38 return;
39
40 int belowLineIndex = currentLineIndex + 1;
41
42 string currentLine;
43 string belowLine;
44
45 scriptEditor.GetLineText(currentLine, currentLineIndex);
46 scriptEditor.GetLineText(belowLine, belowLineIndex);
47
48 SCR_MoveLineDownPluginHelper.IndentChange(currentLine, belowLine);
49
50 scriptEditor.SetLineText(currentLine, belowLineIndex);
51 scriptEditor.SetLineText(belowLine, currentLineIndex);
52 }
53}
54
55class SCR_MoveLineDownPluginHelper
56{
57 //------------------------------------------------------------------------------------------------
61 static void IndentChange(inout string lineAbove, inout string lineBelow)
62 {
63// int tabsDiffAbove; // "above" and "below" are -before- change
64// int tabsDiffBelow;
65
66 string trimmedLine = lineAbove.Trim();
67
68 if (trimmedLine == "{" || trimmedLine.StartsWith("{ /" + "/") || trimmedLine.StartsWith("{\t/" + "/")) // think of arrays { 0, 0, 0 }
69 lineBelow = lineBelow.Substring(1, lineBelow.Length() - 1);
70 else
71 if (trimmedLine.StartsWith("}") && lineBelow != "\t" && lineBelow.StartsWith("\t"))
72 lineBelow = "\t" + lineBelow;
73
74 trimmedLine = lineBelow.Trim();
75
76 if (trimmedLine == "{" || trimmedLine.StartsWith("{ /" + "/") || trimmedLine.StartsWith("{\t/" + "/")) // think of arrays { 0, 0, 0 }
77 lineAbove = "\t" + lineAbove;
78 else
79 if (trimmedLine.StartsWith("}") && lineBelow != "\t" && lineAbove.StartsWith("\t"))
80 lineAbove = lineAbove.Substring(1, lineAbove.Length() - 1);
81 }
82}
83#endif // WORKBENCH
84*/