I recommend the usage of Netbeans C/C++ IDE while working with source code. It provides much more flexible and functional development environment then Arduino IDE.
Setup process will be described on the basis of debian 9 OS.
First install Arduino IDE 1.8.2. Download from http://www.arduino.org/downloads or https://www.arduino.cc/en/Main/Software .
Then unpack and install to /opt:
$ sudo tar -xf arduino-1.8.2*.tar.xz -C /opt
$ cd /opt/arduino-1.8.2*
$ sudo ./install.sh
Then install Netbeans-8.2 C/C++. Download from https://netbeans.org/downloads/ .
Run installer with sudo:
$ sudo bash ./netbeans-8.2-cpp-linux*.sh
Chose install to /opt/netbeans/8.2.
Run installed netbeans, then open Options dialog by selecting "Tools"->"Options".
Choose C/C++ tab, then Build tools tab.
Add toolchain from the installed Arduino IDE, by pressing Add button:
.
Enter paths to the toolchain binaries as shown on the picture below:
.
Next, install the posixcpp library, arduino API level emulator is based on.
Download latest stable version from https://bitbucket.org/starling13/posixcpp/downloads/.
Unzip downloaded archive make and install the library:
$ tar -xf ./posixcpp-*.tar.gz
$ cd ./posixcpp*
$ ./configure
$ make
$ sudo make install
Install mercurial from the distribution repository.
Clone terminal-basic and libraries repositories in the sane directory:
https://bitbucket.org/starling13/terminal-basic
https://bitbucket.org/starling13/libarduino
https://bitbucket.org/starling13/libarduinoext
https://bitbucket.org/starling13/libarduinoemulator
https://bitbucket.org/starling13/tvoutex
https://bitbucket.org/starling13/libsdcard .
$ hg clone <repo address>
Setup is complete, time to code!
Open the main terminal-basic project in a netbeans. Right click on the project tree item and select Open required projects->Open all projects:
.
Choose appropriate configuration and build. Debug and Release configurations use libarduinoemulator to build the x86 version, which can be launched and debugged from netbeans IDE. Other configurations has the target program, which should be used to flash the uC.