SUMMARY="An experimental Qt gui for Vim"
DESCRIPTION="Vim is a highly configurable text editor built to enable \
efficient text editing. It is an improved version of the vi editor \
distributed with most UNIX systems.

Vim is often called a \"programmer's editor,\" and so useful for programming \
that many consider it an entire IDE. It's not just for programmers, though. \
Vim is perfect for all kinds of text editing, from composing email to editing \
configuration files.
Despite this, Vim can be configured to work in a very simple (Notepad-like) \
way, called evim or Easy Vim."
HOMEPAGE="https://github.com/equalsraf/vim-qt/"
COPYRIGHT="1991-2017 Bram Moleenar et al."
LICENSE="Vim"
REVISION="2"
srcGitRev="162b3f3ae0fbe8d4a8e33a24f347e5daa4dd9826"
SOURCE_URI="https://github.com/equalsraf/vim-qt/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="347ba160b86d5263cb0952358fb29ccf5636cdc9d90aa110bedd6a4277c11280"
SOURCE_DIR="vim-qt-$srcGitRev"
PATCHES="qvim-$portVersion.patchset"
ADDITIONAL_FILES="qvim.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	qvim$secondaryArchSuffix = $portVersion
	cmd:ex$secondaryArchSuffix = $portVersion
	cmd:gqvimtutor$secondaryArchSuffix = $portVersion
	cmd:qvim$secondaryArchSuffix = $portVersion
	cmd:qvimdiff$secondaryArchSuffix = $portVersion
	cmd:qvimtutor$secondaryArchSuffix = $portVersion
	cmd:rqvim$secondaryArchSuffix = $portVersion
	cmd:rview$secondaryArchSuffix = $portVersion
	cmd:view$secondaryArchSuffix = $portVersion
	cmd:xxd$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

BUILD()
{

	cd src
	runConfigure ./configure \
			--with-features=huge \
			--with-vim-name=qvim \
			--enable-gui=qt

	make $jobArgs
}

INSTALL()
{
	make install

	# Make arrow keys, backspace, delete, etc behave as expected.
	echo "set nocompatible" >> $dataDir/vim/vimrc

	# Workaround to get the themes and plugins work
	echo "set runtimepath+=`finddir B_USER_SETTINGS_DIRECTORY`/vim" >> $dataDir/vim/vimrc


	local APP_SIGNATURE="application/x-vnd.Qt5-Vim-8"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/qvim.rdef.in > qvim.rdef

	addResourcesToBinaries qvim.rdef $binDir/qvim
	addAppDeskbarSymlink $binDir/qvim QVim
}

TEST()
{
	cd src
	make check
}
