diff --git a/.gitmodules b/.gitmodules index da58f90..2428fa6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "libclangmm"] path = libclangmm - url = https://github.com/cppit/libclangmm/tree/v0.9.3 + url = https://github.com/cppit/libclangmm.git + branch = v0.9.3 diff --git a/MINGW-packages/mingw-w64-gtksourceview3/0006-hack-convert-path-back-to-unix.patch b/MINGW-packages/mingw-w64-gtksourceview3/0006-hack-convert-path-back-to-unix.patch deleted file mode 100644 index 68f217f..0000000 --- a/MINGW-packages/mingw-w64-gtksourceview3/0006-hack-convert-path-back-to-unix.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- gtksourceview-3.13.90/configure.ac.orig 2014-08-22 00:42:28.532000000 +0400 -+++ gtksourceview-3.13.90/configure.ac 2014-08-22 00:43:00.621200000 +0400 -@@ -133,6 +133,12 @@ - AC_MSG_RESULT([$GLADE_CATALOG_DIR]) - AC_SUBST(GLADE_CATALOG_DIR)]) - -+case "$host" in -+ *-*-mingw*) -+ GLADE_CATALOG_DIR=`cygpath -u $GLADE_CATALOG_DIR` -+ ;; -+esac -+ - # i18N stuff - IT_PROG_INTLTOOL([0.40]) - AS_IF([test "$USE_NLS" = "yes"], diff --git a/MINGW-packages/mingw-w64-gtksourceview3/LICENSE b/MINGW-packages/mingw-w64-gtksourceview3/LICENSE deleted file mode 100644 index e0f07ba..0000000 --- a/MINGW-packages/mingw-w64-gtksourceview3/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013, Алексей -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -* Neither the name of the {organization} nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MINGW-packages/mingw-w64-gtksourceview3/PKGBUILD b/MINGW-packages/mingw-w64-gtksourceview3/PKGBUILD deleted file mode 100644 index 038333a..0000000 --- a/MINGW-packages/mingw-w64-gtksourceview3/PKGBUILD +++ /dev/null @@ -1,64 +0,0 @@ -# Maintainer: Alexey Pavlov - -_realname=gtksourceview -pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}3" -pkgver=3.12.0 -pkgrel=2 -pkgdesc="A text widget adding syntax highlighting and more to GNOME (mingw-w64)" -arch=('any') -url="http://www.gnome.org" -license=("LGPL") -makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" - "${MINGW_PACKAGE_PREFIX}-pkg-config" - "${MINGW_PACKAGE_PREFIX}-gobject-introspection" - "${MINGW_PACKAGE_PREFIX}-glade" - "${MINGW_PACKAGE_PREFIX}-vala" - "intltool" - "gtk-doc") -depends=("${MINGW_PACKAGE_PREFIX}-gtk3" - "${MINGW_PACKAGE_PREFIX}-libxml2") -options=(!libtool strip staticlibs) -source=("http://ftp.gnome.org/pub/gnome/sources/gtksourceview/${pkgver%.*}/gtksourceview-${pkgver}.tar.xz" - 0006-hack-convert-path-back-to-unix.patch) -md5sums=('8850fc0aee4893668ede37a30ef05e85' - '324c9e3bb2e4fa2a4977653ce6ed6ef9') - -prepare() { - cd ${_realname}-${pkgver} - patch -p1 -i ${srcdir}/0006-hack-convert-path-back-to-unix.patch - - autoreconf -fi -} - -build() { - mkdir -p "${srcdir}/build-${MINGW_CHOST}" - cd "${srcdir}/build-${MINGW_CHOST}" - - mkdir -p docs/reference/html - cp -rf ../${_realname}-${pkgver}/docs/reference/html/* docs/reference/html - - DATADIRNAME=share \ - ../${_realname}-${pkgver}/configure \ - --prefix=${MINGW_PREFIX} \ - --build=${MINGW_CHOST} \ - --host=${MINGW_CHOST} \ - --enable-shared \ - --disable-static \ - --enable-glade-catalog - - LC_ALL=C make -} - -package() { - cd "${srcdir}/build-${MINGW_CHOST}" - make -j1 DESTDIR="${pkgdir}" install - - for ff in ${pkgdir}/${MINGW_PREFIX}/bin/libgtksourceview*.dll; do - local _reallib=$(basename $ff) - _reallib=${_reallib%.dll} - _reallib=${_reallib#lib} - sed -e "s|library=\"gtksourceview-3.0\"|library=\"${_reallib}\"|g" -i ${pkgdir}/${MINGW_PREFIX}/share/glade/catalogs/gtksourceview.xml - done - - install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING" -} diff --git a/MINGW-packages/mingw-w64-gtksourceviewmm3/LICENSE b/MINGW-packages/mingw-w64-gtksourceviewmm3/LICENSE deleted file mode 100644 index e0f07ba..0000000 --- a/MINGW-packages/mingw-w64-gtksourceviewmm3/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013, Алексей -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -* Neither the name of the {organization} nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MINGW-packages/mingw-w64-gtksourceviewmm3/PKGBUILD b/MINGW-packages/mingw-w64-gtksourceviewmm3/PKGBUILD deleted file mode 100644 index 0d842a8..0000000 --- a/MINGW-packages/mingw-w64-gtksourceviewmm3/PKGBUILD +++ /dev/null @@ -1,33 +0,0 @@ -_realname=gtksourceviewmm3 -pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" -pkgver=3.12.0 -pkgrel=1 -pkgdesc="C++ bindings for gtksourceview3 (mingw-w64)" -arch=('any') -url="https://developer.gnome.org/gtksourceviewmm/" -license=("LGPL") -makedepends=("patch" "${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config") -depends=("${MINGW_PACKAGE_PREFIX}-gtksourceview3=${pkgver}") -options=('staticlibs' 'strip') -source=("https://download.gnome.org/sources/gtksourceviewmm/${pkgver%.*}/gtksourceviewmm-${pkgver}.tar.xz") -sha256sums=("73939031bcc60e6ad31a315ec84b132deba15e5732de16e75fe424a619267ace") - -build() { - mkdir -p "${srcdir}/build-${MINGW_CHOST}" - cd "${srcdir}/build-${MINGW_CHOST}" - ../gtksourceviewmm-${pkgver}/configure \ - CXXFLAGS=-std=c++11 \ - --prefix=${MINGW_PREFIX} \ - --build=${MINGW_CHOST} \ - --host=${MINGW_CHOST} \ - --enable-shared \ - --enable-static \ - --disable-documentation - make -} - -package() { - cd "${srcdir}/build-${MINGW_CHOST}" - make DESTDIR="${pkgdir}" install - find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm -} \ No newline at end of file diff --git a/README.md b/README.md index b769f72..d36d1d2 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ towards libclang with speed and ease of use in mind. * Run shell commands within JuCi++, even on Windows * Regex search and replace * Smart paste, keys and indentation +* Auto-indentation of C++ file buffers through [clang-format](http://clang.llvm.org/docs/ClangFormat.html) * Source minimap * Full UTF-8 support diff --git a/docs/install.md b/docs/install.md index 5877e17..95bcaa0 100644 --- a/docs/install.md +++ b/docs/install.md @@ -15,6 +15,12 @@ make sudo make install ``` +To use clang-format for auto-indentation of C++ files (replace \[version\] with an available clang-format version): +```sh +sudo apt-get install clang-format-[version] +sudo ln -s /usr/bin/clang-format-[version] /usr/local/bin/clang-format +``` + ## Ubuntu 14/Linux Mint 17 Install dependencies: ```sh @@ -34,10 +40,16 @@ make sudo make install ``` +To use clang-format for auto-indentation of C++ files (replace \[version\] with an available clang-format version): +```sh +sudo apt-get install clang-format-[version] +sudo ln -s /usr/bin/clang-format-[version] /usr/local/bin/clang-format +``` + ## OS X with Homebrew (http://brew.sh/) Install dependencies (installing llvm may take some time): ```sh -brew install cmake --with-clang llvm pkg-config boost gtkmm3 homebrew/x11/gtksourceviewmm3 aspell +brew install cmake --with-clang llvm pkg-config boost gtkmm3 homebrew/x11/gtksourceviewmm3 aspell clang-format ``` Get juCi++ source, compile and install: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6448e52..3d246e2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,6 +10,17 @@ if(APPLE) set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig") endif() +if(UNIX) #Checking if compiling on Ubuntu that has a buggy menu system + find_program(LSB_RELEASE_BIN lsb_release) + if(LSB_RELEASE_BIN) + execute_process(COMMAND ${LSB_RELEASE_BIN} -is + OUTPUT_VARIABLE DISTRIBUTION OUTPUT_STRIP_TRAILING_WHITESPACE) + if(DISTRIBUTION STREQUAL Ubuntu) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUBUNTU_BUGGED_MENU") + endif() + endif() +endif() + INCLUDE(FindPkgConfig) find_package(LibClang REQUIRED) diff --git a/src/config.cc b/src/config.cc index c05e382..a50ade1 100644 --- a/src/config.cc +++ b/src/config.cc @@ -8,28 +8,23 @@ using namespace std; //TODO: remove MainConfig::MainConfig() { - auto search_envs = init_home_path(); + init_home_path(); +} + +void MainConfig::read() { auto config_json = (home/"config"/"config.json").string(); // This causes some redundant copies, but assures windows support try { find_or_create_config_files(); - if(home.empty()) { - std::string searched_envs = "["; - for(auto &env : search_envs) - searched_envs+=env+", "; - searched_envs.erase(searched_envs.end()-2, searched_envs.end()); - searched_envs+="]"; - throw std::runtime_error("One of these environment variables needs to point to a writable directory to save configuration: " + searched_envs); - } boost::property_tree::json_parser::read_json(config_json, cfg); update_config_file(); retrieve_config(); } catch(const std::exception &e) { + Singleton::terminal()->print("Error reading "+config_json + "config.json: "+e.what()+"\n"); std::stringstream ss; ss << configjson; boost::property_tree::read_json(ss, cfg); retrieve_config(); - JERROR("Error reading "+ config_json + ": "+e.what()+"\n"); // logs will print to cerr when init_log haven't been run yet } cfg.clear(); } @@ -63,7 +58,10 @@ void MainConfig::find_or_create_config_files() { } void MainConfig::retrieve_config() { - Singleton::Config::window()->keybindings = cfg.get_child("keybindings"); + auto keybindings_pt = cfg.get_child("keybindings"); + for (auto &i : keybindings_pt) { + Singleton::Config::menu()->keys[i.first] = i.second.get_value(); + } GenerateSource(); GenerateDirectoryFilter(); @@ -146,7 +144,9 @@ void MainConfig::GenerateSource() { for (auto &i : source_json.get_child("clang_types")) source_cfg->clang_types[i.first] = i.second.get_value(); - + + source_cfg->clang_format_style = source_json.get("clang_format_style"); + auto pt_doc_search=cfg.get_child("documentation_searches"); for(auto &pt_doc_search_lang: pt_doc_search) { source_cfg->documentation_searches[pt_doc_search_lang.first].separator=pt_doc_search_lang.second.get("separator"); @@ -167,7 +167,8 @@ void MainConfig::GenerateDirectoryFilter() { for ( auto &i : ignore_json ) dir_cfg->ignored.emplace_back(i.second.get_value()); } -std::vector MainConfig::init_home_path(){ + +void MainConfig::init_home_path(){ std::vector locations = JUCI_ENV_SEARCH_LOCATIONS; char *ptr = nullptr; for (auto &env : locations) { @@ -178,9 +179,17 @@ std::vector MainConfig::init_home_path(){ if (boost::filesystem::exists(ptr)) { home /= ptr; home /= ".juci"; - return locations; + break; } } - home=""; - return locations; + + if(home.empty()) { + std::string searched_envs = "["; + for(auto &env : locations) + searched_envs+=env+", "; + searched_envs.erase(searched_envs.end()-2, searched_envs.end()); + searched_envs+="]"; + throw std::runtime_error("One of these environment variables needs to point to a writable directory to save configuration: " + searched_envs); + } + return; } diff --git a/src/config.h b/src/config.h index c84ded6..99ffa90 100644 --- a/src/config.h +++ b/src/config.h @@ -7,6 +7,7 @@ class MainConfig { public: MainConfig(); + void read(); const boost::filesystem::path& juci_home_path() const { return home; } private: @@ -18,7 +19,7 @@ private: void GenerateSource(); void GenerateDirectoryFilter(); - std::vector init_home_path(); + void init_home_path(); boost::property_tree::ptree cfg; boost::filesystem::path home; }; diff --git a/src/dialogs.cc b/src/dialogs.cc index 56fb0c9..a2b9066 100644 --- a/src/dialogs.cc +++ b/src/dialogs.cc @@ -40,7 +40,7 @@ std::string Dialog::new_folder() { } std::string Dialog::select_file() { - return open_dialog("Please choose a folder", + return open_dialog("Please choose a file", {std::make_pair("Cancel", Gtk::RESPONSE_CANCEL),std::make_pair("Select", Gtk::RESPONSE_OK)}, Gtk::FILE_CHOOSER_ACTION_OPEN); } diff --git a/src/files.h b/src/files.h index 39c7cc8..eee5f0d 100644 --- a/src/files.h +++ b/src/files.h @@ -1,6 +1,6 @@ #include -#define JUCI_VERSION "0.9.3" +#define JUCI_VERSION "0.9.4" #define JUCI_ENV_SEARCH_LOCATIONS {"AppData", "HOME", "JUCI_HOME"} @@ -13,24 +13,36 @@ const std::string configjson = " },\n" " \"terminal_history_size\": 1000,\n" " \"gtk_theme\": {\n" -" \"name\": \"Adwaita\", //Use \"\" for default theme, At least these two exist on all systems: Adwaita, Raleigh\n" -" \"variant\": \"\" //Use \"\" for default variant, and \"dark\" for dark theme variant\n" +" \"name_comment\": \"Use \\\"\\\" for default theme, At least these two exist on all systems: Adwaita, Raleigh\",\n" +" \"name\": \"Adwaita\",\n" +" \"variant_comment\": \"Use \\\"\\\" for default variant, and \\\"dark\\\" for dark theme variant\",\n" +" \"variant\": \"\"\n" " },\n" " \"source\": {\n" -" \"style\": \"juci-light\", //Use \"\" for default style, and for instance juci-dark or juci-dark-blue together with dark gtk_theme variant. Styles from normal gtksourceview install: classic, cobalt, kate, oblivion, solarized-dark, solarized-light, tango\n" +" \"style_comment\": \"Use \\\"\\\" for default style, and for instance juci-dark or juci-dark-blue together with dark gtk_theme variant. Styles from normal gtksourceview install: classic, cobalt, kate, oblivion, solarized-dark, solarized-light, tango\",\n" +" \"style\": \"juci-light\",\n" +" \"font_comment\": \"Use \\\"\\\" for default font, and for instance \\\"Monospace 12\\\" to also set size\",\n" #ifdef __APPLE__ -" \"font\": \"Menlo 11\", " +" \"font\": \"Menlo 11\",\n" #else #ifdef _WIN32 -" \"font\": \"Consolas\", " +" \"font\": \"Consolas\",\n" #else -" \"font\": \"Monospace\", " +" \"font\": \"Monospace\",\n" #endif #endif -"//Use \"\" for default font, and for instance \"Monospace 12\" to also set size.\n" " \"show_map\": true,\n" " \"map_font_size\": \"1\",\n" -" \"spellcheck_language\": \"en_US\", //Use \"\" to set language from your locale settings\n" +" \"spellcheck_language_comment\": \"Use \\\"\\\" to set language from your locale settings\",\n" +" \"spellcheck_language\": \"en_US\",\n" +" \"auto_tab_char_and_size_comment\": \"Use false to always use default tab char and size\",\n" +" \"auto_tab_char_and_size\": true,\n" +" \"default_tab_char_comment\": \"Use \\\"\\t\\\" for regular tab\",\n" +" \"default_tab_char\": \" \",\n" +" \"default_tab_size\": 2,\n" +" \"wrap_lines\": false,\n" +" \"highlight_current_line\": true,\n" +" \"show_line_numbers\": true,\n" " \"clang_types\": {\n" " \"8\": \"def:function\",\n" " \"21\": \"def:function\",\n" @@ -45,40 +57,36 @@ const std::string configjson = " \"702\": \"def:statement\",\n" " \"705\": \"def:comment\"\n" " },\n" -" \"auto_tab_char_and_size\": true, //Use false to always use default tab char and size\n" -" \"default_tab_char\": \" \", //Use \"\\t\" for regular tab\n" -" \"default_tab_size\": 2,\n" -" \"wrap_lines\": false,\n" -" \"highlight_current_line\": true,\n" -" \"show_line_numbers\": true\n" +" \"clang_format_style_comment\": \"IndentWidth, AccessModifierOffset and UseTab are set automatically. See http://clang.llvm.org/docs/ClangFormatStyleOptions.html\",\n" +" \"clang_format_style\": \"ColumnLimit: 0\"\n" " },\n" " \"keybindings\": {\n" +" \"preferences\": \"comma\",\n" +" \"quit\": \"q\",\n" " \"new_file\": \"n\",\n" " \"new_folder\": \"n\",\n" -" \"open_folder\": \"o\",\n" " \"open_file\": \"o\",\n" +" \"open_folder\": \"o\",\n" " \"save\": \"s\",\n" " \"save_as\": \"s\",\n" -" \"preferences\": \"comma\",\n" -" \"quit\": \"q\",\n" -" \"edit_copy\": \"c\",\n" -" \"edit_cut\": \"x\",\n" -" \"edit_paste\": \"v\",\n" " \"edit_undo\": \"z\",\n" " \"edit_redo\": \"z\",\n" +" \"edit_cut\": \"x\",\n" +" \"edit_copy\": \"c\",\n" +" \"edit_paste\": \"v\",\n" " \"edit_find\": \"f\",\n" " \"edit_set_tab\": \"\",\n" " \"source_spellcheck\": \"\",\n" " \"source_spellcheck_clear\": \"\",\n" " \"source_spellcheck_next_error\": \"e\",\n" " \"source_indentation_set_buffer_tab\": \"\",\n" -" \"source_indentation_auto_indent_buffer\": \"\",\n" +" \"source_indentation_auto_indent_buffer\": \"i\",\n" " \"source_goto_line\": \"g\",\n" " \"source_center_cursor\": \"l\",\n" +" \"source_find_documentation\": \"d\",\n" " \"source_goto_declaration\": \"d\",\n" " \"source_goto_method\": \"m\",\n" " \"source_rename\": \"r\",\n" -" \"source_find_documentation\": \"d\",\n" " \"source_goto_next_diagnostic\": \"e\",\n" " \"source_apply_fix_its\": \"space\",\n" " \"compile_and_run\": \"Return\",\n" @@ -139,10 +147,11 @@ const std::string juci_light_style = " \n" "\n" "