diff --git a/CMakeLists.txt b/CMakeLists.txt index da710eb..f80481f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,10 @@ cmake_minimum_required (VERSION 2.8.4) set(project_name juci) -set(module juci_to_python_api) +#set(module juci_to_python_api) -#### TODO WINDOWS SUPPORT #### -set(bin_install_path "/usr/local/bin") -set(lib_install_path "/usr/local/lib/python2.7/dist-packages/") -##### +#set(lib_install_path "/usr/local/lib/python2.7/dist-packages/") project (${project_name}) -add_subdirectory("src") \ No newline at end of file +add_subdirectory("src") 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 new file mode 100644 index 0000000..68f217f --- /dev/null +++ b/MINGW-packages/mingw-w64-gtksourceview3/0006-hack-convert-path-back-to-unix.patch @@ -0,0 +1,15 @@ +--- 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 new file mode 100644 index 0000000..e0f07ba --- /dev/null +++ b/MINGW-packages/mingw-w64-gtksourceview3/LICENSE @@ -0,0 +1,27 @@ +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 new file mode 100644 index 0000000..038333a --- /dev/null +++ b/MINGW-packages/mingw-w64-gtksourceview3/PKGBUILD @@ -0,0 +1,64 @@ +# 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 new file mode 100644 index 0000000..e0f07ba --- /dev/null +++ b/MINGW-packages/mingw-w64-gtksourceviewmm3/LICENSE @@ -0,0 +1,27 @@ +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 new file mode 100644 index 0000000..0d842a8 --- /dev/null +++ b/MINGW-packages/mingw-w64-gtksourceviewmm3/PKGBUILD @@ -0,0 +1,33 @@ +_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 3823f43..8fb39cb 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,23 @@ # juCi++ ###### a lightweight C++-IDE with support for C++11 and C++14. ## About -A lot of IDEs struggle with good C++11/14 support. Therefore we -created juCi++. juCi++ is based of the compiler and will *always* -support new versions of C++. +Current IDEs struggle with C++ support due to the complexity of +the programming language. juCI++, however, is designed especially +towards libclang with speed in mind. ## Features -* Syntax highlighing (even C++11/14) -* Superfast autocomletion (even external libraries) -* Accurate refactoring across files -* Basic editor functionallity +* Fast and responsive +* Syntax highlighing (even C++11/14, and more than 100 other file types) +* C++ warnings and errors on the fly +* Fast C++ autocomletion (even external libraries) +* Tooltips showing type information and doxygen documentation +* Refactoring across files * Highlighting of similar types -* write your own plugins in python (limited atm) +* Spell checking depending on file context +* Basic editor functionallity +* Write your own plugins in python (disabled at the moment) ## Dependencies ## -Please install these dependencies on your system. -* libboost-python-dev * libboost-filesystem-dev * libboost-log-dev * libboost-test-dev @@ -23,20 +25,10 @@ Please install these dependencies on your system. * libboost-system-dev * libgtkmm-3.0-dev * libgtksourceview2.0-dev -* libgtksourceviewmm-3.0-dev -* libpython-dev +* libgtksourceviewmm-3.0-dev +* libaspell-dev * libclang-dev * [libclangmm](http://github.com/cppit/libclangmm/) -* cmake -* make -* clang or gcc (compiler) ## Installation ## -Quickstart: -```sh -$ cmake . -$ make -$ sudo make install -``` -See [installation guide](http://github.com/cppit/jucipp/blob/master/docs/install.md) for more details. - +See [installation guide](http://github.com/cppit/jucipp/blob/master/docs/install.md). diff --git a/docs/install.md b/docs/install.md index 345a815..ef2d95c 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,22 +1,90 @@ # juCi++ ## Installation guide ## -Before installation, please install libclangmm see [installation guide](http://github.com/cppit/libclangmm/blob/master/docs/install.md) for installation. -## Debian -First dependencies: +Before installation, please install libclangmm, see [installation guide](http://github.com/cppit/libclangmm/blob/master/docs/install.md). + +## Debian/Ubuntu ```sh -$ sudo apt-get install libboost-python-dev libboost-filesystem-dev libboost-log-dev libboost-test-dev -libboost-thread-dev libboost-system-dev libgtkmm-3.0-dev libgtksourceview2.0-dev libgtksourceviewmm-3.0-dev -libpython-dev libclang-dev make cmake gcc g++ +sudo apt-get install pkg-config libboost-system-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libgtkmm-3.0-dev libgtksourceviewmm-3.0-dev aspell-en libaspell-dev ``` -Install the project: ```sh -$ git clone http://github.com/cppit/jucipp.git juci -$ cd juci -$ cmake . -$ make -$ sudo make install +git clone http://github.com/cppit/jucipp.git +cd jucipp +cmake . +make +sudo make install ``` + +## OS X with Homebrew (http://brew.sh/) +```sh +brew install pkg-config boost gtkmm3 gtksourceviewmm3 aspell +``` + +```sh +git clone https://github.com/cppit/jucipp.git +cd jucipp +cmake . +make +make install +``` + +##Windows with MSYS2 (https://msys2.github.io/) +Install dependencies(replace [arch] with i686 or x86_64 depending on your MSYS2 install): +```sh +pacman -S patch autoconf automake-wrapper mingw-w64-[arch]-gtkmm3 mingw-w64-[arch]-boost mingw-w64-[arch]-aspell mingw-w64-[arch]-aspell-en +``` + +Get juCi++ source: +```sh +git clone https://github.com/cppit/jucipp.git +cd jucipp +``` + +Compiling and installing gtksourceview3 and gtksourceviewmm3: +```sh +cd MINGW-packages/mingw-w64-gtksourceview3/ +makepkg-mingw -sLf +pacman -U mingw-w64-[arch]-gtksourceview3-3.12.0-2-any.pkg.tar.xz +cd ../mingw-w64-gtksourceviewmm3/ +makepkg-mingw -sLf +pacman -U mingw-w64-[arch]-gtksourceviewmm3-3.12.0-1-any.pkg.tar.xz +cd ../../ +``` + +Compile and install juCi++ source: +```sh +cmake -G"MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=/mingw[32 or 64] . +make +make install +``` + + + ## Run ```sh -$ juci +juci +``` + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5f892eb..2d43bff 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,7 @@ if(APPLE) set(CMAKE_MACOSX_RPATH 1) set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig") endif() + INCLUDE(FindPkgConfig) set(validation true) @@ -21,7 +22,7 @@ function(install_help APPLE UNIX WINDOWS) endif(APPLE) endif(UNIX) if(WINDOWS) - message("choco install ${WINDOWS}") + #message("choco install ${WINDOWS}") #Removed this for the time being endif(WINDOWS) endfunction(install_help) @@ -38,10 +39,16 @@ validate(${LCL_FOUND} "clangmm" "clangmm" "clangmm") find_package(LibClang) validate(${LIBCLANG_FOUND} "clang" "libclang-dev" "llvm") -find_package(PythonLibs 2.7) -validate(${PYTHONLIBS_FOUND} "python" "libpython-dev" "python") +#TODO: till clang is fixed on MSYS2 ((lib)clang.dll.a is missing): +if(MSYS) + set(LIBCLANG_LIBRARIES "${CMAKE_INSTALL_PREFIX}/bin/clang.dll") +endif() + +#find_package(PythonLibs 2.7) +#validate(${PYTHONLIBS_FOUND} "python" "libpython-dev" "python") -find_package(Boost 1.55 COMPONENTS python thread log system filesystem REQUIRED) +#find_package(Boost 1.55 COMPONENTS python thread log system filesystem REQUIRED) +find_package(Boost 1.55 COMPONENTS thread log system filesystem REQUIRED) validate(${Boost_FOUND} "boost" "libboost-all-dev" "boost") pkg_check_modules(GTKMM gtkmm-3.0) # The name GTKMM is set here for the variables abouve @@ -50,9 +57,9 @@ validate(${GTKMM_FOUND} "gtkmm" "libgtkmm-dev" "gtkmm") pkg_check_modules(GTKSVMM gtksourceviewmm-3.0) validate(${GTKSVMM_FOUND} "gtksvmm" "libgtksvmm-dev" "gtkmmsv") -if(${validation}) - add_executable(${project_name} - juci.h +find_package(ASPELL REQUIRED) + +set(source_files juci.h juci.cc menu.h menu.cc @@ -66,8 +73,8 @@ if(${validation}) sourcefile.cc window.cc window.h - api.h - api.cc +# api.h +# api.cc notebook.cc notebook.h entrybox.h @@ -75,7 +82,6 @@ if(${validation}) directories.h directories.cc terminal.h - terminal.cc tooltips.h tooltips.cc singletons.h @@ -83,31 +89,42 @@ if(${validation}) cmake.h cmake.cc) - add_library(${module} SHARED - api - api_ext) +if(MSYS) + list(APPEND source_files terminal_win.cc) +else() + list(APPEND source_files terminal.cc) +endif() + +if(${validation}) + add_executable(${project_name} ${source_files}) + +# add_library(${module} SHARED +# api +# api_ext) include_directories( ${Boost_INCLUDE_DIRS} - ${PYTHON_INCLUDE_DIRS} +# ${PYTHON_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS} ${GTKSVMM_INCLUDE_DIRS} ${LCL_INCLUDE_DIRS} - ${LIBCLANG_INCLUDE_DIRS}) + ${LIBCLANG_INCLUDE_DIRS} + ${ASPELL_INCLUDE_DIR}) link_directories( ${GTKMM_LIBRARY_DIRS} ${GTKSVMM_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} - ${PYTHON_INCLUDE_DIRS} +# ${PYTHON_INCLUDE_DIRS} ${LCL_LIBRARY_DIRS} ${LIBCLANG_LIBRARY_DIRS}) - set_target_properties(${module} - PROPERTIES PREFIX "" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/") +# set_target_properties(${module} +# PROPERTIES PREFIX "" +# LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib/") - target_link_libraries(${module} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) +# target_link_libraries(${module} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) +# target_link_libraries(${module} ${Boost_LIBRARIES}) target_link_libraries(${project_name} ${LIBCLANG_LIBRARIES} @@ -115,11 +132,14 @@ if(${validation}) ${GTKMM_LIBRARIES} ${GTKSVMM_LIBRARIES} ${Boost_LIBRARIES} - ${PYTHON_LIBRARIES}) + ${ASPELL_LIBRARIES} +# ${PYTHON_LIBRARIES} + ) - install(TARGETS ${project_name} ${module} - RUNTIME DESTINATION ${bin_install_path} - LIBRARY DESTINATION ${lib_install_path} +# install(TARGETS ${project_name} ${module} + install(TARGETS ${project_name} + RUNTIME DESTINATION bin +# LIBRARY DESTINATION ${lib_install_path} ) endif(${validation}) diff --git a/src/cmake.cc b/src/cmake.cc index d2ecfe6..d112a26 100644 --- a/src/cmake.cc +++ b/src/cmake.cc @@ -46,9 +46,25 @@ CMake::CMake(const boost::filesystem::path &path) { bool CMake::create_compile_commands(const boost::filesystem::path &path) { Singleton::terminal()->print("Creating "+path.string()+"/compile_commands.json\n"); - //TODO: Windows... - if(Singleton::terminal()->execute("cmake . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", path)==EXIT_SUCCESS) + if(Singleton::terminal()->execute(Singleton::Config::terminal()->cmake_command+" . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON", path)==EXIT_SUCCESS) { +#ifdef _WIN32 //Temporary fix to MSYS2's libclang + auto compile_commands_path=path; + compile_commands_path+="/compile_commands.json"; + auto compile_commands_file=juci::filesystem::read(compile_commands_path); + size_t pos=0; + while((pos=compile_commands_file.find("-I/", pos))!=std::string::npos) { + if(pos+3theme_name=cfg.get("gtk_theme.name"); Singleton::Config::window()->theme_variant=cfg.get("gtk_theme.variant"); - + Singleton::Config::terminal()->make_command=cfg.get("project.make_command"); + Singleton::Config::terminal()->cmake_command=cfg.get("project.cmake_command"); } void MainConfig::find_or_create_config_files() { @@ -45,12 +46,16 @@ void MainConfig::GenerateSource() { auto source_cfg = Singleton::Config::source(); auto source_json = cfg.get_child("source"); + source_cfg->spellcheck_language = source_json.get("spellcheck_language"); + source_cfg->default_tab_char = source_json.get("default_tab_char"); source_cfg->default_tab_size = source_json.get("default_tab_size"); source_cfg->auto_tab_char_and_size = source_json.get("auto_tab_char_and_size"); - - source_cfg->highlight_current_line = source_json.get_value("highlight_current_line"); - source_cfg->show_line_numbers = source_json.get_value("show_line_numbers"); + + source_cfg->wrap_lines = source_json.get("wrap_lines"); + + source_cfg->highlight_current_line = source_json.get("highlight_current_line"); + source_cfg->show_line_numbers = source_json.get("show_line_numbers"); for (auto &i : source_json.get_child("clang_types")) source_cfg->clang_types[i.first] = i.second.get_value(); diff --git a/src/entrybox.cc b/src/entrybox.cc index f207e56..e6f5350 100644 --- a/src/entrybox.cc +++ b/src/entrybox.cc @@ -4,12 +4,43 @@ namespace sigc { SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE } +std::unordered_map > EntryBox::entry_histories; + EntryBox::Entry::Entry(const std::string& content, std::function on_activate, unsigned length) : Gtk::Entry(), on_activate(on_activate) { set_max_length(length); set_text(content); + selected_history=0; signal_activate().connect([this](){ - if(this->on_activate) - this->on_activate(get_text()); + if(this->on_activate) { + auto &history=EntryBox::entry_histories[get_placeholder_text()]; + auto text=get_text(); + if(history.size()==0 || (history.size()>0 && *history.begin()!=text)) + history.emplace(history.begin(), text); + selected_history=0; + this->on_activate(text); + } + }); + signal_key_press_event().connect([this](GdkEventKey* key){ + if(key->keyval==GDK_KEY_Up) { + auto &history=entry_histories[get_placeholder_text()]; + if(history.size()>0) { + selected_history++; + if(selected_history>=history.size()) + selected_history=history.size()-1; + set_text(history[selected_history]); + set_position(-1); + } + } + if(key->keyval==GDK_KEY_Down) { + auto &history=entry_histories[get_placeholder_text()]; + if(history.size()>0) { + if(selected_history!=0) + selected_history--; + set_text(history[selected_history]); + set_position(-1); + } + } + return false; }); } diff --git a/src/entrybox.h b/src/entrybox.h index 6ff40c1..e7bdebd 100644 --- a/src/entrybox.h +++ b/src/entrybox.h @@ -4,6 +4,9 @@ #include #include #include "gtkmm.h" +#include +#include +#include class EntryBox : public Gtk::Box { public: @@ -11,6 +14,8 @@ public: public: Entry(const std::string& content="", std::function on_activate=nullptr, unsigned length=50); std::function on_activate; + private: + size_t selected_history; }; class Button : public Gtk::Button { public: @@ -39,6 +44,9 @@ public: std::list