-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_dnGREP.ps1
58 lines (49 loc) · 1.82 KB
/
import_dnGREP.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# convert dnGREP xml to mightygrep ini
$infile = $(Join-Path $(Get-Location) "dnGREP.Settings.dat")
$outfile = $(Join-Path $(Get-Location) "mightygrep.ini")
[xml]$global:xml = Get-Content -Path $infile
if (Test-Path $outfile) {
Clear-Content -Path $outfile
}
function WriteLine {
param ( $Line )
echo $Line
echo $Line | Out-File -FilePath $outfile -Append -Encoding utf8
}
function GetValue {
param( $key )
return $($global:xml.dictionary.item | Where-Object {$_.key -eq $key} | Select-Object -ExpandProperty '#text')
}
function WriteKey {
param( $cfg, $key )
WriteLine $($cfg + " = " + $(GetValue $key))
}
function WriteKeyArray {
param( $cfg, $key )
WriteLine $($cfg + " =")
$value = $($global:xml.dictionary.item | Where-Object {$_.key -eq $key})
foreach ($_ in $value.stringArray.string) {
$line = $($_ | Select-Object -ExpandProperty '#text')
if ($cfg -eq "filter_history") {
$line = $line.Replace(";", " ")
}
WriteLine $line
}
WriteLine ">`tLIST_END"
}
$hlm = GetValue "HighlightMatches"
$dhlm = if ($hlm -eq "False") { 1 } else { 0 }
WriteLine $("disable_match_coloring = " + $dhlm)
$cp = GetValue "CodePage"
if ($cp -eq "-1") { $cp = 65001 }
WriteLine $("codepage = " + $cp)
$editor = $(GetValue "CustomEditor") + " " + $(GetValue "CustomEditorArgs")
$editor = $editor.Replace("%file", '$filepath')
$editor = $editor.Replace("%line", '$line')
$editor = $editor.Replace("%column", '$column')
WriteLine $("ctrl_click_match_command = " + $editor)
WriteKey "font_face" "ResultsFontFamily"
WriteKey "font_size" "ResultsFontSize"
WriteKeyArray "directory_history" "FastPathBookmarks"
WriteKeyArray "filter_history" "FastFileMatchBookmarks"
WriteKeyArray "pattern_history" "FastSearchBookmarks"