[haiku-commits] haiku: hrev45144 - src/apps/stylededit

  • From: zharik@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 9 Jan 2013 22:00:09 +0100 (CET)

hrev45144 adds 2 changesets to branch 'master'
old head: 2b67e9a3a72acffbd4636d0825e7948c738716fb
new head: c7e76f70bc8ae9edd12dadfd9af11e741583c455
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=c7e76f7+%5E2b67e9a

----------------------------------------------------------------------------

c7087c9: Implement "be:caret_position" document file attribute.
  
  * Use "be:caret_position"document file attribute instead of
    "be:line" and "be:selection_{length|offset}" file attributes;
  * Fixed code style violations. Thanks to Axel for pointing it out!

c7e76f7: Support x86_64 platform in makefile-engine

                                        [ Siarzhuk Zharski <zharik@xxxxxx> ]

----------------------------------------------------------------------------

4 files changed, 17 insertions(+), 41 deletions(-)
data/develop/makefile-engine             |  2 +-
src/apps/stylededit/Constants.h          |  2 +-
src/apps/stylededit/StyledEditApp.cpp    | 12 ++++----
src/apps/stylededit/StyledEditWindow.cpp | 42 ++++++----------------------

############################################################################

Commit:      c7087c91837c663ba6794265914f5c408c4f3375
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c7087c9
Author:      Siarzhuk Zharski <zharik@xxxxxx>
Date:        Wed Jan  9 19:23:36 2013 UTC

Implement "be:caret_position" document file attribute.

* Use "be:caret_position"document file attribute instead of
  "be:line" and "be:selection_{length|offset}" file attributes;
* Fixed code style violations. Thanks to Axel for pointing it out!

----------------------------------------------------------------------------

diff --git a/src/apps/stylededit/Constants.h b/src/apps/stylededit/Constants.h
index 03f7387..4c955b6 100644
--- a/src/apps/stylededit/Constants.h
+++ b/src/apps/stylededit/Constants.h
@@ -81,7 +81,7 @@ const uint32 SAVE_THEN_QUIT                           = 
'FPsq';
 // Update StatusView
 const uint32 UPDATE_STATUS                             = 'UPSt';
 const uint32 UNLOCK_FILE                               = 'UNLk';
-const uint32 UPDATE_LINE_SEL                   = 'UPls';
+const uint32 UPDATE_LINE_SELECTION             = 'UPls';
 
 #endif // CONSTANTS_H
 
diff --git a/src/apps/stylededit/StyledEditApp.cpp 
b/src/apps/stylededit/StyledEditApp.cpp
index 664ecbf..0460af8 100644
--- a/src/apps/stylededit/StyledEditApp.cpp
+++ b/src/apps/stylededit/StyledEditApp.cpp
@@ -266,18 +266,18 @@ StyledEditApp::RefsReceived(BMessage* message)
                        length = -1;
                }
 
-               BMessage* selMessage = NULL;
+               BMessage* selection = NULL;
                if (line >= 0 || (start >= 0 && length >= 0)) {
-                       selMessage = new BMessage(UPDATE_LINE_SEL);
+                       selection = new BMessage(UPDATE_LINE_SELECTION);
                        if (line >= 0)
-                               selMessage->AddInt32("be:line", line);
+                               selection->AddInt32("be:line", line);
                        if (start >= 0) {
-                               selMessage->AddInt32("be:selection_offset", 
start);
-                               selMessage->AddInt32("be:selection_length", 
max_c(0, length));
+                               selection->AddInt32("be:selection_offset", 
start);
+                               selection->AddInt32("be:selection_length", 
max_c(0, length));
                        }
                }
 
-               OpenDocument(&ref, selMessage);
+               OpenDocument(&ref, selection);
                index++;
        }
 }
diff --git a/src/apps/stylededit/StyledEditWindow.cpp 
b/src/apps/stylededit/StyledEditWindow.cpp
index 3193bcf..9e08d4f 100644
--- a/src/apps/stylededit/StyledEditWindow.cpp
+++ b/src/apps/stylededit/StyledEditWindow.cpp
@@ -535,7 +535,7 @@ StyledEditWindow::MessageReceived(BMessage* message)
                        break;
                }
 
-               case UPDATE_LINE_SEL:
+               case UPDATE_LINE_SELECTION:
                {
                        int32 line;
                        if (message->FindInt32("be:line", &line) == B_OK) {
@@ -1337,31 +1337,13 @@ StyledEditWindow::_LoadAttrs()
        }
 
        // info about position of caret may live in the file attributes
-       int32 line = 0;
-       int32 lineMax = fTextView->CountLines();
-       if (documentNode.ReadAttr("be:line",
-                       B_INT32_TYPE, 0, &line, sizeof(line)) == sizeof(line))
-               line = min_c(max_c(0, line), lineMax);
-       else
-               line = 0;
-
-       int32 start = 0, length = 0, finish = 0;
-       int32 offsetMax = fTextView->OffsetAt(lineMax);
-       if (documentNode.ReadAttr("be:selection_offset",
-                       B_INT32_TYPE, 0, &start, sizeof(start)) == sizeof(start)
-               && documentNode.ReadAttr("be:selection_length",
-                       B_INT32_TYPE, 0, &length, sizeof(length)) == 
sizeof(length))
-       {
-               finish = start + length;
-               start = min_c(max_c(0, start), offsetMax);
-               finish = min_c(max_c(0, finish), offsetMax);
-       } else {
-               start = fTextView->OffsetAt(line);
-               finish = start;
-       }
+       int32 position = 0;
+       if (documentNode.ReadAttr("be:caret_position", B_INT32_TYPE, 0,
+                       &position, sizeof(position)) != sizeof(position))
+               position = 0;
 
-       fTextView->Select(start, finish);
-       fTextView->ScrollToOffset(start);
+       fTextView->Select(position, position);
+       fTextView->ScrollToOffset(position);
 }
 
 
@@ -1390,17 +1372,11 @@ StyledEditWindow::_SaveAttrs()
        documentNode.WriteAttr(kInfoAttributeName, B_RECT_TYPE, 0, &frame,
                sizeof(BRect));
 
-       // preserve current line and selection too
-       int32 line = fTextView->CurrentLine();
-       documentNode.WriteAttr("be:line", B_INT32_TYPE, 0, &line, sizeof(line));
-
+       // preserve caret line and position
        int32 start, end;
        fTextView->GetSelection(&start, &end);
-       int32 length = end - start;
-       documentNode.WriteAttr("be:selection_offset",
+       documentNode.WriteAttr("be:caret_position",
                        B_INT32_TYPE, 0, &start, sizeof(start));
-       documentNode.WriteAttr("be:selection_length",
-                       B_INT32_TYPE, 0, &length, sizeof(length));
 }
 
 

############################################################################

Revision:    hrev45144
Commit:      c7e76f70bc8ae9edd12dadfd9af11e741583c455
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c7e76f7
Author:      Siarzhuk Zharski <zharik@xxxxxx>
Date:        Wed Jan  9 18:32:35 2013 UTC

Support x86_64 platform in makefile-engine

----------------------------------------------------------------------------

diff --git a/data/develop/makefile-engine b/data/develop/makefile-engine
index 1a2194c..274b072 100644
--- a/data/develop/makefile-engine
+++ b/data/develop/makefile-engine
@@ -148,7 +148,7 @@ VPATH :=
 VPATH += $(addprefix :, $(subst  ,:, $(filter-out $($(subst, :, ,$(VPATH))), 
$(SRC_PATHS))))
 
 #      SETTING: build the local and system include paths, compose C++ libs
-ifeq ($(CPU), x86)
+ifneq (,$(filter $(CPU),x86 x86_64))
        LOC_INCLUDES = $(foreach path, $(SRC_PATHS) $(LOCAL_INCLUDE_PATHS), 
$(addprefix -I, $(path)))
  ifeq ($(CC_VER), 2)
        INCLUDES = $(LOC_INCLUDES)


Other related posts: