mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
cursespp no longer requires boost.
This commit is contained in:
parent
5386526f58
commit
0ee77c9c9d
@ -45,7 +45,7 @@ namespace musik { namespace core { namespace sdk {
|
||||
virtual void Destroy() = 0;
|
||||
virtual double SetPosition(double seconds) = 0;
|
||||
virtual bool GetBuffer(IBuffer *buffer) = 0;
|
||||
virtual bool Open(musik::core::sdk::IDataStream *stream) = 0;
|
||||
virtual bool Open(IDataStream *stream) = 0;
|
||||
};
|
||||
|
||||
} } }
|
||||
|
@ -34,6 +34,8 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <cursespp/App.h>
|
||||
#include <cursespp/Screen.h>
|
||||
|
||||
@ -51,7 +53,11 @@
|
||||
#include <core/support/PreferenceKeys.h>
|
||||
#include <core/audio/Visualizer.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
|
||||
#ifdef WIN32
|
||||
#undef MOUSE_MOVED
|
||||
@ -77,6 +83,11 @@ int _main(int argc, _TCHAR* argv[])
|
||||
int main(int argc, char* argv[])
|
||||
#endif
|
||||
{
|
||||
/* the following allows boost::filesystem to use utf8 on Windows */
|
||||
std::locale locale = std::locale();
|
||||
std::locale utf8Locale(locale, new boost::filesystem::detail::utf8_codecvt_facet);
|
||||
boost::filesystem::path::imbue(utf8Locale);
|
||||
|
||||
#ifndef WIN32
|
||||
#if 1 /*DEBUG*/
|
||||
freopen("/tmp/musikbox.log", "w", stderr);
|
||||
|
@ -43,12 +43,6 @@
|
||||
#include "Text.h"
|
||||
#include "Screen.h"
|
||||
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
|
||||
#include <thread>
|
||||
|
||||
#ifndef WIN32
|
||||
@ -56,7 +50,7 @@
|
||||
#endif
|
||||
|
||||
using namespace cursespp;
|
||||
using namespace boost::chrono;
|
||||
using namespace std::chrono;
|
||||
|
||||
static OverlayStack overlays;
|
||||
static bool disconnected = false;
|
||||
@ -74,11 +68,6 @@ static void resizedHandler(int signal) {
|
||||
#endif
|
||||
|
||||
App::App(const std::string& title) {
|
||||
/* the following allows boost::filesystem to use utf8 on Windows */
|
||||
std::locale locale = std::locale();
|
||||
std::locale utf8Locale(locale, new boost::filesystem::detail::utf8_codecvt_facet);
|
||||
boost::filesystem::path::imbue(utf8Locale);
|
||||
|
||||
this->minWidth = this->minHeight = 0;
|
||||
|
||||
#ifndef WIN32
|
||||
|
@ -36,9 +36,11 @@
|
||||
#include <algorithm>
|
||||
#include "MessageQueue.h"
|
||||
|
||||
using namespace boost::chrono;
|
||||
using namespace std::chrono;
|
||||
using namespace cursespp;
|
||||
|
||||
using LockT = std::unique_lock<std::recursive_mutex>;
|
||||
|
||||
MessageQueue MessageQueue::instance;
|
||||
|
||||
MessageQueue::MessageQueue() {
|
||||
@ -53,11 +55,11 @@ void MessageQueue::Dispatch() {
|
||||
milliseconds now = duration_cast<milliseconds>(
|
||||
system_clock::now().time_since_epoch());
|
||||
|
||||
typedef std::list<EnqueuedMessage*>::iterator Iterator;
|
||||
using Iterator = std::list<EnqueuedMessage*>::iterator;
|
||||
std::list<EnqueuedMessage*> toDispatch;
|
||||
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(this->queueMutex);
|
||||
LockT lock(this->queueMutex);
|
||||
|
||||
Iterator it = this->queue.begin();
|
||||
|
||||
@ -90,7 +92,7 @@ void MessageQueue::Dispatch() {
|
||||
}
|
||||
|
||||
void MessageQueue::Remove(IMessageTarget *target, int type) {
|
||||
boost::recursive_mutex::scoped_lock lock(this->queueMutex);
|
||||
LockT lock(this->queueMutex);
|
||||
|
||||
std::list<EnqueuedMessage*>::iterator it = this->queue.begin();
|
||||
while (it != this->queue.end()) {
|
||||
@ -109,7 +111,7 @@ void MessageQueue::Remove(IMessageTarget *target, int type) {
|
||||
}
|
||||
|
||||
void MessageQueue::Post(IMessagePtr message, int64 delayMs) {
|
||||
boost::recursive_mutex::scoped_lock lock(this->queueMutex);
|
||||
LockT lock(this->queueMutex);
|
||||
|
||||
delayMs = std::max((int64) 0, delayMs);
|
||||
|
||||
|
@ -37,8 +37,8 @@
|
||||
#include "IMessage.h"
|
||||
#include "IMessageTarget.h"
|
||||
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
|
||||
namespace cursespp {
|
||||
class MessageQueue {
|
||||
@ -56,10 +56,10 @@ namespace cursespp {
|
||||
|
||||
struct EnqueuedMessage {
|
||||
IMessagePtr message;
|
||||
boost::chrono::milliseconds time;
|
||||
std::chrono::milliseconds time;
|
||||
};
|
||||
|
||||
boost::recursive_mutex queueMutex;
|
||||
std::recursive_mutex queueMutex;
|
||||
std::list<EnqueuedMessage*> queue;
|
||||
|
||||
MessageQueue();
|
||||
|
@ -38,8 +38,6 @@
|
||||
#include "Colors.h"
|
||||
#include "Text.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
using namespace cursespp;
|
||||
|
||||
ShortcutsWindow::ShortcutsWindow()
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "MultiLineEntry.h"
|
||||
#include "ScrollableWindow.h"
|
||||
#include "Colors.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <utf8/utf8/unchecked.h>
|
||||
|
||||
using namespace cursespp;
|
||||
|
@ -34,7 +34,6 @@
|
||||
|
||||
#include <stdafx.h>
|
||||
#include "SingleLineEntry.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
using namespace cursespp;
|
||||
|
||||
|
@ -40,9 +40,6 @@
|
||||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#define PAD(str, count) for (size_t i = 0; i < count; i++) { str += " "; }
|
||||
|
||||
namespace cursespp {
|
||||
@ -108,6 +105,33 @@ namespace cursespp {
|
||||
}
|
||||
}
|
||||
|
||||
/* not rocket science, but stolen from http://stackoverflow.com/a/1493195 */
|
||||
std::vector<std::string> Split(const std::string& str, const std::string& delimiters, bool trimEmpty) {
|
||||
using ContainerT = std::vector<std::string>;
|
||||
ContainerT tokens;
|
||||
std::string::size_type pos, lastPos = 0, length = str.length();
|
||||
|
||||
using value_type = typename ContainerT::value_type;
|
||||
using size_type = typename ContainerT::size_type;
|
||||
|
||||
while (lastPos < length + 1) {
|
||||
pos = str.find_first_of(delimiters, lastPos);
|
||||
if (pos == std::string::npos) {
|
||||
pos = length;
|
||||
}
|
||||
|
||||
if (pos != lastPos || !trimEmpty) {
|
||||
tokens.push_back(value_type(
|
||||
str.data() + lastPos,
|
||||
(size_type) pos - lastPos));
|
||||
}
|
||||
|
||||
lastPos = pos + 1;
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
inline void privateBreakLines(
|
||||
const std::string& line,
|
||||
size_t width,
|
||||
@ -128,8 +152,7 @@ namespace cursespp {
|
||||
else {
|
||||
/* split by whitespace */
|
||||
|
||||
std::vector<std::string> words;
|
||||
boost::algorithm::split(words, line, boost::is_any_of(" \t\v\f\r"));
|
||||
std::vector<std::string> words = Split(line, " \t\v\f\r");
|
||||
|
||||
/* this isn't super efficient, but let's find all words that are greater
|
||||
than the width and break them into more sublines... it's possible to
|
||||
@ -234,8 +257,7 @@ namespace cursespp {
|
||||
std::vector<std::string> result;
|
||||
|
||||
if (width > 0) {
|
||||
std::vector<std::string> split;
|
||||
boost::algorithm::split(split, line, boost::is_any_of("\n"));
|
||||
std::vector<std::string> split = Split(line, "\n");
|
||||
|
||||
for (size_t i = 0; i < split.size(); i++) {
|
||||
privateBreakLines(split.at(i), width, result);
|
||||
|
@ -47,6 +47,7 @@ namespace cursespp {
|
||||
std::string Ellipsize(const std::string& str, size_t len);
|
||||
std::string Align(const std::string& str, TextAlign align, size_t len);
|
||||
std::vector<std::string> BreakLines(const std::string& line, size_t width);
|
||||
std::vector<std::string> Split(const std::string& str, const std::string& delimiters = " ", bool trimEmpty = false);
|
||||
}
|
||||
|
||||
namespace key {
|
||||
|
@ -34,15 +34,12 @@
|
||||
|
||||
#include <stdafx.h>
|
||||
|
||||
#include <cursespp/Screen.h>
|
||||
#include <cursespp/Colors.h>
|
||||
#include <cursespp/MessageQueue.h>
|
||||
#include <cursespp/Message.h>
|
||||
|
||||
#include "Screen.h"
|
||||
#include "Colors.h"
|
||||
#include "MessageQueue.h"
|
||||
#include "Message.h"
|
||||
#include "TextInput.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
using namespace cursespp;
|
||||
|
||||
inline static void redrawContents(IWindow &window, const std::string& text) {
|
||||
@ -108,7 +105,7 @@ bool TextInput::Write(const std::string& key) {
|
||||
if (len == 1 || (len > 1 && this->inputMode == InputRaw)) {
|
||||
if (this->inputMode == InputRaw) {
|
||||
this->buffer = key;
|
||||
this->bufferLength = len;
|
||||
this->bufferLength = len;
|
||||
this->position = len;
|
||||
}
|
||||
else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user