Skip to content

Commit 1f08cdc

Browse files
committed
installer: add wordpad as an editor choice
To propperly work as an editor for git we need to teach the existing wrapper script some new tricks. Thankfully we don't need to reinvent the wheel and can pick up the EOL handling from the notepad wrapper. We don't need to convert files to CRLF before passing files to wordpad, but when we get them back we need to convert them back to LF. While we're at it let's also pick up the commit message formating. Signed-off-by: Matthias Aßhauer <[email protected]>
1 parent ce03e45 commit 1f08cdc

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

git-extra/PKGBUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ sha256sums=('9efaf8dccc08c7cddc58cb589bab5aac5c0894661175a344ca02b2aa849382bd'
5858
'640d04d2a2da709419188a986d5e5550ad30df23c7ea9be1a389c37a6b917994'
5959
'17c90698d4dd52dd9f383e72aee54ecea0f62520baf56722de5c83285507c0d9'
6060
'3cd83627f1d20e1108533419fcf33c657cbcf777c3dc39fa7f13748b7d63858a'
61-
'a9ada325a279ce460aeb663a715e4c335d8972f497d48d97ff5524053b1fb43a'
61+
'c580bd3806d864d7e1446d08d881e80d6911d459e6f71fc7b62e9a189d8d1d31'
6262
'ad295ceb2c66aaf5fec85705110f701924eb6733b68663aaa52a90b950f03caa'
6363
'573ab22be9381feade4a4cdeb5e3d0761224e2e85e017be418c7004fb85fa8b5'
6464
'd212e1bbe75a9f81443126701324c9c44c3ed5750dd9822eba754a1799ed13b3'

git-extra/wordpad

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
#!/bin/sh
22

3+
die () {
4+
echo "$*" >&2
5+
exit 1
6+
}
7+
38
WORDPAD="$(ls {"$PROGRAMFILES/Windows NT","$SYSTEMROOT"}/*/wordpad.exe 2>&- | head -1)"
49

5-
test $# = 1 &&
10+
test $# = 1 ||
11+
die "Usage: $0 <file>"
12+
613
case "$1" in
714
\\*|/*|?:*) ;; # do nothing
815
*) set "$(pwd -W)/$1";;
916
esac
1017

11-
test -x "$WORDPAD" && exec "$WORDPAD" "$@"
18+
case "$1" in
19+
*/.git/*) ;; # needs LF line endings
20+
*) exec $WORDPAD "$1" || die "Could not launch $WORDPAD";;
21+
esac
1222

13-
echo "Could not launch $WORDPAD"
14-
exit 1
23+
$WORDPAD "$1" &&
24+
dos2unix.exe "$1" &&
25+
case "$1" in
26+
*/COMMIT_EDITMSG|*\\COMMIT_EDITMSG)
27+
! columns="$(git config format.commitmessagecolumns)" || {
28+
msg="$(fmt.exe -s -w "$columns" "$1" -p '#' | \
29+
fmt.exe -s -w "$columns" -)" &&
30+
printf "%s" "$msg" >"$1"
31+
}
32+
;;
33+
esac

installer/install.iss

+13-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ const
327327
GE_Atom = 6;
328328
GE_VSCodium = 7;
329329
GE_Notepad = 8;
330-
GE_CustomEditor = 9;
330+
GE_Wordpad = 9;
331+
GE_CustomEditor = 10;
331332
332333
// Git Path options.
333334
GP_BashOnly = 1;
@@ -1767,6 +1768,12 @@ begin
17671768
CreateItemDescription(EditorPage,'<RED>(NEW!)</RED> Notepad is a simple GUI editor that comes with windows.',Top,Left,LblEditor[GE_Notepad],False);
17681769
EditorAvailable[GE_Notepad]:=True;
17691770
1771+
// 9th choice
1772+
Top:=TopOfLabels;
1773+
CbbEditor.Items.Add('Use Wordpad as Git'+#39+'s default editor');
1774+
CreateItemDescription(EditorPage,'<RED>(NEW!)</RED> Wordpad is a basic word processor that comes with windows.'+#13+'It can also be used as a text editor.',Top,Left,LblEditor[GE_Wordpad],False);
1775+
EditorAvailable[GE_Wordpad]:=True;
1776+
17701777
// Custom choice
17711778
Top:=TopOfLabels;
17721779
CbbEditor.Items.Add('Select other editor as Git'+#39+'s default editor');
@@ -1828,6 +1835,7 @@ begin
18281835
CbbEditor.ItemIndex:=GE_VIM;
18291836
end;
18301837
'Notepad': CbbEditor.ItemIndex:=GE_Notepad;
1838+
'Wordpad': CbbEditor.ItemIndex:=GE_Wordpad;
18311839
'CustomEditor': begin
18321840
CbbEditor.ItemIndex:=GE_CustomEditor;
18331841
EditorPage.Values[0]:=ReplayChoice('Custom Editor Path','');
@@ -3020,6 +3028,8 @@ begin
30203028
LogError('Could not set VSCodium as core.editor in the gitconfig.')
30213029
end else if (CbbEditor.ItemIndex=GE_Notepad) then
30223030
GitSystemConfigSet('core.editor','notepad')
3031+
else if (CbbEditor.ItemIndex=GE_Wordpad) then
3032+
GitSystemConfigSet('core.editor','wordpad')
30233033
else if ((CbbEditor.ItemIndex=GE_CustomEditor)) and (PathIsValidExecutable(CustomEditorPath)) then
30243034
GitSystemConfigSet('core.editor','"'+CustomEditorPath+'" '+CustomEditorOptions);
30253035
@@ -3084,6 +3094,8 @@ begin
30843094
Data:='VSCodium';
30853095
end else if (CbbEditor.ItemIndex=GE_Notepad) then begin
30863096
Data:='Notepad';
3097+
end else if (CbbEditor.ItemIndex=GE_Wordpad) then begin
3098+
Data:='Wordpad';
30873099
end else if (CbbEditor.ItemIndex=GE_CustomEditor) then begin
30883100
Data:='CustomEditor'
30893101
CustomEditorData:=EditorPage.Values[0];

0 commit comments

Comments
 (0)