Index: src/apps/stylededit/StyledEditWindow.cpp
===================================================================
--- src/apps/stylededit/StyledEditWindow.cpp	(revision 39467)
+++ src/apps/stylededit/StyledEditWindow.cpp	(working copy)
@@ -41,6 +41,7 @@
 #include <TextControl.h>
 #include <TextView.h>
 #include <TranslationUtils.h>
+#include <UnicodeChar.h>
 
 
 using namespace BPrivate;
@@ -218,7 +219,7 @@
 	fCopyItem->SetEnabled(false);
 	fCopyItem->SetTarget(fTextView);
 
-	menu->AddItem(menuItem = new BMenuItem(B_TRANSLATE("Paste"),
+	menu->AddItem(fPasteItem = new BMenuItem(B_TRANSLATE("Paste"),
 		new BMessage(B_PASTE), 'V'));
 	menuItem->SetTarget(fTextView);
 	menu->AddItem(fClearItem = new BMenuItem(B_TRANSLATE("Clear"),
@@ -240,7 +241,7 @@
 
 	menu->AddItem(menuItem = new BMenuItem(B_TRANSLATE("Find selection"),
 		new BMessage(MENU_FIND_SELECTION), 'H'));
-	menu->AddItem(menuItem = new BMenuItem(
+	menu->AddItem(fReplaceItem = new BMenuItem(
 		B_TRANSLATE("Replace" B_UTF8_ELLIPSIS),
 		new BMessage(MENU_REPLACE), 'R'));
 	menu->AddItem(fReplaceSameItem = new BMenuItem(B_TRANSLATE("Replace same"),
@@ -323,21 +324,24 @@
 	fMenuBar->AddItem(menu);
 
 	// "Align"-subMenu:
-	subMenu = new BMenu(B_TRANSLATE("Align"));
-	subMenu->SetRadioMode(true);
+	fAlignMenu = new BMenu(B_TRANSLATE("Align"));
+	fAlignMenu->SetRadioMode(true);
 
-	subMenu->AddItem(fAlignLeft = new BMenuItem(B_TRANSLATE("Left"),
+	fAlignMenu->AddItem(fAlignLeft = new BMenuItem(B_TRANSLATE("Left"),
 		new BMessage(ALIGN_LEFT)));
 	fAlignLeft->SetMarked(true);
 
-	subMenu->AddItem(fAlignCenter = new BMenuItem(B_TRANSLATE("Center"),
+	fAlignMenu->AddItem(fAlignCenter = new BMenuItem(B_TRANSLATE("Center"),
 		new BMessage(ALIGN_CENTER)));
-	subMenu->AddItem(fAlignRight = new BMenuItem(B_TRANSLATE("Right"),
+	fAlignMenu->AddItem(fAlignRight = new BMenuItem(B_TRANSLATE("Right"),
 		new BMessage(ALIGN_RIGHT)));
-	menu->AddItem(subMenu);
+	menu->AddItem(fAlignMenu);
+
 	menu->AddItem(fWrapItem = new BMenuItem(B_TRANSLATE("Wrap lines"),
 		new BMessage(WRAP_LINES)));
 	fWrapItem->SetMarked(true);
+    menu->AddItem(fWordCountItem = new BMenuItem(B_TRANSLATE("Word count"),
+        new BMessage(WORD_COUNT)));
 
 	fSavePanel = NULL;
 	fSavePanelEncodingMenu = NULL;
@@ -645,6 +649,9 @@
 			_UpdateCleanUndoRedoSaveRevert();
 			break;
 		}
+		case WORD_COUNT:
+			CountWords();
+			break;
 		case ENABLE_ITEMS:
 			fCutItem->SetEnabled(true);
 			fCopyItem->SetEnabled(true);
@@ -1559,3 +1566,36 @@
 	return false;
 }
 
+
+#undef B_TRANSLATE_CONTEXT
+#define B_TRANSLATE_CONTEXT "WordCount"
+
+
+int32
+StyledEditWindow::CountWords()
+{
+	uint64 words = 0;
+	bool inword = false;
+	uint64 length = BString(fTextView->Text()).Length();
+	
+	for (uint64 i = 0; i < length; i++)	{
+		if (BUnicodeChar::IsSpace(fTextView->Text()[i])) {
+			inword = false;
+		} else if (!inword)	{
+			words++;
+			inword = true;
+		}
+	}
+	
+	BString result;
+	result << B_TRANSLATE("Word count") << '\n' << '\n'
+		<< B_TRANSLATE("Lines:") << ' ' << fTextView->CountLines() << '\n'
+		<< B_TRANSLATE("Characters:") << ' '
+		<< BString(fTextView->Text()).Length() << '\n'
+		<< B_TRANSLATE("Words:") << ' ' << words;
+		
+	BAlert* alert = new BAlert("Word count", result, B_TRANSLATE("OK"), NULL,
+		NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_INFO_ALERT);
+
+	return alert->Go();
+}
Index: src/apps/stylededit/StyledEditWindow.h
===================================================================
--- src/apps/stylededit/StyledEditWindow.h	(revision 39467)
+++ src/apps/stylededit/StyledEditWindow.h	(working copy)
@@ -59,6 +59,7 @@
 		void			SetFontSize(float fontSize);
 		void			SetFontColor(const rgb_color *color);
 		void			SetFontStyle(const char *fontFamily, const char *fontStyle);
+		int32			CountWords();
 		status_t		_LoadFile(entry_ref* ref);
 		void			RevertToSaved();
 		void			_UpdateCleanUndoRedoSaveRevert();
@@ -74,6 +75,7 @@
 		BMenu			*fFontMenu;
 		BMenu			*fFontSizeMenu;
 		BMenu			*fFontColorMenu;
+		BMenu			*fAlignMenu;
 		BMenuItem		*fCurrentFontItem;
 		BMenuItem		*fCurrentStyleItem;
 
@@ -83,9 +85,11 @@
 		BMenuItem		*fUndoItem;
 		BMenuItem		*fCutItem;
 		BMenuItem		*fCopyItem;
+		BMenuItem		*fPasteItem;
 		BMenuItem		*fClearItem;
 
 		BMenuItem		*fFindAgainItem;
+		BMenuItem		*fReplaceItem;
 		BMenuItem		*fReplaceSameItem;
 
 		BMenuItem		*fBlackItem;
@@ -97,6 +101,7 @@
 		BMenuItem		*fYellowItem;
 
 		BMenuItem		*fWrapItem;
+		BMenuItem		*fWordCountItem;
 		BMenuItem		*fAlignLeft;
 		BMenuItem		*fAlignCenter;
 		BMenuItem		*fAlignRight;
Index: src/apps/stylededit/Constants.h
===================================================================
--- src/apps/stylededit/Constants.h	(revision 39467)
+++ src/apps/stylededit/Constants.h	(working copy)
@@ -63,6 +63,7 @@
 const uint32 ALIGN_CENTER				= 'ALce';
 const uint32 ALIGN_RIGHT				= 'ALri';
 const uint32 WRAP_LINES					= 'MDwr';
+const uint32 WORD_COUNT					= 'MDwc';
 
 // enables "edit" menuitems
 const uint32 ENABLE_ITEMS				= 'ENit';
