Skip to content

Commit

Permalink
Merge pull request #161 from ostueker/nano
Browse files Browse the repository at this point in the history
Add Nano editor
  • Loading branch information
dscho authored Nov 6, 2017
2 parents 58495ad + d52de2a commit 2415ef1
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 2 deletions.
164 changes: 164 additions & 0 deletions installer/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ begin
end;
const
// Git Editor options.
GE_VIM = 1;
GE_Nano = 2;
// Git Path options.
GP_BashOnly = 1;
GP_Cmd = 2;
Expand Down Expand Up @@ -339,6 +343,10 @@ var
// Previous Git for Windows version (if upgrading)
PreviousGitForWindowsVersion:String;
// Wizard page and variables for the Editor options.
EditorPage:TWizardPage;
RdbEditor:array[GE_VIM..GE_Nano] of TRadioButton;
// Wizard page and variables for the Path options.
PathPage:TWizardPage;
RdbPath:array[GP_BashOnly..GP_CmdTools] of TRadioButton;
Expand Down Expand Up @@ -745,6 +753,27 @@ begin
Result:=0;
end;
procedure OpenNanoHomepage(Sender:TObject);
var
ExitStatus:Integer;
begin
ShellExec('','https://www.nano-editor.org/dist/v2.8/nano.html','','',SW_SHOW,ewNoWait,ExitStatus);
end;
procedure OpenVIMHomepage(Sender:TObject);
var
ExitStatus:Integer;
begin
ShellExec('','http://www.vim.org/','','',SW_SHOW,ewNoWait,ExitStatus);
end;
procedure OpenExitVIMPost(Sender:TObject);
var
ExitStatus:Integer;
begin
ShellExec('','https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/','','',SW_SHOW,ewNoWait,ExitStatus);
end;
procedure OpenGCMHomepage(Sender:TObject);
var
ExitStatus:Integer;
Expand Down Expand Up @@ -794,6 +823,7 @@ end;
procedure InitializeWizard;
var
PrevPageID:Integer;
LblNano,LblNanoNew,LblNanoLink,lblVIM,lblVIMLink,lblExitVIMLink:TLabel;
LblGitBash,LblGitCmd,LblGitCmdTools,LblGitCmdToolsWarn:TLabel;
LblOpenSSH,LblPlink:TLabel;
LblCurlOpenSSL,LblCurlWinSSL:TLabel;
Expand All @@ -812,6 +842,122 @@ begin
PrevPageID:=wpSelectProgramGroup;
(*
* Create a custom page for configuring the default Git editor.
*)
EditorPage:=CreateCustomPage(
PrevPageID
, 'Choosing the default editor used by Git'
, 'Which editor would you like Git to use?'
);
PrevPageID:=EditorPage.ID;
// 1st choice
RdbEditor[GE_Nano]:=TRadioButton.Create(EditorPage);
with RdbEditor[GE_Nano] do begin
Parent:=EditorPage.Surface;
Caption:='Use the Nano editor by default';
Left:=ScaleX(4);
Top:=ScaleY(8);
Width:=ScaleX(405);
Height:=ScaleY(17);
Font.Style:=[fsBold];
TabOrder:=0;
end;
LblNano:=TLabel.Create(EditorPage);
with LblNano do begin
Parent:=EditorPage.Surface;
Caption:=
'(NEW!) GNU nano is a small and friendly text editor running in the console'+#13+'window. This is the recommended option.';
Left:=ScaleX(28);
Top:=ScaleY(32);
Width:=ScaleX(405);
Height:=ScaleY(26);
end;
LblNanoNew:=TLabel.Create(EditorPage);
with LblNanoNew do begin
Parent:=EditorPage.Surface;
Caption:='(NEW!)';
Left:=ScaleX(28);
Top:=ScaleY(32);
Width:=ScaleX(405);
Height:=ScaleY(13);
Font.Color:=clRed;
end;
LblNanoLink:=TLabel.Create(EditorPage);
with LblNanoLink do begin
Parent:=EditorPage.Surface;
Caption:='GNU nano';
Left:=GetTextWidth('(NEW!) ',LblNano.Font)+ScaleX(28);
Top:=ScaleY(32);
Width:=ScaleX(405);
Height:=ScaleY(13);
Font.Color:=clBlue;
Font.Style:=[fsUnderline];
Cursor:=crHand;
OnClick:=@OpenNanoHomepage;
end;
// 2nd choice
RdbEditor[GE_VIM]:=TRadioButton.Create(EditorPage);
with RdbEditor[GE_VIM] do begin
Parent:=EditorPage.Surface;
Caption:='Use Vim (the ubiquitous text editor) as Git'+#39+'s default editor';
Left:=ScaleX(4);
Top:=ScaleY(76);
Width:=ScaleX(405);
Height:=ScaleY(17);
Font.Style:=[fsBold];
TabOrder:=1;
Checked:=True;
end;
LblVIM:=TLabel.Create(EditorPage);
with LblVIM do begin
Parent:=EditorPage.Surface;
Caption:=
'The Vim editor, while powerful, can be hard to use. It is the default editor of'+#13+'Git for Windows only for historical reasons.';
Left:=ScaleX(28);
Top:=ScaleY(100);
Width:=ScaleX(405);
Height:=ScaleY(26);
end;
LblVIMLink:=TLabel.Create(EditorPage);
with LblVIMLink do begin
Parent:=EditorPage.Surface;
Caption:='Vim editor';
Left:=GetTextWidth('The ',LblVIM.Font)+ScaleX(28);
Top:=ScaleY(100);
Width:=ScaleX(405);
Height:=ScaleY(13);
Font.Color:=clBlue;
Font.Style:=[fsUnderline];
Cursor:=crHand;
OnClick:=@OpenVIMHomepage;
end;
LblExitVIMLink:=TLabel.Create(EditorPage);
with LblExitVIMLink do begin
Parent:=EditorPage.Surface;
Caption:='can be hard to use';
Left:=GetTextWidth('The Vim editor, while powerful, ',LblVIM.Font)+ScaleX(28);
Top:=ScaleY(100);
Width:=ScaleX(405);
Height:=ScaleY(13);
Font.Color:=clBlue;
Font.Style:=[fsUnderline];
Cursor:=crHand;
OnClick:=@OpenExitVIMPost;
end;
// Restore the setting chosen during a previous install.
Data:=ReplayChoice('Editor Option','VIM');
if Data='Nano' then begin
RdbEditor[GE_Nano].Checked:=True;
end else if Data='VIM' then begin
RdbEditor[GE_VIM].Checked:=True;
end;
(*
* Create a custom page for modifying the environment.
*)
Expand Down Expand Up @@ -2161,6 +2307,15 @@ begin
LogError('Line {#__LINE__}: Unable to delete "git-lfs.exe".');
end;
{
Set nano as default editor
}
if RdbEditor[GE_Nano].Checked then begin
if not Exec(AppDir + '\{#MINGW_BITNESS}\bin\git.exe','config --system core.editor nano.exe','',SW_HIDE,ewWaitUntilTerminated, i) then
LogError('Could not set nano as core.editor in the gitconfig.');
end;
{
Install a scheduled task to try to auto-update Git for Windows
}
Expand Down Expand Up @@ -2196,6 +2351,15 @@ procedure RegisterPreviousData(PreviousDataKey:Integer);
var
Data,Path:String;
begin
// Git Editor options.
Data:='';
if RdbEditor[GE_Nano].Checked then begin
Data:='Nano';
end else if RdbEditor[GE_VIM].Checked then begin
Data:='VIM';
end;
RecordChoice(PreviousDataKey,'Editor Option',Data);
// Git Path options.
Data:='';
if RdbPath[GP_BashOnly].Checked then begin
Expand Down
5 changes: 3 additions & 2 deletions make-file-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ for req in mingw-w64-$ARCH-git-credential-manager $SH_FOR_REBASE \
$(test -n "$MINIMAL_GIT" || echo \
mingw-w64-$ARCH-connect git-flow unzip docx2txt \
mingw-w64-$ARCH-antiword mingw-w64-$ARCH-odt2txt \
mingw-w64-$ARCH-xpdf ssh-pageant mingw-w64-$ARCH-git-lfs tig)
mingw-w64-$ARCH-xpdf ssh-pageant mingw-w64-$ARCH-git-lfs tig \
nano)
do
test -d /var/lib/pacman/local/$req-[0-9]* ||
test -d /var/lib/pacman/local/$req-git-[0-9]* ||
Expand All @@ -81,7 +82,7 @@ packages="mingw-w64-$ARCH-git mingw-w64-$ARCH-git-credential-manager
git-extra openssh $UTIL_PACKAGES"
if test -z "$MINIMAL_GIT"
then
packages="$packages mingw-w64-$ARCH-git-doc-html ncurses mintty vim
packages="$packages mingw-w64-$ARCH-git-doc-html ncurses mintty vim nano
winpty less gnupg tar diffutils patch dos2unix which subversion
mingw-w64-$ARCH-tk mingw-w64-$ARCH-connect git-flow docx2txt
mingw-w64-$ARCH-antiword mingw-w64-$ARCH-odt2txt ssh-pageant mingw-w64-$ARCH-git-lfs tig"
Expand Down

0 comments on commit 2415ef1

Please sign in to comment.