diff options
author | David Walter Seikel | 2014-01-28 01:20:24 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-01-28 01:20:24 +1000 |
commit | 02fa96ac5e987640db4acc4f47f186710eb63e3f (patch) | |
tree | 1bde935b9711741525d139f066074627b5713afe /boxes.c | |
parent | More command comments. (diff) | |
download | opensim-SC-02fa96ac5e987640db4acc4f47f186710eb63e3f.zip opensim-SC-02fa96ac5e987640db4acc4f47f186710eb63e3f.tar.gz opensim-SC-02fa96ac5e987640db4acc4f47f186710eb63e3f.tar.bz2 opensim-SC-02fa96ac5e987640db4acc4f47f186710eb63e3f.tar.xz |
More vi fixes after the re organisation.
Diffstat (limited to 'boxes.c')
-rw-r--r-- | boxes.c | 49 |
1 files changed, 34 insertions, 15 deletions
@@ -1798,6 +1798,10 @@ void editLine(view *view, int16_t X, int16_t Y, int16_t W, int16_t H) | |||
1798 | // TODO - We can reuse one or two of these to have less of them. | 1798 | // TODO - We can reuse one or two of these to have less of them. |
1799 | int j = 0, p, ret, y, len; | 1799 | int j = 0, p, ret, y, len; |
1800 | 1800 | ||
1801 | // This is using the currentBox instead of view, coz the command line keys are part of the box context now, not separate. | ||
1802 | // More importantly, the currentBox may change due to a command. | ||
1803 | struct keyCommand *ourKeys = currentBox->view->content->context->modes[currentBox->view->mode].keys; | ||
1804 | |||
1801 | // Coz things might change out from under us, find the current view. | 1805 | // Coz things might change out from under us, find the current view. |
1802 | // TODO - see if I can get this lot out of here. | 1806 | // TODO - see if I can get this lot out of here. |
1803 | if (commandMode) view = commandLine; | 1807 | if (commandMode) view = commandLine; |
@@ -1814,6 +1818,8 @@ void editLine(view *view, int16_t X, int16_t Y, int16_t W, int16_t H) | |||
1814 | pollfds[0].events = POLLIN; | 1818 | pollfds[0].events = POLLIN; |
1815 | pollfds[0].fd = 0; | 1819 | pollfds[0].fd = 0; |
1816 | 1820 | ||
1821 | // TODO - A bit unstable at the moment, something makes it go into a horrid CPU eating edit line flicker mode sometimes. And / or vi mode can crash on exit (stack smash). | ||
1822 | |||
1817 | // TODO - Should only ask for a time out after we get an Escape. | 1823 | // TODO - Should only ask for a time out after we get an Escape. |
1818 | p = poll(pollfds, pollcount, 100); // Timeout of one tenth of a second (100). | 1824 | p = poll(pollfds, pollcount, 100); // Timeout of one tenth of a second (100). |
1819 | if (0 > p) perror_exit("poll"); | 1825 | if (0 > p) perror_exit("poll"); |
@@ -1865,8 +1871,6 @@ void editLine(view *view, int16_t X, int16_t Y, int16_t W, int16_t H) | |||
1865 | } | 1871 | } |
1866 | } | 1872 | } |
1867 | 1873 | ||
1868 | // TODO - think vi got screwed up now. sigh | ||
1869 | |||
1870 | // For a real timeout checked Esc, buffer is now empty, so this for loop wont find it anyway. | 1874 | // For a real timeout checked Esc, buffer is now empty, so this for loop wont find it anyway. |
1871 | // While it's true we could avoid it by checking, the user already had to wait for a time out, and this loop wont take THAT long. | 1875 | // While it's true we could avoid it by checking, the user already had to wait for a time out, and this loop wont take THAT long. |
1872 | for (j = 0; keys[j].code; j++) // Search for multibyte keys and some control keys. | 1876 | for (j = 0; keys[j].code; j++) // Search for multibyte keys and some control keys. |
@@ -1883,17 +1887,36 @@ void editLine(view *view, int16_t X, int16_t Y, int16_t W, int16_t H) | |||
1883 | // See if it's an ordinary key, | 1887 | // See if it's an ordinary key, |
1884 | if ((1 == index) && isprint(buffer[0])) | 1888 | if ((1 == index) && isprint(buffer[0])) |
1885 | { | 1889 | { |
1890 | int visucks = 0; | ||
1891 | |||
1892 | // Here we want to pass it to the command finder first, and only "insert" it if it's not a command. | ||
1893 | // Less and more have the "ZZ" command, but nothing else seems to have multi ordinary character commands. | ||
1894 | // Less and more also have some ordinary character commands, mostly vi like. | ||
1895 | for (j = 0; ourKeys[j].key; j++) | ||
1896 | { | ||
1897 | // Yes, that's right, we are scanning ourKeys twice, coz vi. | ||
1898 | // TODO - We can wriggle out of this later by bumping visucks up a scope and storing a pointer to ourKeys[j].command. | ||
1899 | // In fact, visucks could be that pointer. | ||
1900 | if (strcmp(ourKeys[j].key, buffer) == 0) | ||
1901 | { | ||
1902 | strcpy(command, buffer); | ||
1903 | visucks = 1; | ||
1904 | break; | ||
1905 | } | ||
1906 | } | ||
1886 | // If there's an outstanding command, add this to the end of it. | 1907 | // If there's an outstanding command, add this to the end of it. |
1887 | if (command[0]) | 1908 | if (!visucks) |
1888 | strcat(command, buffer); | ||
1889 | else | ||
1890 | { | 1909 | { |
1891 | // TODO - Should check for tabs to, and insert them. | 1910 | if (command[0]) strcat(command, buffer); |
1892 | // Though better off having a function for that? | 1911 | else |
1893 | // TODO - see if I can get these out of here. Some sort of pushCharacter(buffer, blob) that is passed in. | 1912 | { |
1894 | mooshStrings(view->line, buffer, view->iX, 0, !TT.overWriteMode); | 1913 | // TODO - Should check for tabs to, and insert them. |
1895 | view->oW = formatLine(view, view->line->line, &(view->output)); | 1914 | // Though better off having a function for that? |
1896 | moveCursorRelative(view, strlen(buffer), 0, 0, 0); | 1915 | // TODO - see if I can get these out of here. Some sort of pushCharacter(buffer, blob) that is passed in. |
1916 | mooshStrings(view->line, buffer, view->iX, 0, !TT.overWriteMode); | ||
1917 | view->oW = formatLine(view, view->line->line, &(view->output)); | ||
1918 | moveCursorRelative(view, strlen(buffer), 0, 0, 0); | ||
1919 | } | ||
1897 | } | 1920 | } |
1898 | index = 0; | 1921 | index = 0; |
1899 | buffer[0] = 0; | 1922 | buffer[0] = 0; |
@@ -1909,10 +1932,6 @@ void editLine(view *view, int16_t X, int16_t Y, int16_t W, int16_t H) | |||
1909 | command[0] = 0; | 1932 | command[0] = 0; |
1910 | } | 1933 | } |
1911 | 1934 | ||
1912 | // This is using the currentBox instead of view, coz the command line keys are part of the box context now, not separate. | ||
1913 | // More importantly, the currentBox may change due to a command. | ||
1914 | struct keyCommand *ourKeys = currentBox->view->content->context->modes[currentBox->view->mode].keys; | ||
1915 | |||
1916 | for (j = 0; ourKeys[j].key; j++) | 1935 | for (j = 0; ourKeys[j].key; j++) |
1917 | { | 1936 | { |
1918 | if (strcmp(ourKeys[j].key, command) == 0) | 1937 | if (strcmp(ourKeys[j].key, command) == 0) |