![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
Hello, Unregistered You are browsing a READ only archive of the main support categories pre 4/21/2008. You will not be able to post or reply any threads in this section.
|
|
Desktop Environments Support for your Ubuntu desktop. Including Gnome, KDE and XFCE. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
First Cup of Ubuntu
![]() Join Date: Apr 2006
Beans: 4
|
WriteRoom/Darkroom/?
Hello everyone, long time listener, first time poster.
My problem is this: I was reading Lifehacker.com, and they suggested a Windows app called "Darkroom," a clone of the OS X program "WriteRoom." http://www.hogbaysoftware.com/product/writeroom Basically, I really really want this simple functionality, and I haven't been able to find it via any text editor for Linux. Does anyone have some suggestions? I need these features: - Fullscreen, no window border - Green text, Courier New, 12 pt - Ability to pad the text on either side, creating a column like WriteRoom does, for ease of reading, while not interfering terribly with the formatting. - Easily save to .txt, preferably with a nice key combination like ctrl-s - No title line or formatting lines like nano/pico - Not totally necessary, but it would really help: word-wrap! I've tried out vim, found it way too complex and byzantine for my simple purposes. I tried using Abiword with a black background, green text, in F11 fullscreen mode, but that retained a menu bar and window border. I suppose if I could get rid of the menu bar I could live with the menu bar. Thanks for your time. |
|
|
|
|
|
#2 |
|
Ubuntu Member
![]() Join Date: May 2005
Location: Ogden, Utah
Beans: 522
Ubuntu 8.10 Intrepid Ibex
|
Re: WriteRoom/Darkroom/?
You need to get familiar with Vim. Although the learning curve may be steep initially, it is one of those skills that you'll be glad you learned.
Using the Gnome terminal, I can have 100% full screen (no menu, no borders, no nothing) just by pressing F11. I can change the color of the text as I please, I can easily save to text files and many many more features that you want plus more. Launching vim in screen, I then can have access to the document remotely either via SSH or Telnet plus being able to edit and create locally. Vim and Gnome terminal are by far your best bet.
__________________
Blog |
|
|
|
|
|
#3 |
|
First Cup of Ubuntu
![]() Join Date: Apr 2006
Beans: 4
|
Re: WriteRoom/Darkroom/?
I had a sinking suspicion that was true, heh. vim does indeed seem very powerful, and I will delve into it.
Could you offer any tips on how I can achieve what I'm going for, though? Perhaps a nice tutorial that you might recommend? So far I've got these elements in vim: - Fullscreen, no window border - Green text, Courier New, 12 pt I need: - Ability to pad the text on either side, creating a column like WriteRoom does, for ease of reading, while not interfering terribly with the formatting. - Easily save to .txt, preferably with a nice key combination like ctrl-s [I know how to save, but is there a key combination or macro I could use? Or perhaps some script that saves as I type, much like WriteRoom?] - Word-wrap - for those blue tildes that start every line to disappear. Call me crazy, but it's just more visual clutter that I'd rather not have. Any way to do this? I will certainly RTFM, but as TFM is right next to a phonebook in size, it'll be a while, and I'd appreciate any help you veterans can give. Thanks again! |
|
|
|
|
|
#4 |
|
First Cup of Ubuntu
![]() Join Date: Jul 2006
Beans: 10
|
Re: WriteRoom/Darkroom/?
I've actually been trying to find a similar program, myself. I would write one if I wasn't so lazy and so used to vim's functionality.
What I've been doing: 1) Run VIM fullscreen. Not even gvim, unless that's what you'd prefer. 2) :set wiw=90 3) :vsplit Do that last one twice. You'll end up with three frames. Select the center one, then hit [ Ctrl ][ = ]. Voila! Centered, 90-character wide window. Unfortunately, it's not too elegant. Alternatively, if you've got gvim compiled with Motif or Xaw/Athena support instead of GTK2, you can define the window padding just like any other Xaw application, but that'll pad all sides of the window rather than just the left and right. That is, unless there's some way to pad specific sides. I forget. |
|
|
|
|
|
#5 |
|
First Cup of Ubuntu
![]() Join Date: Jul 2006
Beans: 10
|
Re: WriteRoom/Darkroom/?
Okay, I lied about being lazy. I'm working on a (very) rudimentary text editor based off of ncurses --- at the moment, it's basically a pretty way to do `cat >> filename.txt << EOF`.
![]() It works more or less like a typewriter. To set it up like in the picture, it's just a fullscreen urxvt: urxvt -sb -b 25 -fg green -bg black -fn "xft:Courier 10 Point:size=10:antialias=true" -e ped If anybody wants to give it a try, reply here or send me a PM. |
|
|
|
|
|
#6 |
|
Ubuntu Member
![]() Join Date: May 2005
Location: Ogden, Utah
Beans: 522
Ubuntu 8.10 Intrepid Ibex
|
Re: WriteRoom/Darkroom/?
Quote:
__________________
Blog |
|
|
|
|
|
#7 |
|
First Cup of Ubuntu
![]() Join Date: Jul 2006
Beans: 10
|
Re: WriteRoom/Darkroom/?
C++. I'm a little rusty after having spent a year dealing with Java, but it works, and quickly.
|
|
|
|
|
|
#8 |
|
A Carafe of Ubuntu
![]() Join Date: Apr 2006
Location: CT, USA
Beans: 84
Ubuntu 7.04 Feisty Fawn
|
Re: WriteRoom/Darkroom/?
You can do this with emacs:
You will need the wmctrl package: Code:
sudo apt-get install wmctrl Code:
(defun darkroom-mode ()
(interactive)
(shell-command "wmctrl -r darkroom -badd,fullscreen")
(set-background-color "black")
(set-foreground-color "green")
(set-cursor-color "white")
(setq left-margin 10)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(transient-mark-mode 1)
(set-face-foreground 'region "black")
(set-face-background 'region "green")
(set-face-foreground 'mode-line "gray15")
(set-face-background 'mode-line "black")
(move-to-left-margin 0 1)
(auto-fill-mode)
(setq text-mode-hook 'darkroom-mode)
)
Code:
emacs -f darkroom-mode -title darkroom -fn -adobe-courier-medium-r-normal--25-180-100-100-m-150-iso8859-1 foo.txt Enjoy! |
|
|
|
|
|
#9 |
|
First Cup of Ubuntu
![]() Join Date: Jul 2006
Beans: 10
|
Re: WriteRoom/Darkroom/?
Ooh. Sweet deal.
|
|
|
|
|
|
#10 |
|
First Cup of Ubuntu
![]() Join Date: Apr 2006
Beans: 4
|
Re: WriteRoom/Darkroom/?
With the gracious help of one of my friends, Arek the Absolute on GameDev.net, I now have a solution to my problems!
Even better than that, I have the source, and I've been tweaking it (with his considerable help) to be even better with each iteration. Hopefully someday it will be ready for primetime in Universe or something! Create a new directory and navigate to it: Code:
mkdir aedit cd aedit Code:
gedit main.cpp Code:
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
This program is simply a sensory-deprivation themed text editor, for concentration purposes.
CTRL+SHIFT+BACKSPACE quits, CTRL+SHIFT+S saves. The first line is used as the filename.
Compile with -DSCROLL option to enable a vertical scrollbar.
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void Destroy();
gboolean Accel(GtkAccelGroup *accel_group, GObject *acceleratable, guint keyval, GdkModifierType modifier);
void modify_cursor_color(GtkWidget *widget, GdkColor *color);
GtkWindow *window = NULL;
GtkWidget *scroll = NULL;
GtkWidget *edit = NULL;
/* the main program is given as a DLL when compiled for Windows to allow the main program to locate the GTK
runtimes before executing the program itself. This is irrelevant to any other platform. */
#ifdef _WIN32
#include <windows.h>
extern "C" __declspec(dllexport) int Main(int argc, char *argv[]){
#else
int main(int argc, char *argv[]){
#endif
gtk_init(&argc,&argv);
// create the window
window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_fullscreen(window);
gtk_window_set_title(window,"Editor");
gtk_window_set_keep_above(window,true);
gtk_widget_set_size_request(GTK_WIDGET(window),600,400);
g_signal_connect(window,"delete_event",G_CALLBACK(Destroy),NULL);
edit = gtk_text_view_new();
//set the side margins for maximum readability
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(edit),256);
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(edit),256);
gtk_widget_set_name(edit,"GtkEditorView");
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(edit),GTK_WRAP_WORD);
scroll = gtk_scrolled_window_new(NULL,NULL);
// simply add a scroll window to allow for convenient scrolling capabilities like the mouse wheel
gtk_container_add(GTK_CONTAINER(window),scroll);
((GtkScrolledWindow*)scroll)->hscrollbar_policy = GTK_POLICY_NEVER;
#ifdef SCROLL
((GtkScrolledWindow*)scroll)->vscrollbar_policy = GTK_POLICY_AUTOMATIC;
#else
((GtkScrolledWindow*)scroll)->vscrollbar_policy = GTK_POLICY_NEVER;
#endif
gtk_container_add(GTK_CONTAINER(scroll),edit);
GdkColor color;
gdk_color_parse("black",&color);
gtk_widget_modify_base(edit,GTK_STATE_NORMAL,&color);
gdk_color_parse("green",&color);
gtk_widget_modify_text(edit,GTK_STATE_NORMAL,&color);
gdk_color_parse("yellow",&color);
modify_cursor_color(edit,&color);
// set the font to monospace
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit));
PangoFontDescription *font_desc = pango_font_description_from_string("Courier New,Monospace 12");
gtk_widget_modify_font(edit,font_desc);
pango_font_description_free(font_desc);
// if specified in the command prompt, attempt to open a file
if (argc > 1){
ifstream file(argv[1]);
if (file){
// prepend the file name on its own line for saving purposes
string body = argv[1];
body.append("\n");
while (file && file.peek() != EOF) body += file.get();
gtk_text_buffer_set_text(buffer,body.c_str(),body.length());
}
} else {
// if no file is specified, simply provide a quick introduction
string intro = "filename.txt\n\n"
"CTRL+SHIFT+BACKSPACE to quit (without saving)\n"
"CTRL+SHIFT+S to save (first line is used as filename)\n";
//Comment the next line if you don't want the initial text shown.
gtk_text_buffer_set_text(buffer,intro.c_str(),intro.length());
}
GtkAccelGroup *accel = gtk_accel_group_new();
GClosure *closure;
GdkModifierType CTRL_SHIFT = (GdkModifierType)(GDK_CONTROL_MASK | GDK_SHIFT_MASK);
// add the quit shortcut
closure = g_cclosure_new(G_CALLBACK(Accel),NULL,NULL);
gtk_accel_group_connect(accel,GDK_BackSpace,CTRL_SHIFT,(GtkAccelFlags)0,closure);
// add the save shortcut
closure = g_cclosure_new(G_CALLBACK(Accel),NULL,NULL);
gtk_accel_group_connect(accel,GDK_S,CTRL_SHIFT,(GtkAccelFlags)0,closure);
gtk_window_add_accel_group(window,accel);
gtk_widget_show_all(GTK_WIDGET(window));
// enter the main application loop
gtk_main();
return 0;
}
void Destroy(){
gtk_main_quit();
}
gboolean Accel(GtkAccelGroup *accel_group, GObject *acceleratable, guint keyval, GdkModifierType modifier){
if (keyval == GDK_BackSpace)
Destroy();
else if (keyval == GDK_S || keyval == GDK_s){
GtkTextIter start, end;
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(edit));
gtk_text_buffer_get_start_iter(buffer,&start);
gtk_text_buffer_get_iter_at_line(buffer,&end,1);
gchar *line = gtk_text_buffer_get_slice(buffer,&start,&end,false);
if (!line) return true;
if (line[0]){
for (int i = 0; line[i] != 0; i++){
if (line[i] == '\b' || line[i] == '\r' || line[i] == '\n') line[i] = 0;
}
ofstream file(line);
start = end;
gtk_text_buffer_get_end_iter(buffer,&end);
gchar *body = gtk_text_buffer_get_slice(buffer,&start,&end,false);
file << body;
g_free(body);
file.close();
}
g_free(line);
}
return true;
}
/*
Thanks to gedit source:
A hack to change the cursor color (widget must be named!)
*/
void modify_cursor_color(GtkWidget *widget, GdkColor *color){
static const char cursor_color_rc[] =
"style \"editor\"\n"
"{\n"
"GtkTextView::cursor-color=\"#%04x%04x%04x\"\n"
"}\n"
"widget \"*.%s\" style : application \"editor\"\n";
const gchar *name;
gchar *rc_temp;
name = gtk_widget_get_name(widget);
if (!name) return;
if (color){
rc_temp = g_strdup_printf(cursor_color_rc,
color->red,
color->green,
color->blue,
name);
} else {
GtkRcStyle *rc_style;
rc_style = gtk_widget_get_modifier_style(widget);
rc_temp = g_strdup_printf(cursor_color_rc,
rc_style->text[GTK_STATE_NORMAL].red,
rc_style->text[GTK_STATE_NORMAL].green,
rc_style->text[GTK_STATE_NORMAL].blue,
name);
}
gtk_rc_parse_string(rc_temp);
gtk_widget_reset_rc_styles(widget);
g_free(rc_temp);
}
Code:
g++ -o editor main.cpp `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` Code:
./editor Thanks! |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|