Browse files

Merge branch 'master' of github.com:Mezomish/juffed

  • Loading branch information...
2 parents f816672 + b89be5d commit f3d7ef1153757ecd385ed243cc0711b2596b94af @Mezomish committed Feb 20, 2012
View
62 CMakeLists.txt
@@ -7,10 +7,14 @@
# cd build
# cmake .. -DCMAKE_INSTALL_PREFIX=/usr (or whatever prefix you'd like)
# make
+# make install
+#
+# mac os x notes:
+# juffed.app is build by default. There are some additions to steps above.
+# "make install" is required to get plugins working
+# "make bundle" an optional make target to build bundle with all dependencies inside
+#
-option ( BUILD_PLUGINS "Build plugins from the externally linked SVN" ON )
-option ( APPLEBUNDLE "Build juffed as a Mac OS X bundle" OFF )
-option ( APPLEBUNDLE_STANDALONE "Pack APPLEBUNDLE with all its dependencies (libs)" OFF )
project (juffed)
cmake_minimum_required (VERSION 2.6.0)
@@ -147,7 +151,7 @@ target_link_libraries ( ${QSCI_ENGINE}
${QSCINTILLA_LIBRARY}
)
-if (APPLEBUNDLE)
+if (APPLE)
message ( STATUS "Building as an apple bundle" )
set ( APPLE_PREFIX "${CMAKE_INSTALL_PREFIX}/${JUFFED}.app/Contents" )
@@ -168,7 +172,7 @@ if (APPLEBUNDLE)
# this is a must to load the lib correctly
set_target_properties( ${JUFFLIB} PROPERTIES INSTALL_NAME_DIR "@executable_path/../MacOS" )
set_target_properties( ${QSCI_ENGINE} PROPERTIES INSTALL_NAME_DIR "@executable_path/../MacOS" )
-else (APPLEBUNDLE)
+else (APPLE)
set(GUI_TYPE "")
set(APPLE_BUNDLE_SOURCES "")
# now we want to use soversion etc.
@@ -181,7 +185,7 @@ else (APPLEBUNDLE)
set_target_properties( ${JUFFLIB} PROPERTIES INSTALL_NAME_DIR ${LIB_INSTALL_DIR} )
set_target_properties( ${QSCI_ENGINE} PROPERTIES INSTALL_NAME_DIR ${LIB_INSTALL_DIR} )
endif (NOT APPLE)
-endif (APPLEBUNDLE)
+endif (APPLE)
if ( MINGW )
add_definitions(
@@ -225,26 +229,22 @@ if ( UNIX )
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wextra")
endif ( UNIX )
-if (BUILD_PLUGINS AND EXISTS ${CMAKE_SOURCE_DIR}/plugins)
- message(STATUS "Plugins: all externally linked cmake-ready plugs will be built")
- set(JUFFED_CMAKE_PLUGINS 1)
- if (UNIX)
- set(JUFFED_PLUGINS_DIR ${LIB_INSTALL_DIR}/juffed/plugins)
- endif (UNIX)
- if (APPLEBUNDLE)
- set(JUFFED_PLUGINS_DIR ${APPLE_PREFIX}/plugins)
- endif (APPLEBUNDLE)
- if (WIN32)
- set(JUFFED_PLUGINS_DIR ${CMAKE_INSTALL_PREFIX}/plugins)
- endif(WIN32)
- message(STATUS "Plugins: location = ${JUFFED_PLUGINS_DIR}")
- # dive into external SVN link
- set(JUFFED_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
- set(JUFFED_LIBRARY ${JUFFLIB})
- add_subdirectory(plugins)
-else ()
- message(STATUS "Plugins: externally linked plugins will not be built")
-endif ()
+#
+# plugins
+message(STATUS "Plugins: all externally linked cmake-ready plugs will be built")
+set(JUFFED_CMAKE_PLUGINS 1)
+if (UNIX)
+ set(JUFFED_PLUGINS_DIR ${LIB_INSTALL_DIR}/juffed/plugins)
+endif (UNIX)
+if (APPLE)
+ set(JUFFED_PLUGINS_DIR ${APPLE_PREFIX}/plugins)
+endif (APPLE)
+if (WIN32)
+ set(JUFFED_PLUGINS_DIR ${CMAKE_INSTALL_PREFIX}/plugins)
+endif(WIN32)
+set(JUFFED_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
+set(JUFFED_LIBRARY ${JUFFLIB})
+add_subdirectory(plugins)
#set ( juffed_RCS
# src/app/juffed.rc
@@ -261,7 +261,7 @@ endif ()
####################
# Installs
####################
-if (NOT APPLEBUNDLE)
+if (NOT APPLE)
install ( TARGETS ${JUFFED} DESTINATION ${BIN_INSTALL_DIR} )
install ( TARGETS ${JUFFLIB} DESTINATION ${LIB_INSTALL_DIR} )
@@ -277,7 +277,7 @@ if (NOT APPLEBUNDLE)
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY )
add_custom_target ( uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
-else (NOT APPLEBUNDLE)
+else (NOT APPLE)
install(CODE "message(STATUS \"Cleaning previously installed bundle (rm -r)\")")
install(CODE "execute_process(COMMAND rm -r ${CMAKE_INSTALL_PREFIX}/${JUFFED}.app)")
@@ -293,9 +293,11 @@ else (NOT APPLEBUNDLE)
# helper stuff to create real apple bundle.
# Black magic is summoned here...
- add_subdirectory( macosx )
+ # create a "transportable" bundle - all libs into the bundle: "make bundle" after make install
+ configure_file(macosx/bundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/bundle.cmake @ONLY)
+ add_custom_target(bundle ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/bundle.cmake)
-endif (NOT APPLEBUNDLE)
+endif (NOT APPLE)
# make dist custom target
View
4 macosx/CMakeLists.txt
@@ -1,4 +0,0 @@
-if (APPLEBUNDLE_STANDALONE)
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/bundle.cmake @ONLY)
- install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/bundle.cmake)
-endif (APPLEBUNDLE_STANDALONE)
View
12 macosx/bundle.cmake.in
@@ -48,13 +48,13 @@ fixup_bundle(@CMAKE_INSTALL_PREFIX@/@JUFFED@.app "${inplugs}" @CMAKE_INSTALL_PRE
# FIXUP_BUNDLE copies it into MacOS dir. But we need it in plugins *tree*,
# not a flat dir.
-foreach (item IN LISTS inplugs)
+#foreach (item IN LISTS inplugs)
#message(STATUS "IN: ${item}")
- get_filename_component(fname ${item} NAME)
- message(STATUS "Moving ${fname} back to plugins tree: ${item}")
+# get_filename_component(fname ${item} NAME)
+# message(STATUS "Moving ${fname} back to plugins tree: ${item}")
#message(STATUS " ${fname}")
#message(STATUS " src: @CMAKE_INSTALL_PREFIX@/@JUFFED@.app/Contents/MacOS/${fname}")
#message(STATUS " tgt: ${item}")
- execute_process(COMMAND mv @CMAKE_INSTALL_PREFIX@/@JUFFED@.app/Contents/MacOS/${fname} ${item})
-endforeach()
-
+# execute_process(COMMAND mv @CMAKE_INSTALL_PREFIX@/@JUFFED@.app/Contents/MacOS/${fname} ${item})
+#endforeach()
+
View
13 macosx/strip_bundle.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+#
+# Usage: strip_bundle.sh path/to/directory arch-to-keep
+# Example: strip_bundle.sh ./release/TOra.app x86_64
+# will provide x86_64 only content of the MacOS directory in the same place
+#
+
+echo "Generating new single-architecture bundle for arch: $2"
+echo "Into: $1.$2 (rename required)"
+
+ditto --rsrc --arch $2 $1 $1.$2
+
View
37 plugins/terminal/terminal/TerminalPlugin.cpp
@@ -10,23 +10,22 @@
#include "qtermwidget.h"
-Preferences::Preferences(QTermWidget * term, const QObject * parent,
- int colorIX, const QString & emulation,
- const QFont & font)
+
+Preferences::Preferences(const QObject *parent,
+ const QString &color,
+ const QString &emulation,
+ const QFont &font)
: QWidget()
{
setupUi(this);
- QStringList colorSchemes;
- colorSchemes << "White On Black" << \
- "Green On Black" << \
- "Black On Light Yellow";
- colorSchemaCombo->addItems(colorSchemes);
- colorSchemaCombo->setCurrentIndex(colorIX);
- connect(colorSchemaCombo, SIGNAL(currentIndexChanged(int)),
- parent, SLOT(colorSchemaChanged(int)));
+ colorSchemaCombo->addItems(QTermWidget::availableColorSchemes());
+ int cix = colorSchemaCombo->findText(color);
+ colorSchemaCombo->setCurrentIndex(cix != -1 ? cix : 0);
+ connect(colorSchemaCombo, SIGNAL(currentIndexChanged(const QString&)),
+ parent, SLOT(colorSchemaChanged(const QString &)));
-// emulationComboBox->addItems(term->availableKeyBindings());
+ emulationComboBox->addItems(QTermWidget::availableKeyBindings());
int eix = emulationComboBox->findText(emulation);
emulationComboBox->setCurrentIndex(eix != -1 ? eix : 0 );
connect(emulationComboBox, SIGNAL(currentIndexChanged(const QString&)),
@@ -43,7 +42,6 @@ Preferences::Preferences(QTermWidget * term, const QObject * parent,
TerminalPlugin::TerminalPlugin() : QObject(), JuffPlugin() {
-// w_ = new QWidget();
w_ = new QTermWidget();
w_->setScrollBarPosition(QTermWidget::ScrollBarRight);
w_->setWindowTitle(tr("Terminal"));
@@ -58,11 +56,11 @@ void TerminalPlugin::init()
{
prefFont.fromString(PluginSettings::getString(this, "TerminalFont"));
prefFontSize = prefFont.pointSize();
- prefColorScheme = PluginSettings::getInt(this, "TerminalColorScheme");
+ prefColorScheme = PluginSettings::getString(this, "TerminalColorScheme");
prefEmulation = PluginSettings::getString(this, "TerminalEmulation");
w_->setColorScheme(prefColorScheme);
w_->setTerminalFont(prefFont);
-// w_->setKeyBindings(prefEmulation);
+ w_->setKeyBindings(prefEmulation);
}
TerminalPlugin::~TerminalPlugin() {
@@ -98,7 +96,7 @@ Juff::ActionList TerminalPlugin::mainMenuActions(Juff::MenuID id) const
QWidget * TerminalPlugin::settingsPage() const
{
- return new Preferences(w_, this, prefColorScheme, prefEmulation, prefFont);
+ return new Preferences(this, prefColorScheme, prefEmulation, prefFont);
}
void TerminalPlugin::applySettings()
@@ -109,12 +107,12 @@ void TerminalPlugin::applySettings()
PluginSettings::set(this, "TerminalColorScheme", prefColorScheme);
w_->setColorScheme(prefColorScheme);
w_->setTerminalFont(prefFont);
-// w_->setKeyBindings(prefEmulation);
+ w_->setKeyBindings(prefEmulation);
}
-void TerminalPlugin::colorSchemaChanged(int val)
+void TerminalPlugin::colorSchemaChanged(const QString & val)
{
- prefColorScheme = val + 1;
+ prefColorScheme = val;
}
void TerminalPlugin::emulationChanged(const QString & val)
@@ -153,3 +151,4 @@ void TerminalPlugin::showTerminal()
}
Q_EXPORT_PLUGIN2(terminal, TerminalPlugin)
+
View
14 plugins/terminal/terminal/TerminalPlugin.h
@@ -23,8 +23,9 @@ class Preferences : public QWidget, Ui::Preferences
Q_OBJECT
public:
- Preferences(QTermWidget * term, const QObject * parent,
- int colorIX, const QString & emulation,
+ Preferences(const QObject * parent,
+ const QString &color,
+ const QString & emulation,
const QFont & font);
};
@@ -48,9 +49,9 @@ Q_INTERFACES(JuffPlugin)
void applySettings();
public slots:
- void colorSchemaChanged(int val);
- void emulationChanged(const QString & val);
- void fontChanged(const QFont & val);
+ void colorSchemaChanged(const QString &val);
+ void emulationChanged(const QString &val);
+ void fontChanged(const QFont &val);
void fontSizeChanged(int val);
private slots:
@@ -61,7 +62,7 @@ private slots:
QAction* termAct_;
QTermWidget * m_term;
- int prefColorScheme;
+ QString prefColorScheme;
QString prefEmulation;
QFont prefFont;
int prefFontSize;
@@ -70,3 +71,4 @@ private slots:
};
#endif
+
View
55 plugins/xmlformat/xmlformat.cpp
@@ -25,14 +25,13 @@
#include <QtGui>
#include <QDomDocument>
-#include "Document.h"
-
+#include "EditorSettings.h"
XmlformatPlugin::XmlformatPlugin() : QObject(), JuffPlugin()
{
actDoc = new QAction(QIcon(":xmlwrap"), tr("Format XML Document"), this);
- connect(actDoc, SIGNAL(triggered()), this, SLOT(formatDocument()));
+ connect(actDoc, SIGNAL(triggered()), this, SLOT(format()));
}
void XmlformatPlugin::init() {
@@ -71,30 +70,72 @@ Juff::ActionList XmlformatPlugin::mainMenuActions(Juff::MenuID id) const
return list;
}
-void XmlformatPlugin::formatDocument()
+void XmlformatPlugin::format()
{
Juff::Document* doc = api()->currentDocument();
// api()->currentDocument() never returns NULL, it returns
// NullDoc if there is no docs.
if ( doc->isNull() )
return;
+ // if there is a selection - try to format a selection.
+ // In the other case format all document
+ if (doc->hasSelectedText())
+ {
+ formatSelection(doc);
+ }
+ else
+ {
+ formatDocument(doc);
+ }
+}
+
+void XmlformatPlugin::formatDocument(Juff::Document *doc)
+{
QString content;
+ QDomDocument dom;
+ QString errmsg;
+ int errline, errcolumn;
+
if (! doc->getText(content))
return;
+ if (dom.setContent(content, false, &errmsg, &errline, &errcolumn))
+ {
+ QString newContent = dom.toString(EditorSettings::get(EditorSettings::TabWidth));
+ doc->setText(newContent);
+ }
+ else
+ {
+ QMessageBox::information(0, tr("XML format error"),
+ tr("Cannot format XML due error (line: %1, column: %2)").arg(errline).arg(errcolumn)
+ + "<br/>"
+ + errmsg);
+ }
+}
+
+void XmlformatPlugin::formatSelection(Juff::Document *doc)
+{
+ QString content;
QDomDocument dom;
QString errmsg;
int errline, errcolumn;
+
+ if (! doc->getSelectedText(content))
+ return;
+
+ int line, column, tmp1, tmp2;
+ doc->getSelection(line, column, tmp1, tmp2);
+
if (dom.setContent(content, false, &errmsg, &errline, &errcolumn))
{
- QString newContent = dom.toString(4);
- doc->setText(newContent);
+ QString newContent = dom.toString(EditorSettings::get(EditorSettings::TabWidth));
+ doc->replaceSelectedText(newContent);
}
else
{
QMessageBox::information(0, tr("XML format error"),
- tr("Cannot format XML due error (line: %1, column: %2)").arg(errline).arg(errcolumn)
+ tr("Cannot format XML due error (line: %1, column: %2)").arg(errline+line).arg(errline==1 ? errcolumn+column : errcolumn)
+ "<br/>"
+ errmsg);
}
View
7 plugins/xmlformat/xmlformat.h
@@ -25,6 +25,8 @@
#include <QtCore/QObject>
#include "JuffPlugin.h"
+#include "Document.h"
+
/*! Try to format content of the current dcument as a XML or
similar markup language (HTML, SGML,...)
@@ -47,10 +49,13 @@ class XmlformatPlugin : public QObject, public JuffPlugin {
Juff::ActionList mainMenuActions(Juff::MenuID) const;
public slots:
- void formatDocument();
+ void format();
private:
QAction * actDoc;
+
+ void formatDocument(Juff::Document *doc);
+ void formatSelection(Juff::Document *doc);
};
#endif

0 comments on commit f3d7ef1

Please sign in to comment.